I am trying to initialize the positions of my robot using Gazebo Plugins. SetPosition()
function of the Joint
class is supposed to set the joint angle (all my joints are revolute joints). However, the function doesn't do anything. The function returns false
indicating the action is unsuccessful. I have attached a simplified version of my code. I don't understand why it returns false
always. Any help is appreciated.
#include <map>
#include <functional>
#include <ignition/math/Vector3.hh>
#include <gazebo/common/common.hh>
#include <gazebo/gazebo.hh>
#include <gazebo/physics/physics.hh>
namespace gazebo {
class RobotInitialization : public ModelPlugin {
public:
void Load(physics::ModelPtr _parent, sdf::ElementPtr) {
this->model = _parent;
auto joint = this->model->GetJoint("revolute-joint");
joint->SetPosition(0, 1.0, true);
std::cout << joint->Position(0) << std::endl;
}
private:
physics::ModelPtr model;
};
GZ_REGISTER_MODEL_PLUGIN(CassieInitialization)
} // namespace gazebo
Edit:
Thanks for the suggestion. I checked the joint limits and this helped for 6 out of 16 joints on my robot. I set velocities for all joints using SetVelocity()
and that works for all the joints but SetPosition()
doesn't. I also checked DOF of the joints using joint.DOF()
and it returns 1 for all my joints.
Edit: I am using bullet as the solver.