|
Hello,
Is it possible to change the name of a Solid by modifying the name field of the robot?
I have the following robot PROTO:
#VRML_SIM R2023b utf8 # license: Apache License 2.0 # license url: http://www.apache.org/licenses/LICENSE-2.0 # This is a proto file for Webots for the rbrobout # template language: javascript # Extracted from: /home/joel/Documentos/GitHub/Robotnik_practicas/Robotnik_ws/src/robot_description/robots/rbrobout/rbrobout.urdf
PROTO rbrobout [ field SFVec3f translation 0 0 -0.49 field SFRotation rotation 0 0 1 0 field SFString name "rbrobout" # Is `Robot.name`. field SFString controller "" # Is `Robot.controller`. field MFString controllerArgs [] # Is `Robot.controllerArgs`. field SFString customData "" # Is `Robot.customData`. field SFBool supervisor FALSE # Is `Robot.supervisor`. field SFBool synchronization TRUE # Is `Robot.synchronization`. field SFBool selfCollision FALSE # Is `Robot.selfCollision`. field MFNode toolSlot [] # Extend the robot with new nodes at the end of the arm. ] { Robot { translation IS translation controller IS controller physics Physics { } children [ Shape { appearance PBRAppearance { baseColor 0.5 0.5 0.5 roughness 1 metalness 0 } geometry Box { size 0.001 0.001 0.001 } } Solid {........
And, in that PROTO, i have this field:
Solid { translation -0.8 -0.3666 -0.06 rotation 0 0 -1 2.356194 children [ USE microscan3_visual Solid { translation 0 0 0.11 children [ Lidar { name "robot_rear_laser_sensor" horizontalResolution 700 fieldOfView 4.7 numberOfLayers 1 minRange 0.05 maxRange 64 noise 0.000156 resolution 0.00575 } ] name %<= fields.name.value + "/rear_laser_link" >% } ] name %<= fields.name.value + "/rear_laser_base_link" >% boundingObject USE microscan3 physics Physics { density -1 mass 1.15 centerOfMass [ 0 0 0.075 ] inertiaMatrix [ 0.003337012 0.003358383 0.002382896 0 0 0 ] } } ]
Then, I'm trying to spawn the PROTO using this service call in a Python launcher:
spawn_robot_service_call = ExecuteProcess( cmd=[ 'ros2', 'service', 'call', '/Ros2Supervisor/spawn_node_from_string', 'webots_ros2_msgs/srv/SpawnNodeFromString', [ TextSubstitution(text='{data: "'), robot, TextSubstitution(text=' { name \\"'), namespace, TextSubstitution(text='\\" translation '), x_pos, TextSubstitution(text=' '), y_pos, TextSubstitution(text=' '), z_pos, TextSubstitution(text=' }"}') ] ], output='screen' ) ld.add_action(spawn_robot_service_call)
However, Webots logs this error:
:576:20: error: Expected string literal, found 'rbrobout/rear_laser_link'.
I'm not sure if I wrote the name assignment incorrectly, or if it's just not possible to dynamically assign unique Solid names using string concatenation like this.
I need to do this because I want to spawn multiple instances of the same PROTO robot in the simulation, each with a different name.
The TFs are being published by the WebotsController with 'set_robot_state_publisher':
rbrobout_driver = WebotsController( robot_name='rbrobout', namespace='rbrobout', parameters=[ {'robot_description': robot_controller_path, 'use_sim_time': use_sim_time, 'set_robot_state_publisher': True, 'update_rate': 100}, ros2_control_params ], respawn=True ) ld.add_action(rbrobout_driver)
|