Change frequency for publisher topic


Jose_UTEC

Recommended Posts

Hello!

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  .

Source: http://sdk.rethinkrobotics.com/intera/Arm_Control_Systems#Joint_Trajectory-Position_Control

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')
limb.move_to_neutral()
# 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
names=['right_j6','right_j5']
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)
    control_rate.sleep()
    
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):
            my_msg.position=[j[0][n],j[1][n],j[2][n],j[3][n],j[4][n],j[5][n],j[6][n]]
            my_msg.velocity=[v[0][n],v[1][n],v[2][n],v[3][n],v[4][n],v[5][n],v[6][n]]
            my_msg.acceleration=[a[0][n],a[1][n],a[2][n],a[3][n],a[4][n],a[5][n],a[6][n]]
            pub.publish(my_msg)
            rate.sleep()

```

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

Archived

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