Additional question on this:
Does anyone know how to send a waypoint then via a serial command (using C++)?
I created a payload to send by the following:
//Prepare NAV_WAYPOINT payload
mavlink_command_long_t payload_waypoint;
payload_waypoint.command = MAV_CMD_NAV_WAYPOINT;
payload_waypoint.target_system = 0; //All systems
payload_waypoint.target_component = 0; //All components
payload_waypoint.confirmation = 0; //First transmission of command, not a confirmation
payload_waypoint.param1 = 65535; //Hold time at waypoint in decimal seconds (65535 is max)
payload_waypoint.param2 = 0; //Acceptance radius in meters (when plain inside the sphere of this radius, the waypoint is considered reached) (Plane only).
payload_waypoint.param3 = 0; //0 to pass through the WP, if > 0 radius in meters to pass by WP. Positive value for clockwise orbit, negative value for counter-clockwise orbit. Allows trajectory control.
payload_waypoint.param4 = 0; //Desired yaw angle at waypoint target.(rotary wing)
payload_waypoint.param5 = 0; //Target latitude. If zero, the Copter will hold at the current latitude.
payload_waypoint.param6 = 0; //Target longitude. If zero, the Copter will hold at the current longitude.
payload_waypoint.param7 = loiter_altitude_; //Target altitude. If zero, the Copter will hold at the current altitude.
Then obviously encoded it using:
mavlink_message_t message;
mavlink_msg_command_long_encode(system_id_, component_id_, &message, payload);
uint8_t write_buffer[300]; // longer than any possible Mavlink message
uint16_t message_length = mavlink_msg_to_send_buffer(write_buffer, &message);
port_->write(write_buffer, message_length);
But I get a (from my printout to verify) MAVLink Command ID - 16, Result - MAV_RESULT_UNSUPPORTED
I tried the same with MAV_CMD_NAV_LOITER_TO_ALT:
mavlink_command_long_t payload_loiter_to_alt;
payload_loiter_to_alt.command = MAV_CMD_NAV_LOITER_TO_ALT;
payload_loiter_to_alt.target_system = 0; //All systems
payload_loiter_to_alt.target_component = 0; //All components
payload_loiter_to_alt.confirmation = 0; //First transmission of command, not a confirmation
payload_loiter_to_alt.param1 = 1; //Set to heading required to match next waypoint before exit loiter
payload_loiter_to_alt.param2 = 0; //Use default loiter params for UAV (set by operator)
payload_loiter_to_alt.param3 = 0; //Not Used
payload_loiter_to_alt.param4 = 0; //Allow forward moving UAVs to exit from waypoint
payload_loiter_to_alt.param5 = 0; //Use current lat
payload_loiter_to_alt.param6 = 0; //Use current lon
payload_loiter_to_alt.param7 = loiter_altitude_; //Loiter at desired altitude
I get a (from my printout to verify) MAVLink Command ID - 31, Result - MAV_RESULT_UNSUPPORTED.
I am assumming the file GCS_Mavlink.cpp is the file that accepts these commands that I send, is that correct? Any idea how to set a waypoint via code I can send through the serial?
I’ve been trying using a mavlink_set_position_target_global_int_t payload as well. It seems to write but I get no response from the drone.
I’ve tried all these on both fixed_wing and multi-rotors. And just FYI, I’ve been verifying behavior using mission planner and the sim_vehicle.py simulator (and using TCP to simulate my serial connection).
Using release 3.5.7 of Ardupilot.
Any help is appreciated. Thanks again!
Brian