Change frequency for publisher topic


Recommended Posts


I have read:

"By default, all the joint control publishers and subscribers provided by the Sawyer SDK run at 100Hz, but can be run up to a rate of 800Hz reliably. See the links for more detailed explanations"

How can I change the frequency? Is there a topic or configuration. I have been looking without result. 

Thanks for your time  .


Link to comment
Share on other sites

Hi Jose_UTEC,

I think you do not need to fix the control rate on a particular topic or parameter. If you supply the robot with references at a rate of 5 - 800 Hz, the robot will take it. In your code, you just have to set your command, for example using set_joint_trajectory(), make your code "sleep" for a given time, using for example the rospy.Rate() class with sleep() method, then increment and go to next instruction. See the example below (same as in other thread)

import rospy
import intera_interface

limb = intera_interface.Limb('right')
# control rate, data sent every 0.002 s, meaning controlling at 500 Hz. Can be from 5 Hz to 800 Hz (I think)
rate = 500 # Hz
control_rate = rospy.Rate(rate)
# controlled joints
i = 0 # initializing time step
# looping over your arrays of 60 values for pose, vel and acc for each joint
while i < len(traj_j6):
	pose = [traj_j6[i], traj_j5[i]]
  	velocity = [vel_j6[i], vel_j5[i]]
    acceleration = [acc_j6[i], acc_j5[i]]
    # sending targeted pose, vel and acceleration for current time step  
    limb.set_joint_trajectory(names, pose, velocity, acceleration)
    # incrementing time step
    i += 1
    # make a short break to make sure commands are sent every  0.002 s (500 Hz)
print "Trajectory done..."


When I then look at the joint_command topic after that, I see that commands are indeed sent every 0.002 s (roughly). However, when setting the control rate at 800 Hz (0.00125 sec) with this method, the actual rate at which joint_command messages are sent can sometimes be slightly less precise: delay between each command is slightly off (0.002 sec or 0.001 sec instead of the 0.00125s).
If someone has another more reliable method, I would be interested to know it.

Looking at some other people's codes, like in this thread, it seems they are doing something similar: 



Link to comment
Share on other sites

Thanks for your reply. 

I have already change the publish frequency and works ok.  I add to my code 


rate = rospy.Rate(f)

for n in xrange(ext):


In another hand,  I saw some perturbations in the motion in frequency more than 400 Hz. Please use with caution!



Link to comment
Share on other sites


This topic is now archived and is closed to further replies.