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

Set an instant velocity on Gazebo

asked 2017-04-06 04:53:19 -0500

shenki gravatar image


I am working on Gazebo 7 with ROS kinetic. So, here is my problem, I have that code function :

    void SetVelocity(const double &_vel)
        this->model->GetJointController()->SetVelocityTarget(this->joint->GetScopedName(), _vel);

It's used to set a velocity to my pioneer, it's working pretty well but I want the velocity to be instant. For exemple, when I set it to a velocity of 30 and then a velocity of 0, it will take so many time to stop. What are the solutions ? Here is the rest of the code :

        this->model = _model; 
        this->joint = _model->GetJoints()[0];
        this->pid = common::PID(0.1, 0, 0, 1000, -1000, 1000, -1000);
        this->model->GetJointController()->SetVelocityPID(this->joint->GetScopedName(), this->pid);

Thank in advance.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2017-04-06 09:52:06 -0500

shenki gravatar image

updated 2017-04-06 09:56:00 -0500

For the moment I found that, it's working but it's not that good...

    public: void SetVelocity(const double &_vel)
        double __vel = _vel;
        this->model->GetJointController()->SetVelocityTarget(this->joint->GetScopedName(), __vel);
        old_value = __vel;

This is stupid, so if someone has better, i'll take it, thank you !

edit flag offensive delete link more

answered 2017-04-06 09:14:51 -0500

You can set the velocity for joint directly via SetVelocity in Gazebo's Joint API, but this can lead to undesirable side-effects as the physics engine is bypassed to an extend. In my experience, applying efforts (for instance via PID control) tends to be more stable.

edit flag offensive delete link more



I tried SetVelocity and SetVelocityTarget via a joitController. The thing is if I set the velocity to 30, to pioneer will go at 30 of speed but after that, if I set velocity on 0, it won't stop, and I can't understand why, do you really think it could be better using efforts ?

shenki gravatar image shenki  ( 2017-04-06 09:29:16 -0500 )edit

Well, I just tried it, the problem is still the same, even if my pioneer is going forward, asking him to get a force of 0 doesn't make it stop

shenki gravatar image shenki  ( 2017-04-06 09:39:14 -0500 )edit

Question Tools

1 follower


Asked: 2017-04-06 04:53:19 -0500

Seen: 977 times

Last updated: Apr 06 '17