Shows how to add a task callback to ArRobot's synchronization/processing cycleA sensor interpretation task callback is invoked by the ArRobot object every cycle as it runs, which records the robot's current pose and velocity.
Note that tasks must take a small amount of time to execute, to avoid delaying the robot cycle.
#include "Aria.h"
class PrintingTask
{
public:
~PrintingTask(void);
void doTask(void);
protected:
};
PrintingTask::PrintingTask(
ArRobot *robot) :
myTaskCB(this, &PrintingTask::doTask)
{
myRobot = robot;
}
PrintingTask::~PrintingTask()
{
myRobot->remSensorInterpTask(&myTaskCB);
}
void PrintingTask::doTask(void)
{
printf("\rx %6.1f y %6.1f th %6.1f vel %7.1f mpacs %3d", myRobot->getX(),
myRobot->getY(), myRobot->getTh(), myRobot->getVel(),
myRobot->getMotorPacCount());
fflush(stdout);
}
int main(int argc, char** argv)
{
{
return 1;
}
PrintingTask pt(&robot);
{
printf("Could not connect to the robot.\n");
return 2;
}
printf("Connected to the robot. (Press Ctrl-C to exit)\n");
printf("Disconnected. Goodbye.\n");
return 0;
}