I will post here the process for building and setting up a simple and inexpensive obstacle stop system. The base concept is to put a "sensing " box between the RC receiver and the flight control board of the flying machine, so no mods on the arducopter firmware are required. The sensing box will act as an override on the pilot controls whenever an obstacle comes within the rangefinders predetermined “distance_threshold” (see the meaning of this parameter in the attached GitHub firmware), preventing the multicopter from moving any further toward the obstacle.
The rangefinders are 4, two on the longitudinal axis( so acting on pitch) and two on the trasversal axis (acting on roll).
Since the sensors range is poor, the flying speed which guarantees a safe behavior of the system is low, so it works best in those cases where a precise hover or low translational speeds are involved (for example close inspections outdoor/indoor in those cases where a “safe” distance must be kept from the target).
The system has been tested and works positively for the following flight modes:
Loiter ( should work flawlessly for PosHold too, but I do not believe this flight mode is a real need if you have tuned your Loiter parameters to perfectly suit your flying needs);
DO NOT use it if your simple/supersimple boxes are checked for the related flight mode.
Here is what you need to build it:
- teensy 3.2;
- 4 rangefinders ( I have used MB1240);
- a ppm encoder;
- Teensyduino compiling tool;
- a flying multicopter, already tuned at its best;
Connect the sensors analog output to the specified teensy pins (see firmware) and double check it, if anybody wants to use the PW output from the sensor just change the code accordingly.
Starting from the receiver connect the aileron, elevator and mode_in (for example i used channel 6 on my radio–this is needed to activate/deactivate the system) channel number to the pin on teensy specified in the firmware, then connect the output from the teensy to the respective channel input of the PPM encoder. The remaining channels from the receiver have to be connected directly to the PPM Encoder. I know it will be a little mess of wires…but I’m working to use SBUS thorugh the whole thing, just need time to study properly. Remember that teensy is powered by 5 volts and all grounds have to be common for receiver, sensors and ppm encoder.
Download and compile/upload the following firmware to your teensy: https://github.com/Ferruccio1984/Obstacle_Stop_v1/blob/master/Obstacle_Stop_v1.cpp
If you haven’t installed the PID libraries for Arduino just go on the Arduino webpage and follow instructions on how to get it. Once you have installed the library you need to change the maximum output (default is 255, so you have to increase it in the PID_v1.cpp ).
I have put inside the code a “smoothing” process for the readings coming from the sensors, and it’s basically the same found in “smoothing” of Arduino webpage, so credits go to David A. Mellis.
Once you have compiled and assembled the whole thing, connect the FC to MissionPlanner and check if it is working properly by following these steps:
2)put an obstacle on the left side of your copter:
- in MP you should see the roll axis moving as per the following picture:
4)put an obstacle on the front side of your copter:
- in MP you should see the pitch axis moving as per the following picture:
NOTE: I haven’t included any predetermined PID or Distance values in my firmware, since they are related to the specific machine/autopilot PID setup, so you can determine yours by iterative trials.
Here is a little video showing how it works in practicehttps://www.youtube.com/watch?v=QRxb-W8P4YY
Please feel free to ask or comment/suggest improvements.