-
Notifications
You must be signed in to change notification settings - Fork 119
ConsumerTask
In this task, we will consume the temperature value produced in the producer task. We will first create a consume task. For this, execute the following command
DH> python programs/scripts/dune-create-task.py . DuneAuthor TempConsm
This will create TempConsm task. To use the temperature value produced by the producer task we need for first bind the message from IMC and write a consume method.
First binding the value from the IMC message, for this include bindIMC::Temperature(this) in the constructor.
`
Task(const std::string& name, Tasks::Context& ctx):
DUNE::Tasks::Task(name, ctx)
{
bind<IMC::Temperature>(this);
}
`
Then create a consumer method before the main loop. The following is the consumer method
void consume(const IMC::Temperature* msg) { inf("temperature is %f", msg->value); }