ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to change speed/velocity when moving a robot using JointState?

asked 2023-01-05 08:52:20 -0500

ramyun gravatar image

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/sen...)

  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 ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-01-09 06:30:34 -0500

Andromeda gravatar image

updated 2023-01-09 09:17:49 -0500

Yes, the reason is that the JointStatemessage http://docs.ros.org/en/noetic/api/sen... 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/Tutori...

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)
edit flag offensive delete link more

Comments

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.

ramyun gravatar image ramyun  ( 2023-01-09 07:22:14 -0500 )edit

I edited my answer above

Andromeda gravatar image Andromeda  ( 2023-01-09 09:16:24 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2023-01-05 08:52:20 -0500

Seen: 53 times

Last updated: Jan 09 '23