ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to reset a gazebo world including actors positions

asked 2022-02-17 05:07:33 -0500

Hello there, community. I've created a gazebo simulation world with five human actors. I'd want to reset the simulation and the world, as well as each actor's position. However, after calling the reset simulation and reset world ros services, the actor plugin no longer works, and the actors remain stucked and overlapping one another. Is it possible to reset everything in Gazebo, including the actors' plugin?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2022-02-19 04:45:51 -0500

Dear community, the problem is solved by simply calling the ActorPlugin->Reset() inside the plugin (C++) source code. Do not forget to change the etiquette of the the Reset() method from protected: to public: so that it will be callable by the outside. Finally, calling the /gazebo/reset_simulation rosservice will result in resetting the plugin that controls those actors.

edit flag offensive delete link more

Comments

1

Thank you for sharing!

osilva gravatar image osilva  ( 2022-02-19 07:50:33 -0500 )edit

where do you set the Reset() function. Could you kindly elaborate. I am facing the same issue.

Hirak231992 gravatar image Hirak231992  ( 2022-09-27 09:35:15 -0500 )edit

Hi, you have to just override it just define the function inside your plugin source code :

void pluginClass::Reset() { ....... Do here whatever you want to reset anything .... .... }

seif_seghiri gravatar image seif_seghiri  ( 2022-09-27 09:44:56 -0500 )edit

I have updated the mass of the object in runtime by writing a custom modelplugin. Could you kindly suggest where I should place my overriding function. I have attached the code and asked for it in the forum too. I would be very grateful if you could kindly see it.

link text

Hirak231992 gravatar image Hirak231992  ( 2022-09-27 12:50:21 -0500 )edit

put this definition on the source file (your_plugin.cpp)

void yourPluginClass::Reset() { ...... }

after adding this to the class public virtual methods declaration:

public: virtual void Reset();
seif_seghiri gravatar image seif_seghiri  ( 2022-09-28 04:50:25 -0500 )edit
0

answered 2022-02-17 06:34:31 -0500

osilva gravatar image

Please take a look at this prior answer, I think that's what you are looking for:

https://answers.ros.org/question/2669...

import rospy
from std_srvs.srv import Empty

rospy.init_node('reset_world')

rospy.wait_for_service('/gazebo/reset_world')
reset_world = rospy.ServiceProxy('/gazebo/reset_world', Empty)

reset_world()
edit flag offensive delete link more

Comments

Thank you osliva I already used this to reset the world but the problem is with gazebo actors. They get stuck the moment i reset the world and they never start moving again.

seif_seghiri gravatar image seif_seghiri  ( 2022-02-17 06:56:20 -0500 )edit

And are you using /gazebo/reset_simulation as well?

osilva gravatar image osilva  ( 2022-02-17 07:04:00 -0500 )edit

Yeah, I guess i have to reset the plugin that controls the actors in the simulation somehow!

seif_seghiri gravatar image seif_seghiri  ( 2022-02-17 07:06:55 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-02-17 05:07:33 -0500

Seen: 1,379 times

Last updated: Feb 19 '22