Hi guys, greetings from India! :)
Ever since I saw this I wanted to make one but it is pretty difficult so I made one on my own and I wanted it to share it with you guys :) ; I know that it is ArduIMU Quadcopter which is the older version of APM but I’m unable to run it on my APM 2.5. but still according to me APM is pretty expensive for students like me.
Today I’m going to show you how to make your quadcopter to avoid obstacles in indoor flights and a step closer to automating it.
Updates :
Update 1: you can find the code here
Tested By Lee
Here are the things you need:
- Sharp IR Sensor or a Cheap Ultrasonic sensor x4
- An Arduino
- Jumper cables
- An extra channel in your transmitter to switch Modes.
(Note: Ultrasonic sensor will slow down the reaction time of the system due to latency between transmitting and receiving ultrasonic waves.)
Here’s how it works:
Okay stay with me this a really simple concept :) . The IR sensor measures the distance between the sensor itself and the object and sends it to the arduino in the form of analog signal (value range: 0 to 1023). We should make a setpoint say 40cm from the IR sensor so if the setpoint reaches below 40cm the PID algorithm in the arduino will start its work by sending out the correction value to the stabilization board.
Most of you know what PPM signal is and how it is used in our RC universe and this is how it is used in our little project.
Okay so the normal range is 1000us to 2000us and 1500 us is the center or neutral value for roll pitch and yaw. We are going to use only range from 1200us to 1800us since we don’t want to flip the quad if the quad is a bit closer to the wall. You will be having the having the full control of the throttle stick and the rudder stick.
We are going to manipulate the inputs of stabilization board using arduino.
Here’s the connection diagram:
Now that you have wired it all up we can upload the sketch to the arduino and tune it.
Get the sketch From HERE
I will also be posting the video of my quadcopter soon
Check it before the first flight:
Go to the Receiver test menu and check for the value when you put your hand in front of the sensor if everything goes according to plan then you are ready to fly :)
Using HC-SR04 Sonar for altitude hold and obstacle avoidance:(obsolete)
Here’s the connection diagram:
Sensor Layout :
The Sonar5 is attached anywhere under your quadcopter facing downwards .
Very Important: The Altitude hold is still work in progress and it has to be tuned before flight hence it has been commented out . The main obstacle avoidance PID loop has to be tuned so please use it under your own risk.
Usage: Please make sure the quadcopter is on the floor and increase the throttle to a minimum position where it cannot create any thrust . Now try to place any object near the sensor and check if the Quadcopter is trying to move away from the obstacle if it doesnt then reverse the channel in your kk board or edit the sketch
if the pitch has to be reversed in obstacle avoidance mode then change the sign befor Output1 to "-" and Output2 to "+"
same is applicable for roll change the signs before Output3 and Output4
a single line should not contain two plus or two minus
Sorry for the crappy HOW-TO this is my first time writing a one.
Some other projects of mine which are undergoing testing before release:
- Automatic take-off and landing for RC planes and multirotors
- Convert your old transmitter to connect with any module
- Altitude Hold using SR-04 Sonar for Multirotors
Thanks for reading till this :) please comment and tell me your views on this topic if you have any ideas you can share it here. I would like to thank flitetest without them I would be sitting home thinking that RC flying is difficult. Thanks a lot.
Log In to reply
Log In to reply
Log In to reply
Log In to reply
Log In to reply
I am glade to know that you have done a brilliant job. i am also working in such project in my bachelor thesis. the function which i have to do is object avoidance and auto land.
i have APM 2.6 flight controller board and Arduino Mega with HC-sr04 Ultrasonic sensors. if you kindly help me, how to connect arduino board with APM 2.6 and how to do object avoidance with sensors?
i have seen your design but it is not clear to me if you kindly make little bit more clear to that i should understand, and i have downloaded the PID_v1 library from the mentioned link but the examples are not working. it mentions error compiling...
Log In to reply
I am subscribed...
Log In to reply
Log In to reply
Log In to reply
Log In to reply
My tri sometimes behaves as a tree magnet :-)
Log In to reply
Log In to reply
Log In to reply
Log In to reply
Would it be possible that he should put a file with the arduino directory you use to cut and paste?
Thanks for your time and work
Log In to reply
get the PID library and the NewPing library paste it in your libraries folder . Please Refer arduino Website for the instructions for library installation .All the best :)
Log In to reply
I have updated the program and you can find it here http://www.mediafire.com/view/irm8lk505wa9mqf/PIDObstacleQuadv1.ino
i have also updated the link . please set your aux1 at maximum so the program will start its work
Thanks,
Cyril Anthony
Log In to reply
Thanks! cyril.anthony777 for sharing.
Log In to reply
Log In to reply
congratutations ..is a fantastic ideia ...can i use my crius as FC with arduino pro mini ?
try to acces the links but they where broken ...best regards
Log In to reply
as of now only the Sonar link is working (http://www.mediafire.com/view/nzcb6p8aur7jtqk/PIDObstacleSonarQuad.ino)
but the IR is under hold because my IR sensors are worn out and it is hard to find it here and i manage to find one it s pretty expensive here.
Thanks.
Log In to reply
should i copy this
1.Arduino PID library by Brett
2.Arduino NewPing Library by Tim
to arduino library ,upload with your code and simply connect the sonars ?
best regards
Log In to reply
according to your requirements .
All the best :)
Log In to reply
All the upload process of firmware was done with success but when i go to the terminal monitor i cant see no action ...
Resume:
Downloaded the necessary libraries and copy to the library folders.
then downloaded the Pidobstaclesonar, put it to my arduino folder ..
open arduino upload with success but nothing happens ...apreciate help...
Thanks ,
Bernardino
Log In to reply
could help me?
Not like putting here all the error lines or a picture of the screen, so I could see what happens.
Thanks for your time and expertise
Log In to reply
i have checked the code it is compiling correctly here are few common problems.
1.It doesn't work with ATMEGA8
2.Check all the brackets
3.Check all the semicolons
well thats about it . I suspect that the ending bracket might be missing or just send me a screenshot of the error :)
best regards
Log In to reply
an autonomous system shouldn't be triggered byt the proximity?
maybe i dont understand your code, but i feel the value of range say if range < 40cm, shoudl trigger the correction until range > 40cm... right?
Log In to reply
You are correct about the working of the code.
A newer version of code and MaxSonars gave us pretty impressive results. check it out here https://www.youtube.com/watch?v=-wQjtATUWqI
Log In to reply
i am trying to find the IR sensors sketch and i dont find it in your link...
can you help me with that?
Log In to reply
Greetings
Log In to reply
thanks.
Log In to reply
Log In to reply
Log In to reply
you'll have some idea?
Sorry for my bad English ...
Log In to reply
Log In to reply
Log In to reply
Thanks.
Log In to reply
Log In to reply
Log In to reply
I'm just wondering if the library you are using do factor in the speed of the quad: example... say I'm pushing the quad against a wall (eg. full pitch 1850 pwm), like a car crash test... how fast does it react? Should the sonars ping at least 5/10 meters max distance ( not just 2m) so you can calculate the speed (distance1 - distance 2 in a loop) and determining how much counter-speed it has to apply to the Pitch?
Log In to reply
The code which is given here is fully autonomous beyond the point of flicking the aux switch.You will have no control over the quadcopter until you flick the switch back .
The responsiveness of the quadcopter depends on the PID gains mentioned in the code.
we need to calculate the correction even before reaching the setpoint so limiting the ping distance wont make much difference . Instead we can implement adaptive tuning.
The example exhibits semi-autonomous behavior hence the pilot will lose control of the quadcopter for a short period of time.
All the best with the project i will be updating the code soon.
Thanks.
Log In to reply
I think that's the point of the project, to have a smart quad, not a quad that float meaningless in the air right?
In your code i added a calculation of the speed and direction of the quad based on the sonar, so I can get a value that could be good to increase the Output limits of the PID for instance..
Log In to reply
Could you give me your code for the smart quad. This is exactly what I am looking for!
Thank you.
Log In to reply
my cose run the loop anytime, i have no switch, so by doing the test you said by pushing the throttle to 3% than try to move objects in fornt it get unresposnvie..
i feel the reaction of the sensor sis etiher too slow or the reaction is too aggressive...
Log In to reply
Sorry for the late reply HC-SR04 Support has been dropped due to the inconsistent data output now it works only with Maxsonar and Sharp IR sensors. Current code is still under testing.
Log In to reply
Any progress?? could you please share your code?
Log In to reply
It is different from HC-SR04 right ?
It does not have Eco and Trig right ?
So ??
Log In to reply
example: if the quad is far away at least 1m from any wall/objects you can fly with your own sticks. below 1m (or user preferences, or better dynamic value based on quad speed) the auto correction engages and take over the stick until the quad is far from any other object.
Log In to reply
i will be using the 3DR iris+ as my UAV and also i am a complete newbie to UAVs still learning as much as i can. I would be very grateful if you can provide as much help as possible.Thank you.
Log In to reply
NewPing does not name a tipe
Can you help me plz?
Log In to reply
Log In to reply
Log In to reply
Log In to reply
your "HERE" link is broken.
Log In to reply
Git Hub repo :D
Log In to reply
Log In to reply
Is sonar more responsive or IR
Log In to reply
Can I apply this project to an hexacopter ?
Log In to reply
Can u please explain how you wire an APM to the arduino ?
Log In to reply
Log In to reply
Log In to reply
kindly send me final code along with required sensor model and arduino code...
ca131@live.com
thanks
Log In to reply
Log In to reply
Log In to reply
Log In to reply
I'm working on this type of algorithm for my University.
I'm trying to connect my APM 1.6 to the Arduino Mega (It's not the original one, it's the DROFLY V3) and the problem is that I can't find out the pinout scheme. The bigger problem is that i can't understand your connections scheme between the Arduino and the autopilot.
Hope you can help me.
Regards
(sorry for my bad english)
Log In to reply
Log In to reply
Log In to reply
Log In to reply
Also, none of your links are working
Log In to reply
for IR you can see the connection diagram on this page . for sonar follow the link on the end of the article.
Log In to reply
thanks
Log In to reply
Log In to reply
Log In to reply
Log In to reply
Please help me!
This is such a fantastic idea and I am going to build it. But your link to the schematics and code is broken! Please please I'm begging you, please let me have the code and schematic!
thank you so much!
Log In to reply
Log In to reply
There is for loop in the source code like for(i=0; i=10; i++);
Is that right source code? I think that It is right for(i=0; i<10; i++);
And If you have the latest source code, kindly send me arduino code..plz..
misule0423@gmail.com
thank you
Log In to reply
Log In to reply
i am using 'sharp IR sensors'
for the arduino code, do i use link 1 or link 2 ?
link 1- https://github.com/Cyrilanthony777/Obstacle_Avoidance_Multirotor#sthash.Dyxp11kK.dpuf
or
link 2- http://teamrecon.in/collisionavoidance/
because those codes are a little different ..
thanks in advance
Log In to reply
also are the inputs into the arduino, ch1,ch 2 and aux (on the top diagram) inputs from the receiver, and also ch 3,4,aux from the lower diagram
also, where do the ch 3,4 that are arowed as inputs on the kk2 board come in to this.
i believe that the other two wires on the sharp sensor are - + would this be right.
thanks
Log In to reply
sorry for the late reply
mail me if you want further clarification
Thanks.
Log In to reply
I have some question.
How to connect this system to pixhawk which use S-BUS receiver?
Log In to reply
Log In to reply
and Do you have any plan to support I2C sonar or I2C IR system?
Log In to reply
Log In to reply
and I2C IR is not common in market, but I found this ADC-I2C converter for SHARP analog IR.
http://www.bot-thoughts.com/2013/02/avc-2013-sharp-ir-i2c.html
Log In to reply
Log In to reply
Log In to reply
Log In to reply
Log In to reply
can you share the code please..
my email : tibozen@msn.com
best regards
tibo
Log In to reply
Log In to reply
Log In to reply
Log In to reply
Log In to reply
Log In to reply
Log In to reply
Update Collision_avoidance_IR_v2.ino
AND
Update obstr_p_IR.ino
Log In to reply
obstr_p_IR.ino uses arduino Servo library to write PPM signals
Log In to reply
Many thanks for sharing your code. I have managed to get everything functioning, including normal RC control apart from when the obstacle avoidance code is running, but I cannot increase the distance at which the code takes over. It is only about 200mm and far too close to the props. I am using IR sensors. Can you help? You mention the setpoint but no matter how I change this same result. Great idea using the RC receiver!
Log In to reply
And you have used the connection diagram above? Thanks
Log In to reply
can you share the code please..
my email : dasunrco@outlook.com
Log In to reply
Update Collision_avoidance_IR_v2.ino
AND
Update obstr_p_IR.ino
I have sharp GP2Y0A21YK Sensors
I am using APM 2.6 and cannot connect to mission planner using this set up ( replaced KK with APM 2.6)
Log In to reply
Log In to reply
Thanks
Log In to reply
I cannot get my quad to recognize the signal. Please help me!!
Log In to reply
How do I connect this circut to the flight controller?
Thanks
Log In to reply
bombicche@gmail.com.
Many thanks.
Log In to reply
mikeandpamavitts@yahoo.com many thanks
Log In to reply
I am really interrested in the project, but your links to the code doesn’t work any more, is there any way you can send the code trough mail to me please. My mail-adres is vandenberghe1994@hotmail.com
Thank you very much in advance,
Steven.
Log In to reply
Log In to reply
sensors connect to arduino. arduino connect to pixhawk's telemetry.
let them communicate by mavlink protocol
and override manual control for obstacle avoidance.
Log In to reply
Log In to reply
Log In to reply
I read all of the article as well as the comments.. I already download the libraries and codes and compiled through the Arduino IDE and there is no error so far and I must say it is a good work and thank you very much for sharing cyril.anthony777.
But in one comment you were saying HC-SR04 isn't suitable..I didn't quit get that one. So you were saying it is not working ? or ?
Anyway I am using Arduino Uno.
Log In to reply
Log In to reply
However lets say if I go for sharp ir sensors, will there be a difference in action. Also you removed the Arduino sketch. Can you please share it ?
Log In to reply
I am trying to follow the guide and I need to access the source code, but unfortunately the links you provided are not working.
Can I have the source code please.
My email is giorgosflorou@gmail.com .
Log In to reply
Log In to reply
I'm working on a similiar project, but i'm building a blimp with obstacle avoidance. Would you mind sharing me the arduino code that you have developed so that I can make a reference please.
My email: muhd.wasil@hotmail,com
Thanks a lot
Log In to reply
Log In to reply
Can i use APM with Arduino Uno and sharp sensors?
Thx
Karan
Log In to reply
Log In to reply
Based on your wiring connection for IR sensor, I notice that your channel 1 and 2 (Aileron and elevator) goes to digital 2 and 3 of Arduino Uno. But the code as posted in Github Repo doesn't says anything regards to the 2 pins (digital 2 and 3) but only pin 9 and 10. I understand that pin 9 and 10 is to send a certain value of microseconds to the flight controller when the arduino uno detects a preset radiometric value (too close to target) so to avoid an collision. I am rather confused where do the signals go to and end up in when they entered pin 2 and 3. So how am I suppose to control the aileron and elevator controls of the quadcopter during manual mode?
Log In to reply
Log In to reply
can you share the code please
Because I don't have the code.
my email : Vijaysharma579@gmail.com
best regard
Vijay
Log In to reply
Log In to reply
i will be using the 3DR iris+ as my UAV and also i am a complete newbie to UAVs still learning as much as i can. I would be very grateful if you can provide as much help as possible.Thank you.
Log In to reply
I build a drone with an apm board, but I can not put your sonar project in it, do you have a more detailed schematic of the connection? Would you send me? Topografar@gmail.com.
thank you.
Log In to reply
I see so many sketch in this post, could you please give me last code with sonar.
I try contact with you via facebook but not respond.
Regard
Reed Noel
Log In to reply
super project!
I use a DJI Naza M lite flight controller and a Frsky X8R receiver.
Do you think this system with arduino can be wired on instead of the KK card?
thank you in advance and congratulations for the realization.
Log In to reply
I am trying to make Obstacle avoiding quadcopter using IR module, but i did not get the output.
Please help me to find the problem.
( Is it compulsory to use Sharp IR sensor )
Log In to reply
Log In to reply
I'm trying to implement your code on my custom build quad and actually got no background using Arduino.
I interested with IR based and after took look on your github, I got confused because there were 2 files on IR Based (obstr_p_IR.ino and Collision_avoidance_IR_v2.ino).
Tried your code on obstr_p_IR.ino, verifying was success. But I saw more complexity on Collision_avoidance_IR_v2.ino but when I tried to compile, it wasn't success. Error code was found on ServoIn.h which not available.
Could you help me, please?
Log In to reply
Can someone give me the hint?
Log In to reply