I’m currently testing precision landing with Aruco markers in Python. I’m using Gazebo as my simulator as described in https://ardupilot.org/dev/docs/using-gazebo-simulator-with-sitl.html. When landing, I take the copter and hold it above the Aruco marker, so the marker acquisition is not simulated. However, when I switch to LAND mode, the copter just lands normally.
I’m using OpenCV to retrieve the images and detect the markers. The computed distance values are then used in the following function
async def send_land_message_v2(self, x_rad=0, y_rad=0, dist_m=0, x_m=0,y_m=0,z_m=0, time_usec=0, target_num=0, valid=1): msg = self.vehicle.message_factory.landing_target_encode( time_usec, # time target data was processed target_num, # target num mavutil.mavlink.MAV_FRAME_BODY_NED, # frame x_rad, # X-axis angular offset, in radians y_rad, # Y-axis angular offset, in radians dist_m, # distance, in meters 0, # Target x-axis size, in radians 0, # Target y-axis size, in radians x_m, # x float X Position of the landing target on MAV_FRAME y_m, # y float Y Position of the landing target on MAV_FRAME z_m, # z float Z Position of the landing target on MAV_FRAME (1,0,0,0), # q float Quaternion of landing target orientation (w, x, y, z order, zero-rotation is 1, 0, 0, 0) 2, # type of landing target: 2 = Fiducial marker valid, # position_valid boolean ) self.vehicle.send_mavlink(msg) msg = self.vehicle.message_factory.distance_sensor_encode( time_usec, # time target data was processed 0, # min distance in cm 1000, # max distance in cm int(dist_m*100), # current distance 0, # type 0, # onboard id mavutil.mavlink.MAV_SENSOR_ROTATION_PITCH_270, # downward facing orientation 0 # covariance ) self.vehicle.send_mavlink(msg)
The default parameter for ArduCopter at
<ArduPilot-Repo>/Tools/autotest/default_params/gazebo-iris.parm have been extended with the following parameters:
PLND_ENABLE 1 PLND_TYPE 1 RNGFND1_TYPE 1 RNGFND1_MIN_CM 0 RNGFND1_MAX_CM 4000 RNGFND1_PIN 0 RNGFND1_SCALING 1 RNGFND_LANDING 1
The complete code is part of a larger application and can’t easily be taken out, so I cannot provide an SSCCE here, sorry. Of course, f any info is missing, let me know.
Here is a log from a simple simulation that consisted of a takeoff to 3m, followed by 2 seconds hovering and land command.