37 if ( channel(
"Throttle").nonempty() ) {
38 force = channel(
"Throttle").latest();
40 velocity += ( delta() / 1000 ) * ( - k * velocity + force ) / m;
41 channel(
"Velocity").send(velocity);
42 std::cout <<
"t: " << milli_time() <<
" ms\t" 43 <<
" u: " << force <<
" N\t" 44 <<
" v: " << velocity <<
" m/s\n";
53 const double k = 0.02;
54 const double m = 1000;
78 if ( channel(
"Velocity").nonempty() ) {
79 speed = channel(
"Velocity").latest();
81 channel(
"Throttle").send(-KP*(speed - desired_speed));
89 const double desired_speed = 50.0,
The Process Manager class.
void stop()
Nothing to do to stop.
Manager & schedule(Process &process, high_resolution_clock::duration period)
void stop()
Nothing to do to stop.
void init()
Nothing to do to initialize.
CruiseControl(std::string name)
Example: A cruise controller for a Car process. See examples/feedback.cc.
Manager & run(high_resolution_clock::duration runtime)
Manager & add_channel(Channel &)
void start()
Nothing to do to start.
void init()
Nothing to do to initialize.
Example: A car simulation process. See examples/feedback.cc.
A channel for sending double values to and from Process objects.
An abstract base class for processes.