PX4 / PX4-Autopilot

PX4 Autopilot Software
https://px4.io
BSD 3-Clause "New" or "Revised" License
8.53k stars 13.51k forks source link

[Commander] send_vehicle_command always send TAKEOFF #10359

Closed tecnic08 closed 6 years ago

tecnic08 commented 6 years ago

While I was going through the code and I came across line 263 in Commander.cpp

static bool send_vehicle_command(uint16_t cmd, float param1 = NAN, float param2 = NAN)
{
vehicle_command_s vcmd = {};
vcmd.timestamp = hrt_absolute_time();
vcmd.param1 = param1;
vcmd.param2 = param2;
vcmd.param3 = NAN;
vcmd.param4 = NAN;
vcmd.param5 = (double)NAN;
vcmd.param6 = (double)NAN;
vcmd.param7 = NAN;
vcmd.command = vehicle_command_s::VEHICLE_CMD_NAV_TAKEOFF;
vcmd.target_system = status.system_id;
vcmd.target_component = status.component_id;

orb_advert_t h = orb_advertise_queue(ORB_ID(vehicle_command), &vcmd, vehicle_command_s::ORB_QUEUE_LENGTH);

return (h != nullptr);
}

First argument is uint16_t cmd, but it is not being used in the function as far as I can see. Should the vcmd.command = vehicle_command_s::VEHICLE_CMD_NAV_TAKEOFF; be vcmd.command = cmd; instead?

I haven't tested out the code, but it just seems wrong.

dagar commented 6 years ago

Thanks, that's definitely a bug.

dagar commented 6 years ago

See https://github.com/PX4/Firmware/pull/10362