-
Notifications
You must be signed in to change notification settings - Fork 776
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[ros2] Reset Simulation/World #863
Comments
I guess this has not been ported yet, but you could make use of the spawn/delete_entity services meanwhile: https://github.com/ros-simulation/gazebo_ros_pkgs/wiki/ROS-2-Migration:-Spawn-and-delete If you want reset only for model-resetting purposes: delete + spawn = reset I will be testing this right now so I will post again if I find some interesting tips. It would be a good idea to pause the simulation while this process occurs. I see this is now handled in via |
Hi Nestor, |
Can't re-spawn a complex robot.My problems come when I try to spawn the MARA back again. First, I delete the entity successfully. Then, I try to spawn the robot the same way as in this file or even using the LaunchService -> LaunchDescription containing a node that launches the same Any possible suggestion is welcomed. Working solution for simple models.The solution seems pretty simple, and works with simple gazebo models. Example: # delete the model.
delete_cli = self.node.create_client(DeleteEntity, '/delete_entity')
while not delete_cli.wait_for_service(timeout_sec=1.0):
self.node.get_logger().info('service not available, waiting again...')
delete_request = DeleteEntity.Request()
delete_request.name = "target"
future = delete_cli.call_async(delete_request)
rclpy.spin_until_future_complete(self.node, future)
# spawn the model
spawn_cli = self.node.create_client(SpawnEntity, '/spawn_entity')
while not spawn_cli.wait_for_service(timeout_sec=1.0):
self.node.get_logger().info('service not available, waiting again...')
model_xml = "<?xml version=\"1.0\"?> \
<robot name=\"myfirst\"> \
<link name=\"world\"> \
</link>\
<link name=\"cylinder0\">\
<visual>\
<geometry>\
<sphere radius=\"0.01\"/>\
</geometry>\
<origin xyz=\"0 0 0\"/>\
<material name=\"rojotransparente\">\
<ambient>0.5 0.5 1.0 0.1</ambient>\
<diffuse>0.5 0.5 1.0 0.1</diffuse>\
</material>\
</visual>\
<inertial>\
<mass value=\"5.0\"/>\
<inertia ixx=\"1.0\" ixy=\"0.0\" ixz=\"0.0\" iyy=\"1.0\" iyz=\"0.0\" izz=\"1.0\"/>\
</inertial>\
</link>\
<joint name=\"world_to_base\" type=\"fixed\"> \
<origin xyz=\"0 0 0\" rpy=\"0 0 0\"/>\
<parent link=\"world\"/>\
<child link=\"cylinder0\"/>\
</joint>\
<gazebo reference=\"cylinder0\">\
<material>Gazebo/GreenTransparent</material>\
</gazebo>\
</robot>"
spawn_request = SpawnEntity.Request()
spawn_request.name = "target"
spawn_request.xml = model_xml
spawn_request.robot_namespace = ""
spawn_request.initial_pose = self.temp_var
spawn_request.reference_frame = ""
future = spawn_cli.call_async(spawn_request) |
The reset services used to be part of @nzlz, please ticket a new issue for the spawn problems you're having. |
@LuisYordano , I can work on this later today if you haven't started yet. |
Hi @chapulina, thanks for your answer, you can start, because I am still research the new features simulation in gazebo, ros2 and rviz2. |
Done on #866 |
Hi gazebo_ros_pkgs ROS2 Team,
In ROS1 there are two services:
In ROS2 there are not these services: /gazebo/reset_simulation and /gazebo/reset_world
Could you tell me what the equivalent command is in ROS2?
Thanks in advance for your answer
The text was updated successfully, but these errors were encountered: