Sonar questions.

I have a question with the 3dr quad.  I was out flying a while back and this is something that keeps bothering me.  It was in auto mode.  I have sonar enabled.  When the copter rolls does the sonar think that is is farther from the ground than it really is.  This causing to lose some altitude and then it try to recover but then it is to late.  Were on the log can I find what the sonar is doing.

I was just wondering if this is kinda a problem.  Because when you roll the copter it would seem to think that the copter is higher than it needs to be.  In this case would the sonar need to be always pointing down?

Also I have a video and logs files on another discussion.

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

Join diydrones

Email me when people reply –


  • Developer


    It depends on the sonar model. The recommended sonar has a very wide field of view, but if you are using a narrow one you can enable sonar angle correction. It's computationally expensive and not needed most of the time so it's disabled by default and a compile time option. 


    angle_boost is the variable used to add thrust to your radio input to keep the copter up in the air. It uses a cos(roll_angle) calculation to add throttle. This approach however is slightly flawed and will always loose a little altitude. The alt hold PID will make up the difference. I have a new approach I'm working on that is better and calcs the optimum throttle based on angle, but it's a version or two off. 


  • When I was watching it started to level out and you could here it ramp up.  but it was in such a roll that it hit the ground and rolled like a basketball on the court.  It bounced and rolled. Not breaking anything.  Its been awhile and everyday I sit here and think why it dipped so bad on both ocasions.  Now the first time was my fault because i switched back to stable when i freaked out, and ended up crashing.  But the second time I didn't switch I wanted to see what would happen.  I just sit back and wonder why its dipping so bad.  There is the other video and it takes a dive in auto.  That's the video where you see the building it is headed for.  Right when i switched back to simple mode is when I hit a power line.

  • The sonar has a limit of about 8m. If you are near this or indeed roll far enough, that 8m limit would be broken and there would not be a return (both from distance and the fact that there might be nothing reflected back). I assume it would then switch over to baro which, depending on the version of AMP, might be quite different. 

    I would assume (yes, lots of that) that the APM would take into account what the height is based on roll, assuming of course, it has a valid return signal. See the Optical flow description for pictures of what I am babbling about:

    Having a look at your graphs (I'm no expert, just surmising) it looks like you're at the edge of what the sonar can do.  If you disable the sonar, can you still (within reason)  Atl-hold. 

  • Bradley.

    I dont have a sonar, but logically, even when the sonar is pointing downwards, it does get certain reflections upto a articular angle in all directions, as all radiations have a polar diagram of returns, which it processes and takes the least time return signals.... so upto a certain amount of roll, should not be a big problem, but beyond a certain roll angle, yes, an error will occur. what is that roll angle limit, i guess the DIY guys will have to tell us..... cause i am also planning to put a sonar soon....

This reply was deleted.