Thanks Kevin, we are on the same page theoretically,
I'm getting all kinds of messages but not the
GLOBAL_POSITION_SETPOINT_INT :(
I wrote the following methods
setGlobalPositionSetPoint();
getGlobalPositionSetPoint();
void UAS::setGlobalPositionSetPoint(){
printf("Sending sample Global Position setpoint **\n");
mavlink_message_t message;
mavlink_set_global_position_setpoint_int_t sp;
sp.latitude = 45000000;
sp.longitude = 45000000;
sp.altitude = 10000;
sp.yaw = 0;
sp.coordinate_frame = MAV_FRAME_GLOBAL; //can be MAV_FRAME_GLOBAL or MAV_FRAME_GLOBAL_RELATIVE_ALT
/* send from system 200 and component 0 */
mavlink_msg_set_global_position_setpoint_int_encode(200,0,&message, &sp);
sendMessage(message);
}
void UAS::getGlobalPositionSetPoint(){
printf("Requesting Global Position setpoint **\n");
mavlink_message_t message;
mavlink_global_position_setpoint_int_t sp;
sp.latitude = 23000000; //I'm confused here. Why should a get/read operation have sp.latitude and sp.longitude specified.
sp.longitude = 23000000; //Shouldn't I just say give me "GlobalPositionSetPoint" and then when i receive I first check if it's message "GlobalPositionSetPoint" and decode it and
sp.altitude = 10000; //get my lat, lon, alt?
https://pixhawk.ethz.ch/mavlink/#GLOBAL_POSITION_SETPOINT_INT sp.yaw = 0;
sp.coordinate_frame = MAV_FRAME_GLOBAL; //can be MAV_FRAME_GLOBAL or MAV_FRAME_GLOBAL_RELATIVE_ALT
/* send from system 200 and component 0 */
mavlink_msg_global_position_setpoint_int_encode(200,0,&message, &sp);
sendMessage(message);
}
And my receive part of the code that reads messages is here. It never gets to this piece of code though
...
case MAVLINK_MSG_ID_GLOBAL_POSITION_SETPOINT_INT :
{
printf("Received: MAVLINK_MSG_ID_GLOBAL_POSITION_SETPOINT_INT \n");
mavlink_global_position_setpoint_int_t p;
mavlink_msg_global_position_setpoint_int_decode(&message, &p);
// emit userPositionSetPointsChanged(uasId, p.latitude, p.longitude, p.altitude, p.yaw);
printf("@@ LAT: %d\n", p.latitude);
printf("@@ LNG: %d\n", p.longitude);
printf("@@ ALT: %d\n", p.altitude);
}
break;
...
To enable all messages to come through to my application, I've enabled all data transmission with frequency 5.
enableAllDataTransmission(5);
But still, that MSG_ID_GLOBAL_POSITION_SETPOINT_INT is not coming back.
Am i doing something wrong? Any ideas? insights? recommendations?
I'm working with a Pixhawk board px4 - quadcopter from 3DR, physically connected to my computer via USB cable. I also tried connecting via the radio.