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

nao control rate [closed]

asked 2013-10-07 07:34:09 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

How can I reduce nao control rate in ros??

I use ros publisher "/cmd_vel"

like this,

ros::NodeHandle n; ros::Publisher cmd_pub = n.advertise<geometry_msgs::twist>("/cmd_vel", 1000);

while (ros::ok()) {

cmd_pub(msg); ros::getGlobalCallbackQueue()->callAvailable(ros::WallDuration(0.5));


so, my control rate is 0.5 seconds.

if I control nao for each 0.4 or 0.3 or less, nao ignore some order.

How can I reduce this interval? I already use spin() or spinOnce(), else(changing function).

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by dlxhrl
close date 2014-07-30 22:10:37.345359

1 Answer

Sort by ยป oldest newest most voted

answered 2013-10-07 12:59:41 -0500

jdorich gravatar image

updated 2013-10-07 16:17:29 -0500

You could use ros::Rate()

ros::NodeHandle n;
ros::Publisher cmd_pub = n.advertise<geometry_msgs::twist>("/cmd_vel", 1000);
ros::Rate loop_rate(2);

while (ros::ok()) {

The "loop_rate" input is a frequency in Hertz so you can adjust that as needed. See this tutorial for more details.

edit flag offensive delete link more


Thank you for your response. OK, i'll try but It doesn't matter?? there are no spin() or spinOnce()?? or callbackqueue?

dlxhrl gravatar image dlxhrl  ( 2013-10-16 15:46:39 -0500 )edit

you only need to use the spin() or spinOnce() if you have subscribed to a topic. The loop_rate.sleep() performs the delay you require in this situation.

jdorich gravatar image jdorich  ( 2013-10-16 16:07:25 -0500 )edit

Question Tools


Asked: 2013-10-07 07:34:09 -0500

Seen: 212 times

Last updated: Oct 07 '13