Customer & partner stories

Obstacle avoidance for indoor drone flight!

With TeraRanger Tower Evo and TeraRanger Evo sensors
sensor arrays

Recently we evaluated performance of indoor obstacle avoidance on a quacopter with Pixhawk running ArduPilot and equipped with a TeraRanger Tower and TeraRanger Evo distance sensor for drones. This report presents our setup and the results.

Parts used:

DJI 450 Flamewheel frame
DJI E310 propulsion system
Custom 3D printed legs ( are an alternative)
Custom 3D printed holder for TeraRanger Tower
Pixhawk 1
TeraRanger Tower (
TeraRanger Evo with I2C backboard (
4000 mAh 3S battery
FrSKY D4R-II receiver
Taranis X9D transmitter
sensor arrays

Drone object avoidance in Arducopter

In version 3.5, ArduCopter introduced object avoidance in Loiter and AltHold modes. By using TeraRanger Tower you can implement the object avoidance feature on your aircraft.

In both Loiter and AltHold modes the area around the vehicle is divided into 8 sectors, with sector 0 pointing forward by default

When setting up the TeraRanger Tower on the drone it is important to make sure that the sensor labeled on the TeraRanger Hub PCB board as TR0 is the one that is pointing forward.

structured light sensor camera
time-of-flight sensor

TeraRanger Tower setup

When mounting the tower on the drone it is important to take into account the 3 degrees Field of View of the TeraRanger sensors and their emitted light to ensure that the Field of View is not obstructed by the aircraft frame or propellers. For safety, we usually mount the sensors with about 15 degrees clearance (see picture below).

If you are not sure if your propellers are in the Field of View of the sensor you can perform a static test using the TeraRangerHub GUI and manually change propeller positions to see if the readings are affected.
structured light sensor camera

We connected the Tower to Pixhawk following this diagram (make sure you are connected to U3 port on the TeraRanger Hub board):
sensor arrays

To provide power to the board we made a connection between the drone power distribution board and the U1 port on the TeraRanger Hub PCB. With this setup we are using unregulated battery power (10-20 V is the accepted voltage of TeraRanger Hub). Since we are using 3S LiPo batteries the voltage provided to the board is within range (~12.60 V when the battery is fully charged).

TeraRanger Evo – Altimeter setup

In our setup we use a TeraRanger Evo as an altimeter. At the time of writing, the Evo drivers hadn’t made it to the official ArduCopeter 3.5 release, however, they are supported on the development branch (instructions on getting the development version can be found in chapter 3.2 of our connection instructions).

sensor arrays
structured light sensor camera

Obstacle Avoidance in Loiter mode

We originally showed object avoidance in Loiter mode in our video last year:

In Loiter mode, thanks to sensor data filtering and position information from GPS, the autopilot has high-quality information on it’s speed and acceleration with respect to the ground (groundspeed and groundacceleration). By using a sensor array system, such as TeraRanger Tower, the autopilot can get information on how far away it is from obstacles that are in the sensors fields of view. Knowing how fast the multirotor is travelling towards the obstacle, and having precise distance information from said obstacle, allows the autopilot to request a horizontal acceleration in time to stop the drone at a predefined distance from the obstacle. Since this mode is highly dependent on position information (usually obtained from the GPS) it will not work if GPS is not available, but could potentially harness other positioning systems like an optical flow camera, or motion capture system.

Drone obstacle avoidance in Altitude Hold

Things get very interesting with Altitude Hold mode. Since there is no position reference system (e.g. GPS) we don’t have precise information about where our drone is and in which direction it is actually flying.

Imagine flying a multirotor in a mode in which you have full control over thrust and roll and pitch angle. Let’s say that with 50% thrust you can keep your multirotor level at a fixed height, in such a case the generated thrust is in equilibrium with the aircraft weight. As soon as our aircraft has some roll angle, assuming you don’t increase thrust, your aircraft will start descending as the upward component of the thrust vector is not in equilibrium with the aircraft weight. The remaining thrust component will make the drone fly in the direction of roll. This concept is illustrated on the figure below.
laser proximity sensor

By using altitude hold for indoor drone obstacle avoidance ArduCopter developers can ensure that the appropriate thrust is applied by the motor, so when the multirotor is banking or pitching we can be sure that the autopilot will do it’s best to keep the aircraft at the requested height. You can use a barometer for this task, however by using a TeraRanger rangefinder you will see much better performance in holding a fixed height.

As mentioned earlier in this case, the Pixhawk obstacle avoidance does not know how fast the drone is travelling but it can keep the fixed height. The obstacle avoidance has been solved by ArduCopter developers by creating a pitch/roll request based on the distance measurements received from all the sensors. The largest positive and negative roll and pitch angles are found and combined together resulting in a final roll/pitch angle. Those combined roll/pitch values are then fused with the pilot input. Source:

At the time of our tests, the object avoidance library can request a lean angle of 75% of the maximum allowed lean angle (If you were to set ANGLE_MAX to 1000 centidegrees than the maximum transmitter stick input will translate to 10 degrees, while the input from the avoidance library will not be larger than 7.5 degrees). That means that, if you asked for a 75% roll command, thoeretically the aircraft should be level at the minimum distance set from the obstacle. This is not necessarily good! As discussed earlier, since the autopilot has no precise information on aircraft speed, your aircraft might be perfectly level but still have velocity in a horizontal direction! That is why we advise you, if you want to test the obstacle avoidance drone in Altitude Hold, to take it slow and build trust in the system first.

Usually, when AltHold mode is concerned, we advise our customers to set the AVOID_ANGLE_MAX and ANGLE_MAX to relatively low values. AVOID_ANGLE_MAX is the maximum angle that might be requested by the Object Avoidance library and ANGLE_MAX is the maximum lean angle in all flight modes.

Highlight of parameters of Altitude Hold mode

Here is a short highlight of the parameters we set on the Pixhawk that you see in the original video:


You can get our parameter on the link below


TeraRanger Tower and TeraRanger Evo, when combined with Pixhawk running ArduCopter firmware, provide a strong solution for drone object avoidance in GPS-denied environments. The system is easy to set up and integrate. We advise any integrator to start tuning the system by setting small values of AVOID_DIST_MAX and ANGLE_MAX parameters, to get a good feel for the functionality, before making the system more aggressive.


Related products

TeraRanger Tower Evo

Solid-state ToF LiDAR system
Purchase from Reseller
TeraRanger Tower Evo is a solid-state LiDAR system. With zero moving parts, the product offers increased robustness and silent operation, while the compact and lightweight design makes it ideal for fast-moving and lightweight robotic applications, both on the ground and airborne! TeraRanger Tower Evo is compatible with Pixhawk (APM) flight controllers. Choose between 2 versions with varying performance, including 4 or 8 detection zones.

The TeraRanger Tower Evo is no longer available. You can purchase available stock from our Reseller partners using the link below.

Flat Flex Cables

Bundle of 8 Flat Flex Cables
Purchase from Reseller
Customize the distance between Terabee sensor modules used in your project and the central Hub board. A selection of different length flat flex cables provides users with more flexibility to position the sensors where needed and how needed! The cables are as short as 5 centimeters and as long as 1,5 meters. Ready to prototype?

My Cart