ArduCopter NG with ultrasonic sensor for low-level altitude hold

 

GPS altitude hold is good for +-5m, but what if you want more precision than that, closer to the ground. ArduCopter team member Randy Mackay. He explains what it takes (this is also in the manual):

 

    To give it a go do this:
        1. get yourself one of these Sonars and attach to the bottom of your quad
            http://www.sparkfun.com/products/8504  <-- the cheaper LV ($28)
            http://www.sparkfun.com/products/9495  <-- the slightly more XL ($50)
        2. attach it up to AN1 (the Analog2Digital port on the very back
right of the oilpan near the CLI switch.  AN5 is the outmost, so count
in from there to AN1).
        3. comment out this line in ArduCopterNG.pde:
                //#define UseBMP
        4. make sure this isn't commented out just below in ArduCopterNG.pde
                #define isRANGEFINDER
        5. if you're using the LV sonar you will need to change this line in ArduCopterNG.pde:
                 AP_RangeFinder_MaxsonarXL  AP_RangeFinder_down;
            to be like this:
                 AP_RangeFinder_MaxsonarLV  AP_RangeFinder_down;
        6. you'll need to reset your EEPROM values or go into the CLI menu and select 'o' and set your Sonar PIDs to 0.8;0.3;0.7
 
     I had to make one change though that affects the existing functionality
... if you're UseBMP (i.e. using baro for altitude hold) it's now
possible to do altitude hold even though you're not doing GPS hold (I.e.
if you don't have a GPS lock).  I think this is ok.
 
     So the Barometer altitude control and sonar altitude control continue
to be quite separate functionality that can't be used at the same time. 
Clearly we need a nice transition from one to the other when you go out
of sonar range.  anyway still, thinking about how to do that.

We may be moving the sonar input port to the Pitot port on the IMU board. Note that the ArduPirates  are now handling all public releases of the ArduCopter NG code, they'll be implementing this in their own way. There's already a version of that in their code here.

Views: 3136

Comment by Taylor Cox on December 26, 2010 at 1:35pm
In your opinion, do you think its worth it to spend the extra money on the more expensive sonar?

Developer
Comment by John Arne Birkeland on December 26, 2010 at 2:22pm
Looking good. I have been thinking about something similar for auto
landing airplanes. My plan is to have a sonic source at the center
pointing down, and sensors at the wingtips and in the tail. Should make
it possible to get an exact reading of ground clearance and angle by
comparing the sensors.

Developer
Comment by Randy on December 26, 2010 at 5:35pm

@Taylor - my opinion is the safe bet is to get the more expensive one.  It's $22 more but you're only buying one (or maybe 2 if you've got a couple of quads).  The video above was shot with the more expensive XL-EZ4.  This opinion isn't based on evidence yet..I have some more sensors arriving shortly so I will test more.

 

Besides whether you go for the LV or XL there is also the question of beamwidth..both series have models from "0" (widest) to "4" (narrowest).  I expect 4 is the best for altitude hold.

 

By the way - the set-up instructions are also on the wiki now: https://code.google.com/p/arducopter/wiki/Quad_Sonar

Comment by Taylor Cox on December 26, 2010 at 6:10pm

@Randy. So when we have the sonar equipped. Is it enabled with a switch or anything like that? Or is it just activated when GPS hold is activated? 

 


Developer
Comment by Randy on December 26, 2010 at 8:34pm

Taylor,

 

     As you guessed, it goes on with the autopilot..so when you turn on GPS hold the altitude hold also goes on.  In the video above I disabled the GPS by commenting out the #define IsGPS in ArduCopterNG.pde.

     https://code.google.com/p/arducopter/source/browse/trunk/Arducopter...

     It would be interesting to do GPS hold at 2 feet off the ground - i suspect just because the gps signal isn't perfectly accurate the quad will wander around a bit.

-Randy

Comment by Taylor Cox on December 26, 2010 at 8:44pm
But I don't have to disable the GPS right? You just did that because you don't want it on for low altitudes? And I had one more question. Once the quad gets above a certain height, does the GPS then take over and control the altitude hold of the quad copter?
Comment by SupreCharger on December 26, 2010 at 11:39pm
Where is the Telemetry manual ? @_@"

3D Robotics
Comment by Chris Anderson on December 26, 2010 at 11:44pm
Telemetry will not be supported until the next rev of the code.

Developer
Comment by Randy on December 27, 2010 at 4:23am

@taylor - you're right - i only disabled the GPS because I wanted to do some free flying with the sonar on.  I'm sure you could do GPS hold at a low altitude and it would be fine.

 

Instead of using GPS for altitude control at higher altitudes, we use the barometer on the APM Oilpan because it's more accurate...and this is the only gotcha, at the moment, there's no transition from using sonar to barometer.  it's one or the other.  That'll be resolved shortly though.  I expect by the end of next weekend it'll will transition nicely from sonar to barometer if you climb over a few meters, and then back from barometer to sonar as you come back down to earth.

Comment by Taylor Cox on December 27, 2010 at 11:44am

Alrighty. Thanks Randy

 

Ok. I think I have it working on AN5 like the wiki says. I have the PID values set to what you said because I have the arducopter kit. Before I set them, the quad would ascend up into the air, and now that I have the settings in, it slowly descends. Which value in the PID for the sonar should I change to get the altitude hold dialed in?

Comment

You need to be a member of DIY Drones to add comments!

Join DIY Drones

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service