These are chat archives for dronekit/dronekit-android

15th
Jul 2017
edsonr
@edsonr
Jul 15 2017 16:26
@fernando-s97 Hi fermando. You can get any message via Mavlink Observer. This link has all the messages used by DroneKit ( http://www.programcreek.com/java-api-examples/index.php?source_dir=Tango-master/ROSTango/src/rostango/Mavlink/src/com/MAVLink/Messages/ardupilotmega/msg_rc_channels_raw.java ). Here as code ex:
final MavlinkObserver observer = new MavlinkObserver() {
@Override
public void onMavlinkMessageReceived(MavlinkMessageWrapper mavlinkMessageWrapper) {
if (mavlinkMessageWrapper.getMavLinkMessage().msgid == MAVLINK_MSG_ID_RC_CHANNELS_RAW) {
msg_rc_channels_raw msgRcChannelsRaw = new msg_rc_channels_raw();
msgRcChannelsRaw.unpack(mavlinkMessageWrapper.getMavLinkMessage().pack().payload);
System.out.println(msgRcChannelsRaw.chan3_raw);
System.out.println(msgRcChannelsRaw.chan6_raw);
System.out.println( msgRcChannelsRaw.chan7_raw);
}
}
};
drone.addMavlinkObserver(observer);
edsonr
@edsonr
Jul 15 2017 16:39
@edsonr Do not forget to stop listening at some point, ex: drone.removeMavlinkObserver(observer);
Fernando de Oliveira Santos
@fernando-s97
Jul 15 2017 18:10
@edsonr Is it ok to add the observer when drone gets connected or is has to be at some specific point? Thanks for previous the answer!
Fernando de Oliveira Santos
@fernando-s97
Jul 15 2017 20:20
@edsonr One other question. Are these values from the drone or from the radio?
edsonr
@edsonr
Jul 15 2017 21:28
@fernando-s97 After connected. Create a function and call his after connect.
edsonr
@edsonr
Jul 15 2017 21:40
@fernando-s97 These are from the input from radio. Find the message you want in this link (Java-api-examples) , and change the call of the object. The if is only for filter message. if you remove you will see all messages in .msgid