relation between topic frequency and its content

asked 2020-05-27 06:25:33 -0500

azerila gravatar image

updated 2020-05-27 07:57:38 -0500

I have a message which is defined as the following:

std_msgs/Header header
uint32 traj_id
uint32 traj_step
float64[] joints_pos
float64[] joints_vel
float64[] joints_acc
float64[] joints_eff
float32[] wrench_ee
float32[] twist_ee
float32[] wrench_base
float32[] twist_base
float32[] ee_pos
float32[] ee_quat
bool      in_contact

float64[] joints_eff_cmd
float64[] joints_res_eff_cmd
float64[] joints_res_pos_cmd

And have noticed that I can publish this message on a topic with 1kHz if I only fill 9 out of 10 of the float64[] arrays, but if I also fill the the remaining one, the frequency would drop to around 10Hz to 20 Hz, Does this issue make sense and what could be the best workaround for it?

The following is also a part of the code, which I had tried commenting some to see if the issue was specific around ros or other pars of the application. As I tried, it did not matter which float64[] field I leave empty to have kHz, frequency, and or what values I would have given to the remaining one to observe such frequency drop.

For this it seemed to me rather a limitation in Ros or Rospy.

    self.joint_state_msg.joints_res_eff_cmd = res_eff
    self.joint_state_msg.joints_pos     =[:7]
    self.joint_state_msg.joints_vel     =[:7]
    self.joint_state_msg.joints_acc     =[:7]
    self.joint_state_msg.wrench_ee      = [0, 0, 0] #self.robot.getEndEffectorWrench()
    self.joint_state_msg.twist_ee       = [2,5,55,8]  #self.robot.getTwist_ee()
    self.joint_state_msg.ee_pos         = self.robot.getEndEffector_pos()
    self.joint_state_msg.ee_quat        = self.robot.getEndEffector_quat()
    self.joint_state_msg.in_contact     = self.robot.inContact()
    self.joint_state_msg.joints_eff     = self.robot.getTorqueSensors()[:7] 
    self.joint_state_msg.header.stamp   = rospy.Time(self.sim_time)
    self.joint_state_msg.traj_step      = self.traj_step
    self.joint_state_msg.traj_id        = self.traj_id

edit retag flag offensive close merge delete


I am not aware of any relations between the contents and the publishing as is. Could you provide an SSCCE with which this behavior could be reproduced?

Alternatively, please show the relevant parts of the source code as well as describe in more detail what information you put in the msg (same number of elements in the arrays, different number, how many, filled once vs. filled at every "publish" cycle, ...). The issue could very well be in the code where you fill the arrays...

mgruhler gravatar image mgruhler  ( 2020-05-27 06:30:43 -0500 )edit

@mgruhler I have put some part of the code, the remaining codes are too huge to put here. Most of the float64[] fields have 7 number of elements, and I have also tried except wrench and twist that have 6. It didn't matter though which float64[] array I leave empty to get high frequency. All are fields are filled at every publish cycle except one that if I want 1kHz I have to leave empty, and it doens't matter which.

azerila gravatar image azerila  ( 2020-05-27 06:52:52 -0500 )edit

Well, when writing a little test script to confirm this, I've found that at least in the code that you post, there is an error:

self.joint_state_msg.joints_res_eff_cmd = res_eff is wrong, as your message definition doesn't have a joints_res_eff_cmd field. Not sure if this is the issue, as your node should actually crash like that.

Then again, with my simple test script, I didn't have any issues. Could you confirm that this is also working on your machine? Obviously, if one of the function calls during the assignment takes long, this might be an issue. However, as you are saying that it doesn't matter which one you leave empty, this shouldn't be the case...

mgruhler gravatar image mgruhler  ( 2020-05-27 07:37:11 -0500 )edit

@azerila does changing the message have an effect with the test script I put together?

mgruhler gravatar image mgruhler  ( 2020-05-27 08:12:05 -0500 )edit