PX4 / PX4-Autopilot

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

mavlink_command_sender doesn't transmit messages #9415

Closed okalachev closed 6 years ago

okalachev commented 6 years ago

Trying to make PX4 send some MAVLink commands to other devices. Using vehicle_command topic for that. But have some problems with uORB. MavlinkStreamCommandLong and mavlink_command_send just don't receive my messages and so don't transmit them.

Here is the example code, that I have in my module:

vehicle_command_s cmd = {};

cmd.command = 123;
cmd.param1 = 456;
cmd.param2 = 123;
cmd.param3 = 456;
cmd.target_system = 8; // random target system
cmd.target_component = 0;
cmd.source_system = 1; // our id

orb_advert_t cmd_pub = orb_advertise_queue(ORB_ID(vehicle_command), &cmd, 5); // tried without the queue, didn't help

while(true) {
// publish a message once a second
usleep(1000000);
cmd.timestamp = hrt_absolute_time();
orb_publish(ORB_ID(vehicle_command), cmd_pub, &cmd);
}

I see all these messages via topic_listener.

So, I should get something like cmd sender command 123 sent (first, retries: 1/0, channel: 0) once a second, BUT, it happens only sometimes (once per 10–20 seconds), so most of the messages just got skipped.

Anyone can help?

okalachev commented 6 years ago

https://github.com/PX4/Firmware/pull/9427