# Obstacle avoidance

**URL:** <https://discuss.cubepilot.org/t/obstacle-avoidance/8741>\
**Category:** Cube Autopilot\
**Created:** [13 April 2022 09:46 UTC](https://discuss.cubepilot.org/t/obstacle-avoidance/8741 "2022-04-13T09:46:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chandrahas](https://discuss.cubepilot.org/user_avatar/discuss.cubepilot.org/chandrahas/32/1865_2.png) [@chandrahas](https://discuss.cubepilot.org/u/chandrahas)\
**Post date:** [13 April 2022 09:46 UTC](https://discuss.cubepilot.org/t/obstacle-avoidance/8741/1 "2022-04-13T09:46:33Z")

</div>

@Michael_Oborne @Avi_Aero

- I want to fly a drone Loiter or in auto mode.
- I am using TF mini plus for range finding in the direction of forward-facing.
- I want to just stop and hover my drone when an obstacle arises in the path of drone in Loiter or Auto mode.
- How to do it?

---

<div class="post-metadata">

**Author:** ![BrunoB](https://discuss.cubepilot.org/user_avatar/discuss.cubepilot.org/brunob/32/5401_2.png) [@BrunoB](https://discuss.cubepilot.org/u/BrunoB)\
**Post date:** [13 April 2022 10:33 UTC](https://discuss.cubepilot.org/t/obstacle-avoidance/8741/2 "2022-04-13T10:33:40Z")

</div>

Hello @chandrahas

In Loiter Mode, it should be pretty straight-forward to do that, after properly configuring your rangefinder parameters (RNGFNDX\_ Family) and proximity parameters (PRX\_ Family), you should setup your AVOID\_ parameters, with AVOID\_BEHAVE = 1.  
In Auto Mode, today is not possible to only stop the drone at obstacle with Ardupilot. The thing you can try is to enable path planning by means of OA\_ parameters family. This path planning will use some path planner algorithms in order to avoid the obstacle and continue following the next waypoint.

---

<div class="post-metadata">

**Author:** ![chandrahas](https://discuss.cubepilot.org/user_avatar/discuss.cubepilot.org/chandrahas/32/1865_2.png) [@chandrahas](https://discuss.cubepilot.org/u/chandrahas)\
**Post date:** [14 April 2022 01:06 UTC](https://discuss.cubepilot.org/t/obstacle-avoidance/8741/3 "2022-04-14T01:06:04Z")

</div>

@BrunoB **I have set these parameters for TF mini plus but now working .**

| RNGFND\_ADDR | 0 | | |
| --- | --- | --- | --- |
| RNGFND\_FUNCTION | 0 | | |
| RNGFND\_GAIN | 0.8 | | |
| RNGFND\_GNDCLEAR | 10 | | |
| RNGFND\_MAX\_CM | 600 | | |
| RNGFND\_MIN\_CM | 30 | | |
| RNGFND\_OFFSET | 0 | | |
| RNGFND\_ORIENT | 25 | | |
| RNGFND\_PIN | -1 | | |
| RNGFND\_POS\_X | 0 | | |
| RNGFND\_POS\_Y | 0 | | |
| RNGFND\_POS\_Z | 0 | | |
| RNGFND\_PWRRNG | 0 | | |
| RNGFND\_RMETRIC | 1 | | |
| RNGFND\_SCALING | 3 | | |
| RNGFND\_SETTLE | 0 | | |
| RNGFND\_STOP\_PIN | -1 | | |
| RNGFND\_TYPE | 20 | | |

**for (PRX\_Family)**

| PRX\_IGN\_ANG1 | 0 | deg | 0 360 |
| --- | --- | --- | --- |
| PRX\_IGN\_ANG2 | 0 | deg | 0 360 |
| PRX\_IGN\_ANG3 | 0 | deg | 0 360 |
| PRX\_IGN\_ANG4 | 0 | deg | 0 360 |
| PRX\_IGN\_ANG5 | 0 | deg | 0 360 |
| PRX\_IGN\_ANG6 | 0 | deg | 0 360 |
| PRX\_IGN\_WID1 | 0 | deg | 0 127 |
| PRX\_IGN\_WID2 | 0 | deg | 0 127 |
| PRX\_IGN\_WID3 | 0 | deg | 0 127 |
| PRX\_IGN\_WID4 | 0 | deg | 0 127 |
| PRX\_IGN\_WID5 | 0 | deg | 0 127 |
| PRX\_IGN\_WID6 | 0 | deg | 0 127 |
| PRX\_ORIENT | 0 | | 0:Default 1:Upside Down |
| PRX\_TYPE | 4 | | 0:None 7:LightwareSF40c 1:LightWareSF40C-legacy 2:MAVLink 3:TeraRangerTower 4:RangeFinder 5:RPLidarA2 6:TeraRangerTowerEvo 8:LightwareSF45B 10:SITL 12:AirSimSITL 13:CygbotD1 |
| PRX\_YAW\_CORR | 22 | deg | -180 180 |

---

<div class="post-metadata">

**Author:** ![BrunoB](https://discuss.cubepilot.org/user_avatar/discuss.cubepilot.org/brunob/32/5401_2.png) [@BrunoB](https://discuss.cubepilot.org/u/BrunoB)\
**Post date:** [15 April 2022 00:41 UTC](https://discuss.cubepilot.org/t/obstacle-avoidance/8741/4 "2022-04-15T00:41:31Z")

</div>

Try changing RNGFND1\_ORIENT to 0 (forward) instead of down. Down is for terrain following only.  
And have you properly configured your serial parameters?

---

<div class="post-metadata">

**Author:** ![chandrahas](https://discuss.cubepilot.org/user_avatar/discuss.cubepilot.org/chandrahas/32/1865_2.png) [@chandrahas](https://discuss.cubepilot.org/u/chandrahas)\
**Post date:** [15 April 2022 01:05 UTC](https://discuss.cubepilot.org/t/obstacle-avoidance/8741/5 "2022-04-15T01:05:34Z")

</div>

@BrunoB  
If I set RNGFND1\_ORIENT=0,TF mini stop working,No reading comes in status panel

---

<div class="post-metadata">

**Author:** ![BrunoB](https://discuss.cubepilot.org/user_avatar/discuss.cubepilot.org/brunob/32/5401_2.png) [@BrunoB](https://discuss.cubepilot.org/u/BrunoB)\
**Post date:** [15 April 2022 01:22 UTC](https://discuss.cubepilot.org/t/obstacle-avoidance/8741/6 "2022-04-15T01:22:07Z")

</div>

Are you checking the sensor data by means of sonar range or sonar voltage on the status screen right? On mission planner, press ctrl + F and look for the proximity UI on the advanced menu. With orientation 0 you should be able to see the Readings there. Sonar range / sonar voltage displays to you only downfacing lidars If I am not wrong
