ArduPilot / ArduPilot/MissionPlanner

MAV_CMD_DO_SET_MODE(176),By AcFly

Open
#3,546 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
2.4k
Forks
2.9k
Avg merge
19h 16m
Merged PRs (30d)
4

Description

Sorry for taking up some time here. I have some questions now. When I switch modes in Mission Player, Mission Player will automatically detect the AcFly flight controller and switch modes. It can successfully switch modes.It can successfully switch modes and send logs as follows
```
INFO MissionPlanner.MAVLinkInterface - setMode Offboard Control (393216)
INFO MissionPlanner.MAVLinkInterface - doCommand cmd DO_SET_MODE 1 393216 0 0 0 0 0
INFO MissionPlanner.MAVLinkInterface - set giveComport Base Thread current False new False
```
However, when I use MAV_CMD_DO_SET_MODE to set the mode in Java and Python programs, I get an error message. Is there any internal processing? I am not familiar with C# code. In my program, there is no problem with taking off, unlocking, etc., but there is a problem with switching modes.
```
public void setUavMode(String sn, Integer mode) throws Exception {

float modeValue = 0;

switch (mode) {
case 1:
//Guided
modeValue = 393216;
break;
case 2:
//定点模式
modeValue = 196608;
break;
case 3:
// 自动模式任务模式
modeValue = 67371008;
break;
default:
break;
}

sendCommand(
sn,
MavCmd.MAV_CMD_DO_SET_MODE,
1,
modeValue,
0, 0, 0, 0, 0);
}

private void sendCommand(
String sn,
MavCmd command,
float param1, float param2, float param3, float param4,
float param5, float param6, float param7) throws Exception {
MavlinkUav uav = getMavlinkUav(sn);
CommandLong cmd = new CommandLong.Builder()
.command(command)
.targetSystem(uav.getTargetSystem())
.targetComponent(uav.getTargetComponent())
.param1(param1)
.param2(param2)
.param3(param3)
.param4(param4)
.param5(param5)
.param6(param6)
.param7(param7)
.build();
MavlinkConnection connection = uav.getMavlinkConnection();
logger.info("发送的指令为{}",cmd);
connection.send2(
uav.getTargetSystem(),
uav.getTargetComponent(),
cmd);
}
```
thanks for

![Image](https://github.com/user-attachments/assets/eba8d518-a72a-4511-955d-a2d157e44cc6)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by comparing Mission Player's logged MAV_CMD_DO_SET_MODE parameters with the Java and Python command construction shown in the report. Trace how Mission Player sends the mode command and identify why the external command is rejected; confirm the result by reproducing the mode switch and receiving a successful acknowledgment.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop, robotics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.