How to receive heartbeats from Companion computer

Hi!

I have some troubles getting any information (but for simplicity start with a heartbeat) from my companion computer.

The situation is as follows, I have a drone, with cube flight controller. Then I have a companion computer connected to the flight controller via UDP.

On my companion computer using Mavsdk:

  • I can find the system having the auto pilot (flight controller)
  • My companion computer is sending heartbeats (sys id 0, component id 192)
  mavsdk::Mavsdk mavsdk;
  mavsdk::Mavsdk::Configuration config(mavsdk::Mavsdk::Configuration::UsageType::CompanionComputer);
  config.set_system_id(1);
  config.set_component_id(MAV_COMP_ID_ONBOARD_COMPUTER2);
  config.set_always_send_heartbeats(true);
  mavsdk.set_configuration(config);

  mavsdk::ConnectionResult connection_result =
      mavsdk.add_any_connection(connection_string, mavsdk::ForwardingOption::ForwardingOn);
std::shared_ptr<mavsdk::System> get_system(mavsdk::Mavsdk& mavsdk) {
  for (auto system : mavsdk.systems()) {
    if (system->get_system_id() == 1)  // system_id 1 = autopilot (cube)
    {
      return system;
    }
  }

  ROS_ERROR("No autopilot found");
  return {};
}

Then I have a simple little program that makes the same connection and reads out heartbeats. I would expect:

  • That my companion computer (component id 192) would be shown as added component
  • That I would see the heartbeat
    But I don’t and I cannot figure out why. Does someone have some ideas on how to establish this?

It should not send from sysid 0. Sysid 0 means “all” and is invalid as a source.

If you’re using pymavlink, make sure to set the source sysid and compid:

... = mavutil.mavlink_connection(connection_string, source_system=1, source_component=192)