ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Best approach for continuous blinking task

asked 2012-11-07 12:23:52 -0600

Miguel S. gravatar image

Hello!

I'm developping a small node that interfaces with nao_driver which is supposed to offer the user to start a blinking behaviour. The user is supposed to be able to turn on the behaviour and the stop it as needed.

I see two options:

  • Option 1) Create two services (eg. start_blinking and stop_blinking), and put the blinking code in a different thread.
  • Option 2) Use actionlib and then let the user preempt the task to stop it.

Which one is the recommended approach?

I guess it's irrelevant, but I'm coding this with rospy.

Thanks!

Miguel S.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-11-08 01:54:04 -0600

Lorenz gravatar image

I would say using actionlib is best in your case.

Generally, I would say services should never change state while actions can keep state per client. For instance, suppose you have two nodes that start blinking. The implementation of the action server might blink as long as at least one action is still running and stop only after all were preempted. This would be much harder to implement using services.

edit flag offensive delete link more

Comments

1

I would actually do it the other way around: Whenever start_blinking or stop_blinking is called, I'd like the robot to do exactly that, never mind how many clients requested it to start blinking. This might be a question of the desired behavior. If it should be like @Lorenz said, actions is the better way to go.

dornhege gravatar image dornhege  ( 2012-11-08 02:43:12 -0600 )edit

But that could easily lead to inconsistencies because one node might still think the robot is blinking although the other one disabled it. So it would have to monitor the behavior. Actionlib would notify a node by preempting its goal when another node sends a new goal if this behavior is desired.

Lorenz gravatar image Lorenz  ( 2012-11-11 01:56:55 -0600 )edit

Question Tools

Stats

Asked: 2012-11-07 12:23:52 -0600

Seen: 175 times

Last updated: Nov 08 '12