# Velocity Control using ROS

**URL:** <https://forum.hello-robot.com/t/velocity-control-using-ros/757>\
**Category:** Ask\
**Created:** [June 20, 2023, 12:41pm UTC](https://forum.hello-robot.com/t/velocity-control-using-ros/757 "2023-06-20T12:41:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![akhilp](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/akhilp/32/442_2.png) [@akhilp](https://forum.hello-robot.com/u/akhilp)\
**Post date:** [June 20, 2023, 12:41pm UTC](https://forum.hello-robot.com/t/velocity-control-using-ros/757/1 "2023-06-20T12:41:47Z")

</div>

Is there an easy way to do velocity control of the arm/wrist using ROS?

For the base, I’m currently publishing twists to \cmd\_vel which is extremely straightforward. Is there a similar topic for the arm and wrist or do I need to do something similar to this tutorial: [Follow Joint Trajectory Commands - Stretch Documentation](https://docs.hello-robot.com/0.2/stretch-tutorials/ros1/follow_joint_trajectory/)?

---

<div class="post-metadata">

**Author:** ![akhilp](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/akhilp/32/442_2.png) [@akhilp](https://forum.hello-robot.com/u/akhilp)\
**Post date:** [June 20, 2023, 2:00pm UTC](https://forum.hello-robot.com/t/velocity-control-using-ros/757/2 "2023-06-20T14:00:26Z")

</div>

As a followup, seems like it might make sense to just use the Stretch Body set velocity commands?

---

<div class="post-metadata">

**Author:** ![bshah](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/bshah/32/55_2.png) [@bshah](https://forum.hello-robot.com/u/bshah)\
**Post date:** [June 20, 2023, 3:11pm UTC](https://forum.hello-robot.com/t/velocity-control-using-ros/757/3 "2023-06-20T15:11:30Z")

</div>

Hey @akhilp, our ROS driver doesn’t have velocity control for the bounded joints, so if you’re able to use Stretch Body, I’d recommend going that route. **You cannot use Stretch ROS and Stretch Body simultaneously.** There’s an example script for the arm/lift joints in this topic:

> [@Commanding velocity to the arm and lift](https://forum.hello-robot.com/t/commanding-velocity-to-the-arm-and-lift/386/2):
>
> Hi @sguysc, welcome to the forum! Yes, you can send velocity commands to the [arm](https://github.com/hello-robot/stretch_body/blob/master/body/stretch_body/arm.py#L121-L152) and [lift](https://github.com/hello-robot/stretch_body/blob/master/body/stretch_body/lift.py#L122-L154) joints using the set\_velocity() API in Stretch Body. Here’s an example script of what using this API would look like: import stretch\_body.robot r = stretch\_body.robot.Robot() r.startup() assert(r.is\_calibrated()) # the robot must be homed # move the arm out at 0.05 m/s r.arm.set\_velocity(0.05) r.push\_command() [...] # some time later, move the lift up at 0.05 m/s r.lift.set\_velocity(0.05) r.push\_comman…

If you think it would be useful to have velocity control at the ROS level, I can definitely explain how to make that happen.

---

<div class="post-metadata">

**Author:** ![akhilp](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/akhilp/32/442_2.png) [@akhilp](https://forum.hello-robot.com/u/akhilp)\
**Post date:** [June 20, 2023, 3:30pm UTC](https://forum.hello-robot.com/t/velocity-control-using-ros/757/4 "2023-06-20T15:30:37Z")

</div>

Thanks Binit!

For the gripper and wrist dynamixels, is it possible to do velocity control also?

I saw the following code from this post ([Watchdog on joint velocity](https://forum.hello-robot.com/t/watchdog-on-joint-velocity/619)):

```auto
motor = stretch_body.stepper.Stepper('/dev/hello-motor-right-wheel')
motor.startup()
motor.disable_sync_mode()
motor.enable_vel_traj()
motor.push_command()

motor.set_command(v_des=4.0)
motor.push_command()
time.sleep(20.0)
motor.stop()

```

However, when I try to do:  
`motor = stretch_body.stepper.Stepper('/dev/hello-dynamixel-wrist')`

I get the error: `[ERROR] [hello-dynamixel-wrist]: Parameters for device hello-dynamixel-wrist not found. Check parameter YAML and device name. Exiting...`

I also don’t see the address for the gripper dynamixel in the /dev/ folder.

Thanks again!

---

<div class="post-metadata">

**Author:** ![bshah](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/bshah/32/55_2.png) [@bshah](https://forum.hello-robot.com/u/bshah)\
**Post date:** [June 20, 2023, 3:47pm UTC](https://forum.hello-robot.com/t/velocity-control-using-ros/757/5 "2023-06-20T15:47:41Z")

</div>

Yup, all the dynamixels have velocity control as well. The dynamixels aren’t Stepper joints, so interacting with them looks like this:

```python
import stretch_body.robot

r = stretch_body.robot.Robot()
r.startup()
assert(r.is_calibrated()) # the robot must be homed

# move the wrist_yaw counter clockwise at 0.1 rad/s
r.end_of_arm.get_joint('wrist_yaw').set_velocity(0.1)

[...]

# move the head clockwise at 0.2 rad/s
r.head.get_joint('head_pan').set_velocity(-0.2)

```

---

<div class="post-metadata">

**Author:** ![akhilp](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/akhilp/32/442_2.png) [@akhilp](https://forum.hello-robot.com/u/akhilp)\
**Post date:** [June 20, 2023, 6:02pm UTC](https://forum.hello-robot.com/t/velocity-control-using-ros/757/6 "2023-06-20T18:02:26Z")

</div>

@bshah The dynamixels don’t move when I use the above code. I made sure the robot was homed and also tried putting the two move commands into a while loop.

---

<div class="post-metadata">

**Author:** ![bshah](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/bshah/32/55_2.png) [@bshah](https://forum.hello-robot.com/u/bshah)\
**Post date:** [July 17, 2023, 8:10am UTC](https://forum.hello-robot.com/t/velocity-control-using-ros/757/7 "2023-07-17T08:10:29Z")

</div>

Hey @akhilp, I edited my post above to show how to use the new `set_velocity()` API, which is part of [this PR](https://github.com/hello-robot/stretch_body/pull/194). You’ll see the Dynamixels move correctly with this new API, and the PR fixes a few other bugs related to velocity controlling Dxl joints. You’ll need Stretch Body version 0.5.1 or greater. You can upgrade Stretch Body using:

```auto
pip3 install -U hello-robot-stretch-body

```
