Ask Your Question
0

Is it possible to run a timer inside an action server?

asked 2019-06-21 05:09:18 -0600

schizzz8 gravatar image

updated 2019-06-21 06:45:07 -0600

Hi all,

my question is rather theoretical and it's about best practice, I hope what I'm thinking about it's not completely useless.

Let me introduce you the problem.

Basically, I have a node which is in charge of doing two things:

  • publishing velocity commands to /cmd_vel

  • listening to /joint_states topic

This node is not a controller (as one would expect). The velocity commands are defined a-priori and the subscriber to the /joint_states topic is used to track the robot trajectory. In fact, the publisher spins at 100Hz while the listener at ~50Hz (which is the frequency of the /joint_states topic). To do so, the publisher is implemented with a timer, the listener with a subscriber and I use an asynchronous spinner to run them both in the same node:

  ros::AsyncSpinner spinner(4);
  spinner.start();
  ros::waitForShutdown();

So far so good. Now, imagine I want to implement a safety layer. That is, while tracking the robot trajectory I detect that the robot reached a forbidden position and I want to halt the robot by stopping publishing velocity commands.

My idea was to implement it with an action server. In particular, a server with the GoalCallbackMethod (for the /joint_states topic). Therefore, my question is: can I use a ros::Timer inside the action server class? If possible, what I have to do in order to run the server callback and the timer callback asynchronously? An asynchronous spinner is enough?

Any suggestion would be appreciated!

Thanks.


EDIT: @gvdhoorn: thanks for your reply!

Regarding the last question, my idea was that the action server publishes as feedback the robot pose. Then, the client cancels the goal if the robot reached a forbidden position. Does it make sense to you?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-06-21 06:37:41 -0600

gvdhoorn gravatar image

updated 2019-06-21 07:01:22 -0600

Therefore, my question is: can I use a ros::Timer inside the action server class?

Yes (at least, if you're referring to your own action server class here, not something like SimpleActionServer).

If possible, what I have to do in order to run the server callback and the timer callback asynchronously? An asynchronous spinner is enough?

It should be, yes.

If it doesn't work, post back here.

So far so good. Now, imagine I want to implement a safety layer. That is, while tracking the robot trajectory I detect that the robot reached a forbidden position and I want to halt the robot by stopping publishing velocity commands.

are you describing a valve here? So your node receives velocity commands, checks whether everything is ok. If ok, forward, if not ok, stop forwarding.


Edit:

Regarding the last question, my idea was that the action server publishes as feedback the robot pose. Then, the client cancels the goal if the robot reached a forbidden position. Does it make sense to you?

not really, but it probably does to you, so that is fine.

if the node is not a controller, where does it get its velocity commands from? And if the feedback of the robot is joint_states, couldn't your client subscribe to that topic? Or are you looking at Cartesian poses here? In that case: TF?

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-06-21 05:09:18 -0600

Seen: 80 times

Last updated: Jun 21