How to make QGControl connect to gazebo simulation instance in another host in same LAN?

#1

Hello,I have gazebo simu run in a another host:192.168.10.11 by this scripts:

#!/bin/bash

px4_dir=$(pwd)

source $px4_dir/Tools/setup_gazebo.bash $px4_dir $px4_dir/build/posix_sitl_default

#source devel/setup.bash

export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$px4_dir
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$px4_dir/Tools/sitl_gazebo

roslaunch px4 posix_sitl.launch

and the console output like this:

GAZEBO_PLUGIN_PATH :/home/x-man/Firmware/build/posix_sitl_default/build_gazebo
GAZEBO_MODEL_PATH :/home/x-man/Firmware/Tools/sitl_gazebo/models
LD_LIBRARY_PATH /home/x-man/catkin_ws/devel/lib:/opt/ros/kinetic/lib:/opt/ros/kinetic/lib/x86_64-linux-gnu:/usr/local/lib:/home/x-man/Firmware/build/posix_sitl_default/build_gazebo
... logging to /home/x-man/.ros/log/b80d9922-4396-11e9-a728-0800273e9aa6/roslaunch-x-test-6238.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://x-test:43745/
SUMMARY
========
PARAMETERS
 * /rosdistro: kinetic
 * /rosversion: 1.12.14
 * /use_sim_time: True
NODES
  /
    gazebo (gazebo_ros/gzserver)
    gazebo_gui (gazebo_ros/gzclient)
    sitl (px4/px4)
    vehicle_spawn_x_test_6238_688026835630494011 (gazebo_ros/spawn_model)
auto-starting new master
process[master]: started with pid [6294]
ROS_MASTER_URI=http://localhost:11311
...
process[vehicle_spawn_x_test_6238_688026835630494011-5]: started with pid [6322]
INFO  [px4] Creating symlink /home/x-man/Firmware/ROMFS/px4fmu_common -> /home/x-man/.ros/etc
0 WARNING: setRealtimeSched failed (not run as root?)
______  __   __    ___ 
| ___ \ \ \ / /   /   |
| |_/ /  \ V /   / /| |
|  __/   /   \  / /_| |
| |     / /^\ \ \___  |
\_|     \/   \/     |_/
px4 starting.
INFO  [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0
  SYS_AUTOSTART: curr: 0 -> new: 10016
  BAT_N_CELLS: curr: 0 -> new: 3
  ...
  PWM_MAX: curr: 2000 -> new: 1950
  PWM_MIN: curr: 1000 -> new: 1075
INFO  [dataman] Unknown restart, data manager file './dataman' size is 11798680 bytes
INFO  [simulator] Waiting for simulator to connect on TCP port 4560
SpawnModel script started
...
[ INFO] [1552265046.945923218]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
...
[ INFO] [1552265049.043329814, 0.112000000]: Physics dynamic reconfigure ready.
[vehicle_spawn_x_test_6238_688026835630494011-5] process has finished cleanly
log file: /home/x-man/.ros/log/b80d9922-4396-11e9-a728-0800273e9aa6/vehicle_spawn_x_test_6238_688026835630494011-5*.log

In QGroundControl->settings->Comm Links,I have tried to create TCP links to this host(192.168.10.11) by different port:

43745
11311
4560

but all failed,so question is:

How to use gqcontrol to connect to gazebo simulation instance in another host in same LAN?

#2

You need to tell PX4 to send UDP to the other computer.

There are two ways:

  1. Broadcast in your local subnet. The first QGC that sees a heartbeat will connect. If you have more than one computer with QGC open, you have a race.
  2. Add the IP of the computer with e.g. -t 192.168.x.y here:
    https://github.com/PX4/Firmware/blob/6672284871d4cd4163e99d68e75831d0495f58c8/ROMFS/px4fmu_common/init.d-posix/rcS#L226
#3

It connected,thanks very much @JulianOes

1 Like