I am working on setting up code that will allow direct control over certain aspects of the APM during flight. Currently I am testing a simple sequence of commands through MAVLINK, starting with launch and land. The commands are as follows:
[code]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 0, # NAV/LOITER Command: Yaw Orientation [o to 360 degrees] 0, # local: x position, global: latitude 0, # local: y position, global: longitude 20) # 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)[/code]
# Land Command
mavutil.mavlink.MAV_CMD_NAV_LAND, 0, 0,
0, 0, 0,
0, 0, 0)
During a test, I send the launch command. The vehicle ascended, however, it went to a height higher than I sent and once the launch was complete started to randomly wonder (I had a GPS Fix). I attempted to take control with the RC, however, I had no control trying all possible combinations. I then send the land command so the vehicle would at least land safely. As soon as the command was sent, all motors shut off and the vehicle fell to the ground (breaking the vehicle).
Are the methods I am using to send the Launch and Land command acceptable? Are there any ideas as to why this may have happened. Until this moment, all flight aspects were running great.