@@ -92,26 +92,28 @@ def generate_domain_bridge_config(robot_domain: int, output_dir: Path) -> Path:
9292 return config_path
9393
9494
95- def generate_world_xml (num_robots : int , package_share : str ) -> Path :
95+ def generate_world_xml (num_robots : int , package_share : str , robot_type : str ) -> Path :
9696 """Generate MuJoCo world XML with the correct number of robots."""
9797 template_path = Path (package_share ) / "xml" / "adult_field.xml"
9898 output_path = Path (package_share ) / "xml" / "generated_world.xml"
99+ offset = 6 * (1 / num_robots ) # this makes the offset be the default value when there are 4 robots and increse the less robots there are
99100
100101 with open (template_path ) as f :
101102 template = f .read ()
102103
103104 # Replace placeholder with actual robot count
104- world_xml = template .replace ("{{NUM_ROBOTS}}" , str (num_robots ))
105+ world_xml = template .replace ("{{NUM_ROBOTS}}" , str (num_robots )).replace ("{{OFFSET}}" , str (offset )).replace ("{{ROBOT_TYPE}}" , robot_type )
106+
105107
106108 with open (output_path , "w" ) as f :
107109 f .write (world_xml )
108-
109110 return output_path
110111
111112
112113def launch_setup (context ):
113114 """Dynamically set up launches based on num_robots."""
114115 num_robots = int (LaunchConfiguration ("num_robots" ).perform (context ))
116+ robot_type = str (LaunchConfiguration ("robot_type" ).perform (context ))
115117 package_share = get_package_share_directory ("bitbots_mujoco_sim" )
116118 bridge_config_dir = Path (package_share ) / "config" / "domain_bridges"
117119
@@ -122,7 +124,7 @@ def launch_setup(context):
122124 if value : # Only pass if not empty string
123125 teamplayer_args .append (f"{ arg_name } :={ value } " )
124126
125- world_file = generate_world_xml (num_robots , package_share )
127+ world_file = generate_world_xml (num_robots , package_share , robot_type )
126128
127129 actions = []
128130
@@ -188,8 +190,15 @@ def generate_launch_description():
188190 default_value = "1" ,
189191 description = "Number of robots in the simulation" ,
190192 ),
193+ DeclareLaunchArgument (
194+ "robot_type" ,
195+ default_value = "wolfgang" ,
196+ description = "Set the type of robot used (wolfgang, piplus, x02)" ,
197+ ),
191198 ]
192199
200+
201+
193202 # Add all teamplayer arguments with empty default (means use teamplayer's default)
194203 for arg_name , description in TEAMPLAYER_ARGS :
195204 declared_args .append (
0 commit comments