Java Mavlink library

Hi everyone,

During the past month or so I have been developing a component for an internal proprietary system. As part of this project, I also wrote a library that generates dialects for Mavlink, deals with packing/unpacking the protocol, serializes/deserializes message payloads, performs CRC checks, supports signing and more. I wrote it as a separate module and released it as an open source project, which is also available on Maven Central.

It is available at GitHub - dronefleet/mavlink: A Java API for MAVLink communication
Please feel free to use, criticize, make suggestions, and most importantly report bugs, design problems or any other relevant issue that keeps you from achieving your intended goal (within constraints of the library’s objective, obviously).

Hopefully you find this helpful :slight_smile:

Thanks,
Ben

2 Likes

Hi, Ben. Ben. Many thanks. It’s very helpful.

Hi, Ben. Do you have example using Mavlink2 message send?
When i try to create and send message Mavlink2, i recieve error.

Exception in thread “main” java.lang.IllegalStateException: Failed generate signature for packet

			if (message.getPayload() instanceof Heartbeat) {
				// This is a heartbeat message
				System.out.println("Heartbeat");
				System.out.println(message.toString());
				if ( handshake != true ) {
					
					System.out.println("\n Handshake \n ");				
					connection.send(new Mavlink2Message<>(
							1,
							1,
							message.getOriginComponentId(), 
							message.getOriginSystemId(),
							CommandInt.builder()
							.targetComponent(message.getOriginComponentId())
							.targetSystem(message.getOriginSystemId()).param1(1)
							.frame(MavFrame.MAV_FRAME_MISSION)
							.command(MavCmd.MAV_CMD_REQUEST_PROTOCOL_VERSION)
							.build()
					      ));
					handshake = true;						
				}

This parammeters i get from Heartbeat message of APM.
message.getOriginComponentId(),
message.getOriginSystemId(),

I use PX4 v.3 APM

Hi kgmormylo,

Please open an issue at https://github.com/dronefleet/mavlink/issues/new and make sure to include the full stack trace of the exception :slight_smile:

Thank you,
Ben