Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to get the position of a model in World plugin

I have this code in my World plugin:

    // Called by the world update start event
    public: void OnUpdate(const common::UpdateInfo & /*_info*/) 
            auto model = myWorldPtr->ModelByName("robot1");
            if (model != NULL)
                ignition::math::Pose3d position = model->WorldPose();
                ignition::math::Vector3d pos = position.Pos();

                ROS_INFO("TeleopRobot::joyCallback -> linear.x: %d", pos.X());

but pos.X() has always the same value although my model is moving.

I have seen previous solutions here, but neither of them works. I just want to know where my model is while moving.

Any ideas?