RosettaDrone / rosettadrone

MAVlink and H.264 Video for DJI drones
BSD 3-Clause "New" or "Revised" License
301 stars 115 forks source link

BUG: Missing brace in MAVLinkReceiver.java:190 #167

Closed marcomacchia99 closed 1 year ago

marcomacchia99 commented 1 year ago

Describe the bug

In MavLinkReceiver.java, starting from line 187 it is written:

case MAV_CMD_COMPONENT_ARM_DISARM:
     if (msg_cmd.param1 == 1)
          sendResponse(MAV_CMD_COMPONENT_ARM_DISARM, mModel.armMotors());
     else
          sendResponse(MAV_CMD_COMPONENT_ARM_DISARM);
          mModel.disarmMotors(true);
     break;

The incorrect code formatting doesn't clearly show the error, which is a missing brace for the else statement! In this way, everytime this message is received, the motors are disarmed no matter the value of param1

Steps To Reproduce

No response

Screenshots

No response

Desktop

No response

Smartphone

No response

Additional context

No response

marcomacchia99 commented 1 year ago

Moreover, the function armMotors() is fully commented. Uncommenting it results in the ability of arming a DJI Mini2 drone from QGC

kripper commented 1 year ago

The incorrect code formatting doesn't clearly show the error, which is a missing brace for the else statement! In this way, everytime this message is received, the motors are disarmed no matter the value of param1

That is clearly a bug. Fixed.

kripper commented 1 year ago

Moreover, the function armMotors() is fully commented. Uncommenting it results in the ability of arming a DJI Mini2 drone from QGC

Are you sure mFlightController.turnOnMotors() is needed for the DJI MIni 2 to take off? Please try first without uncommenting this code, because I believe your problem was the other bug (missing brackets).

marcomacchia99 commented 1 year ago

Are you sure mFlightController.turnOnMotors() is needed for the DJI MIni 2 to take off? Please try first without uncommenting this code, because I believe your problem was the other bug (missing brackets).

mFlightController.turnOnMotors() is needed only to formally arm the DJI Mini 2 and start the motors, which I think is what the arm button of QGC should do. In my opinion it could be useful to let the user use the full interface of QGC also for controlling the drone, beyond planning missions.

kripper commented 1 year ago

I'm not sure why it was commented (probably because of safety reasons), but in my experience, taking off works fine without it.

I believe it is not necessary for DJI drones because the SDK starts the motors automatically when required.