Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetMode its not changing the mode #52

Closed
dairoca90 opened this issue Nov 16, 2020 · 1 comment
Closed

SetMode its not changing the mode #52

dairoca90 opened this issue Nov 16, 2020 · 1 comment

Comments

@dairoca90
Copy link

Hi, i was trying to change the mode of an arducopter using SetMode because using CommandLong its not supported for the autopilot , the problem is that every time when i send the command returns a COMMAND_ACK {command : 11, result : 4} i try to change the custom mode param for my autopilot but it didnt work hope you can tell me if this command works or its no longer in use or am i doing something wrong

Here is my code

Socket socket = new Socket("192.168.1.105", 14450);
MavlinkConnection connection = MavlinkConnection.builder(socket.getInputStream(), 
		                                        socket.getOutputStream())
                                                       .dialect(MavAutopilot.MAV_AUTOPILOT_ARDUPILOTMEGA, new ArdupilotmegaDialect())
						       .build();
				
SetMode setMode = SetMode.builder()
		.targetSystem(255)
		.customMode(0)
		.build();
		
connection.send1(255, 1, setMode);
@dairoca90
Copy link
Author

Hi i was able to send the mode correctly creating a enum class with the correct value that my autopilot "arducopter 3.2.1" was needed and build it in the SetMode it seems that at least for my autopilot its neccesary to send specific values for the baseMode and custom_mode, i got these printed with the Heartbeat message and i started to change the modes with my rc controller to see the outputs of the baseMode and custom mode so i can send it back with the SetMode class.

This is my enum class with the customFlagMode

import io.dronefleet.mavlink.annotations.MavlinkEntryInfo;
import io.dronefleet.mavlink.annotations.MavlinkEnum;

@MavlinkEnum
public enum MavModeCustomFlag {

	
   @MavlinkEntryInfo(81)
    MAV_MODE_CUSTOM
	
}

This is the code to change the mode using the custom enum

SetMode setMode = SetMode.builder()
				.targetSystem(255)
				.baseMode(MavModeCustomFlag.MAV_MODE_CUSTOM)
				.customMode(6)
				.build();
connection.send1(255,0,setMode);

Hope someone helps im closing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant