Controlling position by setpoints with companion computer (ROS) (Precision Landing)

Hello everyone,

My goal is to land the drone very precisely and it successfully lands in the Gazebo simulation. My approach is:

  1. Detecting visual targets, their distances and orientations,
  2. Reading acceleration from /mavros/imu/data for my landing code’s Kalman Filter, (ATTITUDE)
  3. Reading odometry message through /mavros/local_position/odom, (LOCAL_POSITION_NED)
  4. Sending relative position targets according to odometry, through mavros/setpoint_position/local

My problem is, I need to send setpoints at 50Hz or 100Hz otherwise, in slower setup like 10Hz, ArduPilot tries to run away from the point that I sent. I see this behaviour in simulation. On the real copter side, It’s even more unpredictable. I’ve tried to send at 200Hz and it aggressively controlled the drone under a breeze wind (16 kts), then landed on the target once. But since it was a bit overkill, I didn’t try again.

Since the odometry is perfect in the simulation, I tried to send a single absolute waypoint like “go 1 meter in x”, before reaching to the point, it didn’t slowdown and passed the point a bit, then fixed its position. On the real copter side, I don’t know ArduPilot parameters well, I observed that it holds its position good after auto tuning and I don’t want to hurt its parameters :slight_smile:

I switched my drone to ArduPilot because PX4 was very bad at position control, mission waypoint style, landing / landing detector etc. -for my drone. Even before auto tuning, Ardupilot was flying very well on the first flight. The weird thing is, I can land PX4, landed more than hundreds of times by sending position commands. The difference of the setpoint styles is, PX4 expects setpoint commands continuously, in order to reach to the point, it stops when I stop sending. Ardupilot takes just one setpoint and doesn’t stop till it reaches to the point.

What approach would you guys suggest for this? I know Ardupilot has a builtin precision landing support but I’m trying to achieve more precision (Previously achieved with PX4). Basically, my code tries to make it hover above the target, then sends land command inside my thresholds.

Hi @cosmicog Not trying to dissuade you from coming up with new cool ideas, but on the other hand why re-invent the wheel? Ardupilot has PrecLand which can work well if carefully setup - you can achieve precision to within a few cm. What level of precision are you after?

1 Like

So true… My code is a bit old actually, written when the PX4 hasn’t got a precland mode.

Few weeks ago, I also added an option to send LANDING_TARGET messages, instead of trying to control the drone from the companion computer, for comparing both options and their precisions at the field. I observed very weird behavior in Gazebo simulation; it landed 1 meters away from the target and, lowered its altitude while drawing circles on top of the target. Then I decided to first try the one that’s made the drone land lots of times before.

Have you ever observed the PrecLand in windy conditions?

I will work on tuning parameters that affect PrecLand, more than trying my old methods. Thank you!

@fnoop
After auto tuning, it landed successfully in the Gazebo Simulation, I think, still, needs more tuning for more precision in order to get the precision that I achieved previously, but PrecLand lands the drone 3x faster than my code.

@khancyr
Just as a feedback, Previously I fixed an oscillation (also position hold) problem by making AHRS_EKF_TYPE = 10, I’ve seen that making it 10 for the sitl is suggested in the ArduPilot Gitter.

After resetting parameters for switching from Copter-3.6.5 to Copter-3.6.6, I decided to try autotuning in simulation. With the new PIDs, and other parameters, I was able to use the PrecLand when EKF2 was enabled.

I don’t know if it’s documented/tested/suggested by you or not, yet, but the auto tuning makes lots of problems go away in the Gazebo Simulation.

@cosmicog Great! The biggest problem with precland is latency between capturing the image, processing the pose/target angles and getting that data to the flight controller, but if you’re able to do 50-100hz+ then it’s not really a problem. You might find some interesting info here:

(ps - it’s not very obvious but in the github readme you can click on the pictures for videos of the precision landing, which will show you the sort of accuracy that can be achieved)

@fnoop Thanks a lot for the links. Your comment really helped me realizing what can I do. I’ll improve raw input with Kalman Filter to send data faster than detection(my code’s setpoint control part was doing it already), and will be using simpler ways for getting the visual detection data faster (for example instead of higher image resolution, I’ll print a very big tag for handling much higher altitudes).

I saw your repo/videos weeks ago, it’s really great. If I wouldn’t have a landing code from past (that I can play with it easily), I’d start by forking it. And also watched videos after clicking accidentally, I even saw the little puppy barking :slight_smile:

If you check my gazebo repo, I have update the .world to have better gazebo performance, it help a lot, but I agree that having autotune and calibration from within gazebo improves the behavior. I just need to find some time to do it.

@khancyr Currently, I am working with an overkill gaming desktop setup. But (for the same reason, free time) when I’ll need to run the simulation on a normal laptop, I will rebase my fork with those changes. Thanks!

BTW I really liked the ArduPilot Gazebo plugin when I try it for the first time on my laptop, since it utilizes GPU as well. Previously; with the old PX4 plugins, I was having performance issues, they were CPU dependent and my laptop was struggling when I try my CPU dependent ros applications with it.

I might look like that I’m making bad comments about PX4 a lot in the ArduPilot forum :sweat_smile:, it is a great framework but it gave me headaches with unexpected behaviours / performance issues on stable releases. May be it is just for very very professionals, but obviously, not for me.