Kinovarobotics / kinova-ros

ROS packages for Jaco2 and Mico robotic arms
BSD 3-Clause "New" or "Revised" License
365 stars 317 forks source link

How to speed up the sending rate of arm publishers #372

Closed Yang12308 closed 2 years ago

Yang12308 commented 2 years ago

I used the command rostopic hz (like '/j2n6s300_driver/out/joint_state'). And I found that the average rate is 10. Can increase speed of rate to 100. Thx

felixmaisonneuve commented 2 years ago

Hi @Yang12308,

In the kinova_driver/src/kinova_arm.cpp file, in the constructor (KinovaArm()), the driver defines a param status_interval_seconds which correspond to the frequency of the output topics.

You need to change this line : https://github.com/Kinovarobotics/kinova-ros/blob/6b7a12199b29dc7c9ee484eb890bd89e9cf20cd9/kinova_driver/src/kinova_arm.cpp#L224

to this

    node_handle_.param<double>("status_interval_seconds", status_interval_seconds_, 0.01);

and recompile your driver with catkin_make. After that, your output frequency should be 100Hz.

If you don't want to recompile the driver, it might be possible to simply edit the status_interval_seconds param after the driver is launched, but I haven't tried it, so I don't know if it will work. After launching the driver, simply run

rosparam set status_interval_seconds 0.01

Regards, Felix

wxmerkt commented 2 years ago

As a note - this won't work if you connect via USB due to datarate limits (e.g. maxing out between 40-60 Hz for us). It works if you connect via Ethernet.

felixmaisonneuve commented 2 years ago

Also, there is this old issue #281.

To summarize : There is param feedback_publish_rate in the launch file that you can use to change the rate

roslaunch kinova_bringup kinova_robot.launch kinova_robotType:=j2n6s300 feedback_publish_rate:=0.01

Like @wxmerkt said, you might not be able to reach 100Hz. You can comment some of functions that communicates with the arm to accelerate the response time. Topics are published by those 4 functions : https://github.com/Kinovarobotics/kinova-ros/blob/6b7a12199b29dc7c9ee484eb890bd89e9cf20cd9/kinova_driver/src/kinova_arm.cpp#L759-L765

For example, if you only plan to work in angular mode, you could comment publishToolPosition(), publishToolWrench() and publishFingerPosition() (that you won't need).

This will limit the number of call with kinova_comm_.something() and it will increase your refresh rate.

Yang12308 commented 2 years ago

It worked !First i connected via Ethernet Then i used this to start roslaunch kinova_bringup kinova_robot.launch kinova_robotType:=j2n6s300 feedback_publish_rate:=0.01 and Commented some of functions

     publishToolPosition(); 
     publishToolWrench(); 
     publishFingerPosition(); 

bacause i just want the information of angle and velocity for joints The output frequency can be 100Hz.

Thanks,all!