MAVROS companion computer connection problems when connected using USB

I am trying to setup a companion computer where the pixhawk2 cube is connected to the companion computer via USB cable (connected to the micro USB port on pixhawk). For testing, I have QGC on the same computer, and I connect using UDP. I can see the device connected to /dev/ttyACM0. When I start the mavros node (in ROS melodic) with px4.launch file, it shows that the mavros node is started, but there is no heartbeat nor connection to pixhawk.
roslaunch mavros px4.launch fcu_url:=/dev/ttyACM0:921600 gcs_url:="udp://@localhost:14550"
Below is the relevant output.

[ INFO] [1660313567.229164677]: Autostarting mavlink via USB on PX4
[ INFO] [1660313567.229234680]: Built-in SIMD instructions: SSE, SSE2
[ INFO] [1660313567.229250439]: Built-in MAVLink package version: 2022.3.3
[ INFO] [1660313567.229273267]: Known MAVLink dialects: common ardupilotmega ASLUAV AVSSUAS all development icarous matrixpilot paparazzi standard storm32 uAvionix ualberta
[ INFO] [1660313567.229290611]: MAVROS started. MY ID 1.240, TARGET ID 1.1

Nothing happens after this.

It is the same when I try to connect to mavlink shell. When I run ./Tools/mavlink_shell.py /dev/ttACM0, it just shows
Connecting to MAVLINK...

As a workaround, if I make a serial connection in GCS after I connect the USB cable, I can see that the pixhawk is connected to it. After this, if I close GCS (remove the serial connection to GCS) and try starting the mavros node again (with the same launch parameters), it connects, and I can connect from GCS using UDP.

[ INFO] [1660313567.229164677]: Autostarting mavlink via USB on PX4
[ INFO] [1660313567.229234680]: Built-in SIMD instructions: SSE, SSE2
[ INFO] [1660313567.229250439]: Built-in MAVLink package version: 2022.3.3
[ INFO] [1660313567.229273267]: Known MAVLink dialects: common ardupilotmega ASLUAV AVSSUAS all development icarous matrixpilot paparazzi standard storm32 uAvionix ualberta
[ INFO] [1660313567.229290611]: MAVROS started. MY ID 1.240, TARGET ID 1.1
[ INFO] [1660313567.229465365]: IMU: Attitude quaternion IMU detected!
[ INFO] [1660313567.229534213]: IMU: High resolution IMU detected!
[ INFO] [1660313567.230388767]: CON: Got HEARTBEAT, connected. FCU: PX4 Autopilot

I am able to connect to mavlink shell also after the workaround.

I have to always make this one time serial connection to GCS after each time I reconnect the pixhawk to the computer using USB. Can anyone help me fix this issue? I don’t want to (it might be even possible to) start GCS and connect pixhawk serially.

Cheers!

Did you find a fix for this? I’m having the same issue. I have some code I can use to read MAVLink packets over USB connection but the pixhawk won’t send anything until after it has been connected to QGC. I have to do the same, connect to QGC and then close QGC every time I power up the pixhawk before I can read anything over serial. It feels like there’s a handshake or a wake up call I’m missing.

I’ve tried sending the following to no avail:

  • request data stream
  • heartbeat
  • message interval

Hi!

Try this:
see MAV_2_BROADCAST param of your PX4, it mast be “Always broadcast”;
and MAV_HB_FORW_EN = Enabled;
maybe it’s help.

Hi, thank you for the help!

Unfortunately I have already set these parameters and it hasn’t solved the issue.

@katbuj @ConorZAM Did you solve this issue? I am having the same thing!

Hi @UAV

I managed to get it working. I connected Pixhawk to the computer using TELEM2 port, rather than using the micro USB port.

This page (https://wiki.hanzheteng.com/quadrotor/companion-computer#px4-firmware) details the steps to set it up. Hope this would be useful.

@katbuj Thank you, I managed to solve the issue too, but connecting everything via USB, as via telemetry some of the values like HIGHRES_IMU values won´t show up. I made a thread asking for help and then I posted my solution.