用PX4的示例launch文件
roslaunch px4 posix_sitl.launch
QGC和mavros话题连接不上
... logging to /home/abcd/.ros/log/bfe21ae8-8e82-11ed-9454-00155d5404ed/roslaunch-LAPTOP-5C4ISNEJ-4568.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://LAPTOP-5C4ISNEJ:46817/
SUMMARY
========
PARAMETERS
* /gazebo/enable_ros_network: True
* /rosdistro: noetic
* /rosversion: 1.15.15
* /use_sim_time: True
NODES
/
gazebo (gazebo_ros/gzserver)
gazebo_gui (gazebo_ros/gzclient)
sitl (px4/px4)
vehicle_spawn_LAPTOP_5C4ISNEJ_4568_5999769344658295407 (gazebo_ros/spawn_model)
auto-starting new master
process[master]: started with pid [4587]
ROS_MASTER_URI=http://localhost:11311
setting /run_id to bfe21ae8-8e82-11ed-9454-00155d5404ed
process[rosout-1]: started with pid [4608]
started core service [/rosout]
process[sitl-2]: started with pid [4615]
Creating symlink /home/abcd/PX4_WS/PX4-Autopilot/build/px4_sitl_default/etc -> /home/abcd/.ros/etc
______ __ __ ___
| ___ \ \ \ / / / |
| |_/ / \ V / / /| |
| __/ / \ / /_| |
| | / /^\ \ \___ |
\_| \/ \/ |_/
px4 starting.
INFO [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0
process[gazebo-3]: started with pid [4626]
INFO [init] found model autostart file as SYS_AUTOSTART=10016
INFO [param] selected parameter default file eeprom/parameters_10016
[param] parameter file not found, creating eeprom/parameters_10016
process[gazebo_gui-4]: started with pid [4637]
SYS_AUTOCONFIG: curr: 0 -> new: 1
process[vehicle_spawn_LAPTOP_5C4ISNEJ_4568_5999769344658295407-5]: started with pid [4649]
SYS_AUTOSTART: curr: 0 -> new: 10016
CAL_ACC0_ID: curr: 0 -> new: 1310988
CAL_GYRO0_ID: curr: 0 -> new: 1310988
CAL_ACC1_ID: curr: 0 -> new: 1310996
CAL_GYRO1_ID: curr: 0 -> new: 1310996
CAL_ACC2_ID: curr: 0 -> new: 1311004
CAL_GYRO2_ID: curr: 0 -> new: 1311004
* CAL_MAG0_ID: curr: 0 -> new: 197388
* CAL_MAG1_ID: curr: 0 -> new: 197644
* SENS_BOARD_X_OFF: curr: 0.0000 -> new: 0.0000
* SENS_DPRES_OFF: curr: 0.0000 -> new: 0.0010
* SYS_AUTOCONFIG: curr: 1 -> new: 0
* IMU_INTEG_RATE: curr: 200 -> new: 250
INFO [dataman] data manager file './dataman' size is 7866640 bytes
PX4 SIM HOST: localhost
INFO [simulator] Waiting for simulator to accept connection on TCP port 4560
[INFO] [1673092774.280612, 0.000000]: Loading model XML from file /home/abcd/PX4_WS/PX4-Autopilot/Tools/sitl_gazebo/models/iris/iris.sdf
[INFO] [1673092774.283555, 0.000000]: Waiting for service /gazebo/spawn_sdf_model
[ INFO] [1673092774.420736900]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1673092774.421906400]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
[ INFO] [1673092774.498667300]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1673092774.499843600]: waitForService: Service [/gazebo_gui/set_physics_properties] has not been advertised, waiting...
[ INFO] [1673092777.585026100]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[INFO] [1673092777.597045, 0.000000]: Calling service /gazebo/spawn_sdf_model
[ INFO] [1673092777.603531100, 0.016000000]: Physics dynamic reconfigure ready.
Warning [parser.cc:833] XML Attribute[version] in element[sdf] not defined in SDF, ignoring.
[INFO] [1673092777.853853, 0.168000]: Spawn status: SpawnModel: Successfully spawned entity
[vehicle_spawn_LAPTOP_5C4ISNEJ_4568_5999769344658295407-5] process has finished cleanly
在运行 PX4 仿真的 posix_sitl.launch 文件时,无法连接到 QGC 和 mavros 话题。这可能是由于网络配置问题造成的。请确保计算机能够正常连接到模拟器,并且确保 QGC 和 mavros 正在使用相同的网络连接。
也可以尝试运行 rosnode list 命令,以查看当前正在运行的 ROS 节点。如果 QGC 和 mavros 节点没有出现在节点列表中,则可能是因为它们没有正确启动。
此外,还可以尝试在运行 posix_sitl.launch 文件之前运行 source devel/setup.bash 来加载环境变量,以确保所有必要的工具和库都可用。