FCU Not receiving heartbeat in the Offboard Example

Hi,

I have the following problem. I am trying to run the Offboard example with ROS and PX4 in Gazebo as described here: MAVROS Offboard Example · PX4 Developer Guide

(There is no Hardware involved in my setup)

I am on Ubuntu 16.04 with the PX4/Firmware repo at v1.8.2

Everything works fine and now I am trying to put all together in a launch file which launches mavros, the sitl part and px4. However, in this case I am not able to receive a heartbeat by the FCU (i.e. I get stuck in the line while loop

// wait for FCU connection
    while(ros::ok() && !current_state.connected){
        ros::spinOnce();
        rate.sleep();
    }

CASE 1
In this case I open three different terminals.

Terminal 1
cd ~/src/Firmware && make posix_sitl_default gazebo
Terminal 2
roslaunch mavros px4.launch fcu_url:=udp://:14540@localhost:14557
Terminal 3
rosrun offboard_example_package offb_original_node
where offb_original_node is the name of the executable generated from the .cpp at the previously linked page. I did not change anything and I changed the CMakeLists.txt as suggested in the webpage. Indeed, in Case 1 Everything works!

CASE 2
Instead of opening 3 different terminals I would like to run everything with a launch file. Therefore I created a file .launch called offboard_original_node.launch. In this file I wrote:

<?xml version="1.0"?>
<launch>
    <include file="$(find px4)/launch/mavros_posix_sitl.launch"/>

    <node name="offb_original_node" pkg="offboard_example_package" type="offb_original_node" output="screen"/>
</launch>

And then I try to do
roslaunch offboard_example_package offb_original_node.launch
The node gets stuck in the line I told you above (i.e. I am not able to connect to the FCU).
Therefore, CASE 2 does not work :frowning:

What am I doing wrong?
What are the differences between case 1 and case 2

Try looking at the parameters in mavros_posix_stil.launch if everything is configured properly.

You are using two different launch files in case1 and case2

I personally run sitl and mavros separately so that on a real vehicle, just the sitl part needs to get crossed out: example

1 Like