Arducopter's Sonar-based Altitude hold works great

3689390365?profile=original

I have installed the recommended sonar sensor (XL-Maxsonar EZ4) on my custom-framed Arducopter. Using the ArudPirateNG code, I've been flying with the Altitude hold and it works great. I love it! It allows me to put the quad at the altitude I want, say five feet off the ground, flip the Altitude hold switch on my Tx, and then fly around at will at that altitude. This allows me to practice my yawing, pitching, and rolling without having to worry about crashing into the ground. (Still have to watch out for trees and buildings!). It's very cool. Thank you to the team!

 

I'm really looking forward to automatic take off and landing in the future, and also obstacle avoidance (using yet to be installed side-firing sensors obviously). I have included some pictures of how I mounted the sonar sensor underneath my quad. I have also included some pictures of the tiny EyeCam camera (made by DraganFly Innovations) that I installed on my arducopter. It transmits video in real-time back to a 9" portable screen and a small video receiver that I rigged up with a battery.


3689390421?profile=original

 

 


3689390390?profile=original

 

 

 

 

 

 

 

 

 

 

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • OK, well it looks like I can stop it climbing like a homesick angel by reducing the PID's. Problem is that it is next to useless at actually holding altitude. Ho hum..  Unless anyone has a brainwave I think I will give up on the sonar for the time being. Thanks anyway for trying so hard Randy and for your help too Robert.
  • OK. Thanks. I understand. I am trying working with the PID's again. With some success. I have reduced Sonar PID down to 0.040;0.010;0.015 and it has stopped going straight up when I engage hold. It is also responding to up and down commands on the throttle. However, the altitude is drifting a lot and its response to up and down is very, very slow. It is the best it has been, so I will keep working at this to see if I can find the sweet spot.
  • Developer

    @Andrew - I think you shoudl try engaging the sonar at about 1~2 meters over a hard surface and see how it works.

     

    Your comment about the throttle slowly increasing when you're looking at the configurator and engage the autopilot could be totally fine because:

          -  I suspect when you're doing this, you have the quad very close to the ground so sonar is returning somewhere around 20cm

          - the altitude hold will set the target altitude to be max(60cm, current altitude)...so the target altitude will be 60cm.

          - The PID controller will see the current altitude is below the target so it's I term will cause the throttle to slowly increase as you describe.

        During all this, if you actually lifted the quad above 60cm you'd likely see the throttle slowly come back down.

  • I have been engaging alt hold at between 1 metre and around 8 metres max. 

    Randy, not sure I understand your comment about the behaviour being fine. Do you mean the increase I see in throttle output? 

  • @Randy: OK. That makes sense. Thanks for following-up.
  • Developer

    @Andrew...at what altitude are you trying to engage the sonar?  You know it only works at very low altitude right?  So you should get your quad off the ground..roughly level at about 1 or 2 meters off the ground, then engage the autopilot.

     

    Now that I read your note above about testing with the configurator - that behaviour could be totally fine.

  • Developer

    @Robert,

        I think i saw that post and I thought I responded...but perhaps not.  For the XL, the raw value returned for the sensor is actually the same as the distance (in cm).  for the LV, the raw value is inverted so there's a more complex formula.

         the above values from Andrew look a-ok.

    -Randy

  • Notice that the distance and the raw values are the same, which seems wrong. I saw the same thing on mine. I expected the distance value to be the calculated distance in centimeters (using the voltage/distance ratio of the sonar), but that's not happening for some reason. I posted a forum question about it a while back, but no one responded to it, so I let it go. My quad has been flying/working fine with the sonar, so I assume this particular example sketch just isn't calculating the distance correctly. Or perhaps I'm misinterpreting what "dist" is supposed to mean and do.

  • I agree. There has to be something odd going on here. I ran the AP_Rangefinder_test.pde again and iave clipped the results below. The quad was around a metre from a hard surface floor. I then put my hand underneath and then took it away again, Output looks OK to me.


    dist:106 raw:106
    dist:106 raw:106
    dist:106 raw:106
    dist:101 raw:101
    dist:77 raw:77
    dist:76 raw:76
    dist:76 raw:76
    dist:76 raw:76
    dist:88 raw:88
    dist:105 raw:105
    dist:106 raw:106
    dist:106 raw:106
    dist:104 raw:104
    dist:66 raw:66
    dist:59 raw:59
    dist:58 raw:58
    dist:58 raw:58
    dist:65 raw:65
    dist:102 raw:102
    dist:105 raw:105
    dist:105 raw:105
    dist:105 raw:105
    dist:106 raw:106
    dist:106 raw:106
    dist:106 raw:106
    dist:106 raw:106
    dist:106 raw:106
    dist:106 raw:106
    dist:106 raw:106
    dist:105 raw:105

    Andrew
  • Developer

    The thing that doesn't add up is that you've already tested the sensor with the example sketch and apparently it was producing proper values (i.e. the real distance displayed in cm).  The example sketch and the arduCopterNG code both use the same library code so it just doesn't make sense that the arduCopterNG code wouldn't work.

     

    May you could try the example sketch again and try posting the output.  It would be good to see it with values when your hand is close-ish and then with it pointed off into space.

     

This reply was deleted.