Quantcast
Channel: Gazebo: Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 7017

SITL Gazebo, Reset model using code

$
0
0
Hello, I am looking to reset the model position, I found that it is possible using the Edit panel in gazebo. I have tried to write several code to reset the mode automatically from the outside even being inspired by the source code of gazebo itself. However, the code I have written does not do anything. I do not know if you have an idea why it does not working. Should the code be implemented as a plugin?? or I missed something ? /* C++ Standard library include */ # include # include # include # include # include # include /* locale defined include */ # include "gazebo.hh" int main(int argc, char* argv[]) { gazebo::transport::NodePtr node(new gazebo::transport::Node()); /* start resetting the world */ gazebo::transport::PublisherPtr reset_pub; gazebo::transport::PublisherPtr userCmdPub; node->Init("iris.world"); node->GetTopicNamespace(); // ~/world_control reset_pub = node->Advertise("~/world_control"); userCmdPub = node->Advertise("~/user_cmd"); gazebo::msgs::WorldControl msg; // w_ctrl.reset(); //->set_all(true); //I believe this is equal to indicating a world reset msg.mutable_reset()->set_all(false); msg.mutable_reset()->set_time_only(false); msg.mutable_reset()->set_model_only(true); gazebo::msgs::UserCmd userCmdMsg; userCmdMsg.set_description("Reset models"); userCmdMsg.set_type(gazebo::msgs::UserCmd::WORLD_CONTROL); userCmdMsg.mutable_world_control()->CopyFrom(msg); userCmdPub->Publish(userCmdMsg); reset_pub->Publish(msg); }

Viewing all articles
Browse latest Browse all 7017

Trending Articles