Hi,
So I am trying to retrieve sensor information from my ArduCopter to my c# application and as such need to use Mavlink.
From the Mission Planner source I have found functions to create the packets with check-sums and all. Once connected I can see my ArduCopter streaming heart beat messages. As I am a newbie to Mavlink, how do I get it to stream sensor info or how can I poll the ArduCopter? Send messages with no payload?
Replies
This is a very oldd post try here http://discuss.ardupilot.org/c/ground-control-software/mavlink and ask the question
and this post http://discuss.ardupilot.org/t/mavlink-step-by-step/9629
Hint: pocketed is actually packet sequence so declaring it as a global byte starting at zero and make the line Packet[2] = packetid++; means the sequence goes up each packet
endrie said:
Hi Jan, could you show me how you declare variable "packetid" ???
is that integer or byte or what ??
thanks
Jan Swanepoel said:
Hello folks,
you can find the last version of my MAVLinkJava project here :
https://code.google.com/p/mavlinkjava/
Best
Guillaume
Hello,
Since Im doing something really similar Im gonna post my problem here:
I wanna to retrieve altitude of ardupilot. When I connect to APM, I can see in telemetry the altitude and if I move ardupilot in my hands, altitude is changing. So my goal is to print all that. I found out that the float altitude is in mavlink_msg_vfr_hud.h. So far its only printing: "ALTITUDE: 0.0"
Here is what I have so far:
#include "/Users/Gabriele/Documents/Arduino/libraries/ArdunioMAVLink/libraries/mavlink/include/mavlink.h"
#include <mavlink_msg_vfr_hud.h>
int system_type = MAV_QUADROTOR;
int autopilot_type = MAV_AUTOPILOT_GENERIC;
uint16_t len;
mavlink_message_t msg;
uint8_t buf[MAVLINK_MAX_PACKET_LEN];
mavlink_status_t status;
float mavlink_msg_vfr_hud_get_alt;
char buffer[32];
void readSerialMavLink();
void setup() {
Serial.begin(115200);
Serial.println("Booting...");
}
void loop() {
readSerialMavlink();
delay(1000);
}
void readSerialMavlink() {
while(Serial.available() > 0) {
Serial.println("Serial available");
Serial.print("ALTITUTDE: ");
Serial.println((dtostrf(mavlink_msg_vfr_hud_get_alt,10,2,buffer)));
}
}
Hi
This is cool! But does anyone have a simple vb.net example of send and recieve like this ?
Tommy
From gcs-copter Java:
- from APM heartbeat get info:
MAVLink.CURRENT_SYSID = m.sysID;
MAVLink.ARDUCOPTER_COMPONENT_ID = m.componentID;
- send a heartbeat presenting yourself:
msg_heartbeat msg = new msg_heartbeat();
msg.type = MAVLink.MAV_TYPE.MAV_TYPE_GCS;
msg.autopilot = MAVLink.MAV_AUTOPILOT.MAV_AUTOPILOT_GENERIC;
sendBytesToComm(MAVLink.createMessage(msg));
- and request all packets or only the ones you are interested in:
msg_request_data_stream req = new msg_request_data_stream();
req.req_message_rate = 20;
req.req_stream_id = MAVLink.MAV_DATA_STREAM.MAV_DATA_STREAM_ALL;
req.start_stop = 1;
req.target_system = MAVLink.CURRENT_SYSID;
req.target_component = 0;
sendBytesToComm( MAVLink.createMessage(req));