0
$\begingroup$

Rosanswers logo

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).


Originally posted by dlxhrl on ROS Answers with karma: 3 on 2013-10-07

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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()) {
    cmd_pub.publish(msg);
    loop_rate.sleep();
}

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


Originally posted by jdorich with karma: 211 on 2013-10-07

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by dlxhrl on 2013-10-16:
Thank you for your response. OK, i'll try but It doesn't matter?? there are no spin() or spinOnce()?? or callbackqueue?

Comment by jdorich on 2013-10-16:
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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.