Can AsyncSpinner spins in functions?
Hi, everyone,
I build a simple program to play with turtle under the ROS and Qt environment. Right now I use the signal-slot in Qt to combine the button to the direction function of the turtle in ROS. Since the signal-slot connection only runs function one time as I click the button once, I can't continuously control the turtle in one direction, so I wanna use the AsyncSpinner let one thread of spin in one function to drive the turtle, and in another function, I let the spin stop to stop the turtle's movement. But I tried lots way, I can't get my purpose. So I post the question here, hope to see some hints! The question is when I put the AsyncSpinner inside, the program seems spin in the same place. The code is like that:
void HelloWidget::forWard() {
_qtturtle->setforWard();
ros::AsyncSpinner spinner(1);
spinner.start(); // the spin seems lock the program when I ran
ros::waitForShutdown();
qDebug("step 1");
}
void HelloWidget::forwardStop()
{
_qtturtle->setforWardstop();
spinner.stop(); //I can't use here, because the compiler tells
//that spin is not define in this scope, but I do
// not know how to define AsyncSpinner in ordinary way
// like: AsyncSpinner *spinner in headfile, then
// in construct function, spinner = new AsyncSpinner,because
// it is not work for AsyncSpinner ...
qDebug("step2");
}
Can anyone share some experiences about that? Thanks in advance.