Skip to content
pbsujit edited this page May 31, 2013 · 31 revisions

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 Tutorials/TempConsume

This will create TempConsume 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 bind IMC::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);
  }