Update model position in each timestep

asked 2023-04-09 15:33:57 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.


I'm writing a physics solver and want to integrate it into Gazebo. My current implementation is do simulation in my code and update the position of model in each timestep.

I register models with <gravity>false</gravity> to disable simulation in Gazebo and implement a world plugin. The logic of the code looks like the following.

Factory::Load() {
      this->modelPub = this->node->Advertise<msgs::Model>("~/model/modify", 10000);
      this->updateConnection = event::Events::ConnectWorldUpdateEnd(std::bind(&Factory::Step, this));
Factory::Step() {
      msgs::Model msg;
      msgs::Set(msg.mutable_pose(), modelNewPose);

The problem now is that I can feel the object moving by stopping and moving and stopping, rather than being silky smooth like a keyframe animation. It's like I'm not updating it fast enough.

I'm not sure if this isn't the correct way to implement it.

edit retag flag offensive close merge delete