# About stretch\_body interface

**URL:** <https://forum.hello-robot.com/t/about-stretch-body-interface/273>\
**Category:** Ask\
**Created:** [August 4, 2021, 2:48pm UTC](https://forum.hello-robot.com/t/about-stretch-body-interface/273 "2021-08-04T14:48:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hehonglu123](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/hehonglu123/32/183_2.png) [@hehonglu123](https://forum.hello-robot.com/u/hehonglu123)\
**Post date:** [August 4, 2021, 2:48pm UTC](https://forum.hello-robot.com/t/about-stretch-body-interface/273/1 "2021-08-04T14:48:46Z")

</div>

Do stretch stepper motors and dynamixel motors support velocity control? I see `MODE_VEL_PID` and `MODE_VEL_TRAJ`.  
The update rate is 15~25Hz, is this the fastest we could get or it’s downsampled somewhere?

---

<div class="post-metadata">

**Author:** ![aedsinger](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/aedsinger/32/6_2.png) [@aedsinger](https://forum.hello-robot.com/u/aedsinger)\
**Post date:** [August 4, 2021, 3:17pm UTC](https://forum.hello-robot.com/t/about-stretch-body-interface/273/2 "2021-08-04T15:17:32Z")

</div>

Hi @hehonglu123 . Yes, they do support velocity control. Hopefully it goes without saying but care should be taken when running a joint in velocity control mode to avoid collisions and manage termination conditions well.

MODE\_VEL\_PID and MODE\_VEL\_TRAJ are specific to the steppers. Functionally they are similar (though [MODE\_VEL\_TRAJ utilizes an underlying trajectory generator](https://github.com/hello-robot/stretch_firmware/blob/master/arduino/hello_stepper/HelloController.cpp), allowing you to set acceleration limits.

With the Dynamixels you can use the [enable\_vel](https://github.com/hello-robot/stretch_body/blob/master/body/stretch_body/dynamixel_XL430.py#L424) and [set\_vel](https://github.com/hello-robot/stretch_body/blob/master/body/stretch_body/dynamixel_XL430.py#L486) interface.

The update rate of 15-25Hz is the fastest we can achieve in Python. Note, however, that the actual control of joint velocities is done on the joint microcontrollers.

We have some [ongoing work](https://github.com/hello-robot/stretch_body/blob/feature/waypoint_trajectories_py3/body/stretch_body/trajectory_managers.py#L608) to close a Python control loop around the Dynamixel velocity commands. We’re finding that the actual performance of smooth motion is dependent on the achievable update rates. We are still working on providing more reliable update rates that are not impacted by the user process load.

We’re happy to provide additional guidance if you can tell us more about your application.

---

<div class="post-metadata">

**Author:** ![hehonglu123](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/hehonglu123/32/183_2.png) [@hehonglu123](https://forum.hello-robot.com/u/hehonglu123)\
**Post date:** [August 4, 2021, 3:40pm UTC](https://forum.hello-robot.com/t/about-stretch-body-interface/273/3 "2021-08-04T15:40:13Z")

</div>

Thanks @aedsinger , the information is really helpful. Will stretch robot classes (arm, lift, etc.) at some point later include velocity control helper functions similar to `move_to` and `move_by` in position control?

---

<div class="post-metadata">

**Author:** ![aedsinger](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/aedsinger/32/6_2.png) [@aedsinger](https://forum.hello-robot.com/u/aedsinger)\
**Post date:** [August 4, 2021, 4:09pm UTC](https://forum.hello-robot.com/t/about-stretch-body-interface/273/4 "2021-08-04T16:09:22Z")

</div>

Yes, we will add this to our todo. I created [an issue on Stretch Body](https://github.com/hello-robot/stretch_body/issues/73) for this and we’ll address it soon.

Even without this it is possible to command velocities by, for example:

robot.lift.motor.set\_command(mode=MODE\_VEL\_TRAJ, v\_des=velocity\_target, a\_des=acceleration\_target)

I’d recommend using the MODE\_VEL\_TRAJ controller as it will respect the hardstops of the joint and also create smoother motion.
