This repository has been archived by the owner on Mar 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 480
Tidy up multi-simulation doc #835
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,14 +25,12 @@ To build an example setup, follow the step below: | |
DONT_RUN=1 make px4_sitl_default gazebo | ||
``` | ||
1. Source your environment: | ||
|
||
``` | ||
source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default | ||
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd):$(pwd)/Tools/sitl_gazebo | ||
``` | ||
|
||
1. Run launch file: | ||
|
||
``` | ||
roslaunch px4 multi_uav_mavros_sitl.launch | ||
``` | ||
|
@@ -62,7 +60,7 @@ For each simulated vehicle, the following is required: | |
The launch file `multi_uav_mavros_sitl.launch`does the following, | ||
|
||
* loads a world in gazebo, | ||
``` | ||
``` | ||
<!-- Gazebo sim --> | ||
<include file="$(find gazebo_ros)/launch/empty_world.launch"> | ||
<arg name="gui" value="$(arg gui)"/> | ||
|
@@ -71,11 +69,11 @@ The launch file `multi_uav_mavros_sitl.launch`does the following, | |
<arg name="verbose" value="$(arg verbose)"/> | ||
<arg name="paused" value="$(arg paused)"/> | ||
</include> | ||
``` | ||
``` | ||
* for each vehicle, | ||
|
||
* creates urdf model from xacro, loads gazebo model and runs PX4 SITL app instance | ||
``` | ||
``` | ||
<!-- PX4 SITL and vehicle spawn --> | ||
<include file="$(find px4)/launch/single_vehicle_spawn.launch"> | ||
<arg name="x" value="0"/> | ||
|
@@ -89,18 +87,18 @@ The launch file `multi_uav_mavros_sitl.launch`does the following, | |
<arg name="mavlink_tcp_port" value="4560"/> | ||
<arg name="ID" value="$(arg ID)"/> | ||
</include> | ||
``` | ||
``` | ||
|
||
* runs a mavros node | ||
``` | ||
``` | ||
<!-- MAVROS --> | ||
<include file="$(find mavros)/launch/px4.launch"> | ||
<arg name="fcu_url" value="$(arg fcu_url)"/> | ||
<arg name="gcs_url" value=""/> | ||
<arg name="tgt_system" value="$(arg ID)"/> | ||
<arg name="tgt_component" value="1"/> | ||
</include> | ||
``` | ||
``` | ||
|
||
> **Note** The complete block for each vehicle is enclosed in a set of `<group>` tags to separate the ROS namespaces of the vehicles. | ||
|
||
|
@@ -121,25 +119,38 @@ To add a third iris to this simulation there are two main components to consider | |
|
||
|
||
## Multiple Vehicles using SDF Models | ||
Developers can alternatively simulate multiple vehicles using vehicle models defined in Gazebp SDF files (instead of using models defined in the ROS Xacro file, as discussed in the rest of this topic). | ||
|
||
This section shows how developers can simulate multiple vehicles using vehicle models defined in Gazebo SDF files (instead of using models defined in the ROS Xacro file, as discussed in the rest of this topic). | ||
|
||
The steps are: | ||
|
||
1. Install xmlstarlet from your Linux terminal | ||
`sudo apt install xmlstarlet` | ||
1. Use roslaunch with the multi_uav_mavros_sitl_sdf.launch launch file: | ||
`roslaunch multi_uav_mavros_sitl_sdf.launch vehicle:=<model_file_name>` | ||
1. Install *xmlstarlet* from your Linux terminal: | ||
``` | ||
sudo apt install xmlstarlet | ||
``` | ||
1. Use *roslaunch* with the **multi_uav_mavros_sitl_sdf.launch** launch file: | ||
```` | ||
roslaunch multi_uav_mavros_sitl_sdf.launch vehicle:=<model_file_name> | ||
``` | ||
|
||
> **Note** that the vehicle model file name argument is optional; the [plane model](https://github.com/PX4/sitl_gazebo/tree/master/models/plane) will be used by default. | ||
> **Note** that the vehicle model file name argument is optional (`vehicle:=<model_file_name>`); if omitted the [plane model](https://github.com/PX4/sitl_gazebo/tree/master/models/plane) will be used by default. | ||
|
||
This method is similar to using the xacro except that the SITL/Gazebo port number is automatically inserted by _xmstarlet_ for each spawned vehicle, and does not need to be specified in the SDF file. | ||
|
||
To add a new vehicle, you need to make sure the model can be found in order to spawn it in Gazebo and PX4 needs to have an approperate startup script corresponding to it. | ||
|
||
1. You can choose to either modify the `single_vehicle_spawn_sdf.launch` file to point to the location of your model by changing the line containing: | ||
`$(find px4)/Tools/sitl_gazebo/models/$(arg vehicle)/$(arg vehicle).sdf` | ||
to point to your model or copy your model in to the folder above (following the same path convention). Be sure to set the `vehicle` argument even if you hardcode the path to your model. | ||
1. The `vehicle` argument is used to set the `PX4_SIM_MODEL` environment variable, which is used by the default rCS (startup script) to find the corresponding startup settings file for the model. Within PX4 these startup files can be found in the `Firmware/ROMFS/px4fmu_common/init.d-posix/` directory. For example, here is the plane model's [startup script](https://github.com/PX4/Firmware/blob/master/ROMFS/px4fmu_common/init.d-posix/1030_plane). For this to work, the PX4 node in the launch file is passed arguemnts that specify the rCS file (`etc/init.d/rcS`) and the location of the rootfs directory (`$(find px4)/ROMFS/px4fmu_common`). For simplicity, it is suggested that the startup file for the model be placed alongside PX4's in `Firmware/ROMFS/px4fmu_common/init.d-posix/`. | ||
To add a new vehicle, you need to make sure the model can be found (in order to spawn it in Gazebo), and PX4 needs to have an appropriate corresponding startup script. | ||
|
||
1. You can choose to do either of: | ||
* modify the **single_vehicle_spawn_sdf.launch** file to point to the location of your model by changing the line below to point to your model: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tend to use bold for filenames, italic for tool names, and code for code or command line invocations. |
||
``` | ||
$(find px4)/Tools/sitl_gazebo/models/$(arg vehicle)/$(arg vehicle).sdf | ||
``` | ||
> **Note** Ensure you set the `vehicle` argument even if you hardcode the path to your model. | ||
* copy your model into the folder indicated above (following the same path convention). | ||
1. The `vehicle` argument is used to set the `PX4_SIM_MODEL` environment variable, which is used by the default rCS (startup script) to find the corresponding startup settings file for the model. | ||
Within PX4 these startup files can be found in the **Firmware/ROMFS/px4fmu_common/init.d-posix/** directory. | ||
For example, here is the plane model's [startup script](https://github.com/PX4/Firmware/blob/master/ROMFS/px4fmu_common/init.d-posix/1030_plane). | ||
For this to work, the PX4 node in the launch file is passed arguments that specify the *rCS* file (**etc/init.d/rcS**) and the location of the rootfs directory (`$(find px4)/ROMFS/px4fmu_common`). | ||
For simplicity, it is suggested that the startup file for the model be placed alongside PX4's in **Firmware/ROMFS/px4fmu_common/init.d-posix/**. | ||
|
||
|
||
## Additional Resources | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lamping7
Note