I am trying to work with a simple launch and land command before moving further to waypoints on an APM2.5+. I attempted the commands last night, however, the vehicle did not behave as desired. When sending the launch command the vehicle first did not launch. After sending a second time, the vehicle launched. When at the desired altitude it began to drift wildly. I tried to regain control with the RC, but none of my commands were received. Afterwards, I attempted to send the land command since the vehicle was not under my control. At this moment, all motors shut off and the vehicle crashed. As soon as the vehicle crashed, the motors started back up and the vehicle began to listen to my commands.
master.mav.mission_count_send(master.target_system, master.target_component, 2)
# Dummy Waypoint
master.mav.mission_item_send(master.target_system, master.target_component,
0, 0, mavutil.mavlink.MAV_CMD_NAV_TAKEOFF,
0, 0, 0,
0, 0, 0,
0, 0, 0)
# Launch Waypoint
master.mav.mission_item_send(master.target_system, master.target_component,
1, # Waypoint Number
0, mavutil.mavlink.MAV_CMD_NAV_TAKEOFF,
1, # Is Current Waypoint
0, # Should Autocontinue to next wp
0, # NAV Command: Radius for accept within range (meters)
0, # NAV Command: Hold Time (ms)
0, # LOITER Command: Orbit to circle (meters). Positive clockwise, Negative counter-clockwise
270, # NAV/LOITER Command: Yaw Orientation [o to 360 degrees]
0, # local: x position, global: latitude
0, # local: y position, global: longitude
10) # local: z position, global: altitude (meters)
# Set Launch Waypoint as Current Waypoint
set_current_waypoint()
receive_waypoint(1)
# Trigger auto mode for launch command
master.mav.set_mode_send(master.target_system, mavutil.mavlink.MAV_MODE_FLAG_CUSTOM_MODE_ENABLED, AUTO)
rospy.sleep(0.1)
master.mav.set_mode_send(master.target_system, mavutil.mavlink.MAV_MODE_FLAG_CUSTOM_MODE_ENABLED, AUTO)
# Land Command
master.mav.command_long_send(master.target_system, master.target_component,
mavutil.mavlink.MAV_CMD_NAV_LAND, 0, 0,
0, 0, 0,
0, 0, 0)
Thanks for the help.