0
$\begingroup$

Rosanswers logo

I am able to move a 2 arm ABB YuMi robot arm (7 joints and a gripper per arm) using the following function as intended (http://docs.ros.org/en/noetic/api/sensor_msgs/html/msg/JointState.html)

  def go_joint(self, position, arm, reuse_controller=False):

    if not reuse_controller:
        self.request_controller(arm)

    state = JointState()
    state.header = Header()
    state.header.stamp = rospy.Time.now()
    if arm == LEFT:
        state.name = ['yumi_robl_joint_1','yumi_robl_joint_2','yumi_robl_joint_3','yumi_robl_joint_4','yumi_robl_joint_5','yumi_robl_joint_6','yumi_robl_joint_7','gripper_l_joint']
    else:
        state.name = ['yumi_robr_joint_1','yumi_robr_joint_2','yumi_robr_joint_3','yumi_robr_joint_4','yumi_robr_joint_5','yumi_robr_joint_6','yumi_robr_joint_7','gripper_r_joint']
    state.position = position
    state.velocity = [10]*8
    state.effort = []
    self.cur_arm.go(state, wait=True)

    print(state)

However, despite the fact that the velocity is being registered (here is an print of the state)

header: 
seq: 0
stamp: 
  secs: 1672929166
  nsecs: 529814243
frame_id: ''
name: 
  - yumi_robl_joint_1
  - yumi_robl_joint_2
  - yumi_robl_joint_3
  - yumi_robl_joint_4
  - yumi_robl_joint_5
  - yumi_robl_joint_6
  - yumi_robl_joint_7
  - gripper_l_joint
position: [0.25920000672340393, -1.1437000036239624, 1.0319000482559204, 0.2806999981403351, -0.002400000113993883, 0.9562000036239624, -0.2125999927520752, 0.0]
velocity: [10, 10, 10, 10, 10, 10, 10, 10]
effort: []

The speed of the movement is not changing. Any idea why this is happening ?


Originally posted by ramyun on ROS Answers with karma: 3 on 2023-01-05

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Yes, the reason is that the JointState message http://docs.ros.org/en/noetic/api/sensor_msgs/html/msg/JointState.html is more like a container than a controller. You send an information (e.g. the position of a particular joint) and the robot move to that coordinate. The velocity field in the message are not changing the velocity (meant as a state) of the robot. But they are used more for "information porpuses". If you want to change the speed/velocity of the robot for moving from point A to point B slower or quicker, then you can only control the frequency of the JointState message. By increasing or reducing the time lapse between two messages, you can control the speed/velocity for your robot around one or more joints. Is it clear?

EDIT: For instance, let's take the tutorial on this site and let change it to move quickly around the 3 joints: https://docs.ros.org/en/humble/Tutorials/Intermediate/URDF/Using-URDF-with-Robot-State-Publisher.html

Looking in the code, we find out, that a "frequency" has been passed as an argument to the method loop_rate

...
 loop_rate = self.create_rate(30)
...

If we take the same code and replace the fixes value 30 with a variable:

...
self.frequency = 30
...
loop_rate = self.create_rate(self.frequency)
...

....
    self.frequency += 10  # Or self.frequency -= 10 if you want to decrease your speed.
...

then you have indirectly changed the frequency at which you send the msg JointState

But pay attention: The example above is not professional and definetely not elegant. I personally would keep the loop_rate constant and change only the frequency at which the single joint state messages are sent. In pseudocode:

if (timecurrent - timeprevious) > delta_time:  # Where delta_time is a variable which can be changed according to your desired speed
    self.joint_pub.publish(joint_state)

Originally posted by Andromeda with karma: 893 on 2023-01-09

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by ramyun on 2023-01-09:
Thank you for your comment about the velocity. I am actually new to this, can you please elaborate on your second comment (for the time lapse)? Because I think I did try increasing it and there was an overutilization of the channel. Maybe I did it the wrong way, I would appreciate any further details or any link that can guide me through it. Thanks again.

Comment by Andromeda on 2023-01-09:
I edited my answer above

$\endgroup$

Your Answer

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