Rover ros + QGroundControl

Hi.

I’m trying to control rover with a gamepad and get IMU and Camera images through ros.
However, when I use rover with Ros and QGroundControl together, weird thing happens.

I started gazebo and ros with the following commands

sudo no_sim=1 make px4_sitl_default gazebo 
source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
roslaunch gazebo_ros empty_world.launch world_name:=$(pwd)/Tools/sitl_gazebo/worlds/rover.world

And when I arm the rover in QGroundControl, then rover starts to move backward, even though throttling is 0.
This doesn’t happen when I do not use ros.

Can anyone explain what is happening?
Can’t I use ros + QGroundcontrol?

@Keunwoo_Park Its because of the way you are starting the simulation.

roslaunch px4 posix_sitl.launch vehicle:=rover

For sourcing the environment if ros is unable to find px4, you can check this doc

1 Like

Thank you for the answer.
However, I’m facing another problem, related to that.

I tried to run gazebo with ros wrappers, as the doc says.

DONT_RUN=1 make px4_sitl_default gazebo
source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/sitl_gazebo
roslaunch px4 posix_sitl.launch

Then I get following errors

ERROR [px4] is_server_running: failed to create lock file: /tmp/px4_lock-0, reason=Permission denied
ERROR [px4_daemon] error binding socket /tmp/px4-sock-0, error = Address already in use

So I googled, and tried this solution, but didn’t work.

Do you have any suggestions what to try next?

@Keunwoo_Park You don’t need to run DONT_RUN=1 make px4_sitl_default gazebo since the roslaunch already starts sitl. Infact you are running two SITL instances on the same port

1 Like

Thank you! Now it works!

But I had to do make clean before everything else.

However, now QGroundControl doesn’t connects to the vehicle.
Shouldn’t it automatically connect to the vehicle?
Is there something else that I should do to use QGroundControl with roslaunch?

QGroundcontrol should connect automatically.

Can you check if you have Autoconnect enabled on udp? You can check in the General settings menu whcih appears when clicking on to the QGC logo

UDP autoconnection is set.

QGC works well when I run sitl with make px4_sitl command.
Should I run something else on the background?

@Keunwoo_Park For me it works instantly. Did you change anything in the launchfile? Have you tried using wireshark to see if any udp packets are coming out of PX4 sitl?

Actually, I have this error when I run Gazebo with ROS wrapper.
But it still runs.

ERROR: cannot launch node of type [px4/px4]: can't locate node [px4] in package [px4]

Do you think it is a relevant issue?

Yes, it is because ros somehow doesn’t return 1 when you launch. Does this happen also when you set the environment variables correctly as above? most likely you are not getting qgc connection because px4 is not running at all

That is weird. Here are exact commands that I used.

sudo make clean
source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/sitl_gazebo
roslaunch px4 posix_sitl.launch

And I still get the error. Is there anything that I’m missing?

Try

sudo make clean
DONT_RUN=1 make px4_sitl_default gazebo
source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/sitl_gazebo
roslaunch px4 posix_sitl.launch
1 Like