-
Notifications
You must be signed in to change notification settings - Fork 13.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
launch: multiple sdf models #12306
Merged
Merged
launch: multiple sdf models #12306
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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?xml version="1.0"?> | ||
<launch> | ||
<!-- MAVROS posix SITL environment launch script --> | ||
<!-- launches Gazebo environment and 2x: MAVROS, PX4 SITL, and spawns vehicle --> | ||
<!-- vehicle model and world --> | ||
<arg name="est" default="ekf2"/> | ||
<arg name="vehicle" default="plane"/> | ||
<arg name="world" default="$(find mavlink_sitl_gazebo)/worlds/empty.world"/> | ||
<!-- gazebo configs --> | ||
<arg name="gui" default="true"/> | ||
<arg name="debug" default="false"/> | ||
<arg name="verbose" default="false"/> | ||
<arg name="paused" default="false"/> | ||
<!-- Gazebo sim --> | ||
<include file="$(find gazebo_ros)/launch/empty_world.launch"> | ||
<arg name="gui" value="$(arg gui)"/> | ||
<arg name="world_name" value="$(arg world)"/> | ||
<arg name="debug" value="$(arg debug)"/> | ||
<arg name="verbose" value="$(arg verbose)"/> | ||
<arg name="paused" value="$(arg paused)"/> | ||
</include> | ||
<!-- UAV0 --> | ||
<group ns="uav0"> | ||
<!-- MAVROS and vehicle configs --> | ||
<arg name="ID" value="0"/> | ||
<arg name="fcu_url" default="udp://:14540@localhost:14580"/> | ||
<!-- PX4 SITL and vehicle spawn --> | ||
<include file="$(find px4)/launch/single_vehicle_spawn_sdf.launch"> | ||
<arg name="x" value="0"/> | ||
<arg name="y" value="0"/> | ||
<arg name="z" value="0"/> | ||
<arg name="R" value="0"/> | ||
<arg name="P" value="0"/> | ||
<arg name="Y" value="0"/> | ||
<arg name="vehicle" value="$(arg vehicle)"/> | ||
<arg name="mavlink_udp_port" value="14560"/> | ||
<arg name="mavlink_tcp_port" value="4560"/> | ||
<arg name="ID" value="$(arg ID)"/> | ||
</include> | ||
<!-- 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="$(eval 0 + arg('ID'))"/> | ||
<arg name="tgt_component" value="1"/> | ||
</include> | ||
</group> | ||
<!-- UAV1 --> | ||
<group ns="uav1"> | ||
<!-- MAVROS and vehicle configs --> | ||
<arg name="ID" value="1"/> | ||
<arg name="fcu_url" default="udp://:14541@localhost:14581"/> | ||
<!-- PX4 SITL and vehicle spawn --> | ||
<include file="$(find px4)/launch/single_vehicle_spawn_sdf.launch"> | ||
<arg name="x" value="1"/> | ||
<arg name="y" value="0"/> | ||
<arg name="z" value="0"/> | ||
<arg name="R" value="0"/> | ||
<arg name="P" value="0"/> | ||
<arg name="Y" value="0"/> | ||
<arg name="vehicle" value="$(arg vehicle)"/> | ||
<arg name="mavlink_udp_port" value="14561"/> | ||
<arg name="mavlink_tcp_port" value="4561"/> | ||
<arg name="ID" value="$(arg ID)"/> | ||
</include> | ||
<!-- 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="$(eval 1 + arg('ID'))"/> | ||
<arg name="tgt_component" value="1"/> | ||
</include> | ||
</group> | ||
<!-- UAV2 --> | ||
<group ns="uav2"> | ||
<!-- MAVROS and vehicle configs --> | ||
<arg name="ID" value="2"/> | ||
<arg name="fcu_url" default="udp://:14542@localhost:14582"/> | ||
<!-- PX4 SITL and vehicle spawn --> | ||
<include file="$(find px4)/launch/single_vehicle_spawn_sdf.launch"> | ||
<arg name="x" value="0"/> | ||
<arg name="y" value="1"/> | ||
<arg name="z" value="0"/> | ||
<arg name="R" value="0"/> | ||
<arg name="P" value="0"/> | ||
<arg name="Y" value="0"/> | ||
<arg name="vehicle" value="$(arg vehicle)"/> | ||
<arg name="mavlink_udp_port" value="14562"/> | ||
<arg name="mavlink_tcp_port" value="4562"/> | ||
<arg name="ID" value="$(arg ID)"/> | ||
</include> | ||
<!-- 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="$(eval 1 + arg('ID'))"/> | ||
<arg name="tgt_component" value="1"/> | ||
</include> | ||
</group> | ||
</launch> | ||
<!-- to add more UAVs (up to 10): | ||
Increase the id | ||
Change the name space | ||
Set the FCU to default="udp://:14540+id@localhost:14550+id" | ||
Set the malink_udp_port to 14560+id) --> |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0"?> | ||
<launch> | ||
<!-- Posix SITL environment launch script --> | ||
<!-- launchs PX4 SITL and spawns vehicle --> | ||
<!-- vehicle pose --> | ||
<arg name="x" default="0"/> | ||
<arg name="y" default="0"/> | ||
<arg name="z" default="0"/> | ||
<arg name="R" default="0"/> | ||
<arg name="P" default="0"/> | ||
<arg name="Y" default="0"/> | ||
<!-- vehcile model and config --> | ||
<arg name="est" default="ekf2"/> | ||
<arg name="vehicle" default="plane"/> | ||
<arg name="ID" default="1"/> | ||
<env name="PX4_SIM_MODEL" value="$(arg vehicle)" /> | ||
<env name="PX4_ESTIMATOR" value="$(arg est)" /> | ||
<arg name="mavlink_udp_port" default="14560"/> | ||
<arg name="mavlink_tcp_port" default="4560"/> | ||
<!-- PX4 configs --> | ||
<arg name="interactive" default="true"/> | ||
<!-- generate sdf vehicle model --> | ||
<arg name="cmd" default="xmlstarlet ed -d '//plugin[@name="mavlink_interface"]/mavlink_tcp_port' -s '//plugin[@name="mavlink_interface"]' -t elem -n mavlink_tcp_port -v $(arg mavlink_tcp_port) $(find px4)/Tools/sitl_gazebo/models/$(arg vehicle)/$(arg vehicle).sdf"/> | ||
<param command="$(arg cmd)" name="model_description"/> | ||
<!-- PX4 SITL --> | ||
<arg unless="$(arg interactive)" name="px4_command_arg1" value=""/> | ||
<arg if="$(arg interactive)" name="px4_command_arg1" value="-d"/> | ||
<node name="sitl_$(arg ID)" pkg="px4" type="px4" output="screen" args="$(find px4)/ROMFS/px4fmu_common -s etc/init.d-posix/rcS -i $(arg ID) $(arg px4_command_arg1)"> | ||
</node> | ||
<!-- spawn vehicle --> | ||
<node name="$(arg vehicle)_$(arg ID)_spawn" output="screen" pkg="gazebo_ros" type="spawn_model" args="-sdf -param model_description -model $(arg vehicle)_$(arg ID) -x $(arg x) -y $(arg y) -z $(arg z) -R $(arg R) -P $(arg P) -Y $(arg Y)"/> | ||
</launch> |
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.
This is where the magic happens.