# Comments about Collision Avoidance

**URL:** <https://forum.hello-robot.com/t/comments-about-collision-avoidance/278>\
**Category:** Ask\
**Created:** [August 11, 2021, 12:25am UTC](https://forum.hello-robot.com/t/comments-about-collision-avoidance/278 "2021-08-11T00:25:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lionel\_Zhang](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/lionel_zhang/32/181_2.png) [@Lionel\_Zhang](https://forum.hello-robot.com/u/Lionel_Zhang)\
**Post date:** [August 11, 2021, 12:25am UTC](https://forum.hello-robot.com/t/comments-about-collision-avoidance/278/1 "2021-08-11T00:25:00Z")

</div>

Hello!

Thank you very much for the detailed [collision avoidance tutorial](https://github.com/hello-robot/stretch_body/blob/15c93620da897b5f889c90d6a4832a0e4c7a7437/docs/collision_avoidance_tutorial.md), it has been very helpful for getting started. For some context, I’ve made a hand+table collision model that looks at whether the pinky or thumb might collide with the table. When the hand is open in a palm down pose, we would set a slightly higher lift\_lower\_limit compared to when the hand is supinated 90 deg (karate chop). This is because the hand makes a C-shape in an open pose (thumb points away from the palm).

Some problems I ran into:

- The RobotCollisionManager does not allow setting joint limits that are less conservative than the current soft\_motion\_limits of that joint. This was problematic for our application because we would want to set a less conservative lift\_lower\_limit when the hand was in a karate chop pose compared to palm down pose.
- The enable/disable\_model methods did not seem to be working as intended. The models\_enabled flags seem to only be used on startup but are not checked in step().

Minor issues:

- Would it be possible to add an option for [set\_soft\_motion\_limits()](https://github.com/hello-robot/stretch_body/blob/master/body/stretch_body/lift.py) to not modify one or both limits? Currently, it feels a bit unintuitive to use:  
`self.collision_manager.robot.lift.soft_motion_limits[0]`  
(or maybe just add a line in the collision avoidance tutorial for future users).
- Renaming class [RobotCollision](https://github.com/hello-robot/stretch_body/blob/master/body/stretch_body/robot_collision.py) to RobotCollisionManager like it is described in the comments for clarity.

Thanks for your help!  
Lionel

---

<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 11, 2021, 2:09pm UTC](https://forum.hello-robot.com/t/comments-about-collision-avoidance/278/2 "2021-08-11T14:09:19Z")

</div>

Great to hear the tutorial was valuable, and thank you for the detailed feedback. We will integrate your feedback into the next release of Stretch Body.

---

<div class="post-metadata">

**Author:** ![Lionel\_Zhang](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/lionel_zhang/32/181_2.png) [@Lionel\_Zhang](https://forum.hello-robot.com/u/Lionel_Zhang)\
**Post date:** [August 11, 2021, 5:54pm UTC](https://forum.hello-robot.com/t/comments-about-collision-avoidance/278/3 "2021-08-11T17:54:41Z")

</div>

Thank you, Dr. Edsinger!

---

<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 26, 2021, 11:54pm UTC](https://forum.hello-robot.com/t/comments-about-collision-avoidance/278/4 "2021-08-26T23:54:44Z")

</div>

An update! We’ve just released Stretch Body v0.1.6 that integrates your feedback on the collision avoidance functionality (along with various bug-fixes). These updates can be installed

```auto
>>$ pip2 install hello-robot-stretch-body -U --no-cache-dir
>>$ pip2 install hello-robot-stretch-body-tools -U --no-cache-dir
>>$ pip2 install hello-robot-stretch-factory -U --no-cache-dir
>>$ pip2 install hello-robot-stretch-tool-share -U --no-cache-dir

```

Unfortunately we had to change the API a bit. Previously you might call:

```auto
lift.set_soft_motion_limit(min_val,max_val). 

```

Now we support setting individual limits by:

```auto
lift.set_soft_motion_limit_min(min_val)
lift.set_soft_motion_limit_max(max_val)

```

Stretch Body also now distinguishes between Collision limits and User limits. In this way the two constraints can co-exist without overwriting each other. The most conservative joint range between the two is applied). This is further explained in the code [here](https://github.com/hello-robot/stretch_body/blob/master/body/stretch_body/lift.py#L58).

Thanks for the feedback and let us know if there are any questions!

---

<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 26, 2021, 11:58pm UTC](https://forum.hello-robot.com/t/comments-about-collision-avoidance/278/5 "2021-08-26T23:58:30Z")

</div>

I should also highlight for other users that the collision avoidance functionality is considered ‘experimental’ and is turned off by default. To turn it on, add to your user YAML:

```auto
robot:
  use_collision_manager: 1

```

Stretch Body includes two collision avoidance models (found [here](https://github.com/hello-robot/stretch_body/blob/master/body/stretch_body/robot_collision_models.py)). One (mostly) avoids collisions between the arm and the camera. The other (mostly) avoids collisions between the gripper and the base.

---

<div class="post-metadata">

**Author:** ![Lionel\_Zhang](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/lionel_zhang/32/181_2.png) [@Lionel\_Zhang](https://forum.hello-robot.com/u/Lionel_Zhang)\
**Post date:** [August 27, 2021, 5:30pm UTC](https://forum.hello-robot.com/t/comments-about-collision-avoidance/278/6 "2021-08-27T17:30:46Z")

</div>

Thank you! We will test this out next week.
