replace string in ros2 launch command xacro
Hi all, i need to replace a string in an urdf after the xacro command is executed. In the launcher, I load the xacro like this:
robot_description_content_1 = Command(
[
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
PathJoinSubstitution([FindPackageShare(description_package), "urdf", description_file]),
" ","safety_limits:=",safety_limits,
" ","safety_pos_margin:=",safety_pos_margin,
" ","safety_k_position:=",safety_k_position,
" ","name:=","ur1",
" ","ur_type:=",ur_type,
" ","prefix:=","sweepee_1/",
" ","prefix_rc:=","sweepee_1",
" ","simulation_controllers:=",initial_joint_controllers_1,
" ","use_fake_hardware:=",use_fake_hardware,
" ","sim_gazebo:=",sim_gazebo,
" ","sim_ignition:=",sim_ignition,
]
)
robot_description_1 = {"robot_description": robot_description_content_1}
After loading it , I need to replace a keyword with another.
The problem is that the command is not yet a string and I don't know how to act on it.
I would use the xacro package directly but I have a lot of PathJoinSubstitution, and I cant deal with them in the xacro.
Is there a way to do this ?
Thanks
Asked by muttidrhummer on 2023-05-17 04:10:31 UTC
Comments
Do you need to change this keyword in the launcher? Maybe you could add a parameter callback to dynamically change the node parameters. Perhaps use of the
OpaqueFunction
can help if you have to do this change in the launcher?Asked by ljaniec on 2023-05-17 05:32:57 UTC
I will take a look at the OpaqueFunction, but the problem I'm having is that I need to put
in my urdf, and xacro wont allow "ignition:", I wanted to substitute it later.
Asked by muttidrhummer on 2023-05-17 05:42:47 UTC
Take a look at xacro block parameters if you're planning on customizing the URDF robot description anyway
Asked by danzimmerman on 2023-05-20 13:41:33 UTC