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

Putting MPC to work with a 4-wheel omnidirectional robot?

asked 2021-01-11 08:10:38 -0500

R_B gravatar image

I am making the code based on a script from Christoph Rösmann. But I have serious doubts on how to apply the kinematics of a four-wheel omnidirectional robot to the algorithm, taking into account the input of the vector u of the controller;

// implements interface method
SystemDynamicsInterface::Ptr getInstance() const override { return std::make_shared<Omni_Model>(); }

// implements interface method
int getInputDimension() const override { return 2; }

// implements interface method
void dynamics(const Eigen::Ref<const StateVector>& x, const Eigen::Ref<const ControlVector>& u, Eigen::Ref<StateVector> f) const override
{
    assert(x.size() == getStateDimension());
    assert(u.size() == getInputDimension());
    assert(x.size() == f.size() && "Omni_Model::dynamics(): x and f are not of the same size, do not forget to pre-allocate f.");

    f[0] = u[0] * ?????
    f[1] = u[0] * ????
    f[2] = u[1]; ????
}


// implements interface method
bool getTwistFromControl(const Eigen::Ref<const Eigen::VectorXd>& u, geometry_msgs::Twist& twist) const override
{
    assert(u.size() == getInputDimension());
    twist.linear.x = u[0];
    twist.linear.y = u[0];
    twist.linear.z = 0;

    twist.angular.z = u[1];
    twist.angular.x = twist.angular.y = 0;
    return true;
}

};

edit retag flag offensive close merge delete

Comments

I don't know if I'm missing something, but what is your question?

jayess gravatar image jayess  ( 2021-01-11 18:45:44 -0500 )edit

I wanted to put the MPC developed by Christoph Rösmann with an omnidirectional robot. Link:. But I am not understanding how to connect the kinematics of the robot with the speed that is the output of the controller

R_B gravatar image R_B  ( 2021-01-12 04:29:48 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2021-01-12 14:47:50 -0500

soldierofhell gravatar image

Just write your ODE. u is control, f = \dot{x}. See examples in the repo

edit flag offensive delete link more

Comments

For exemple of Kinematic Bicycle Model

    double beta = std::atan(_lr / (_lf + _lr) * std::tan(u[1]));
    f[0] = u[0] * std::cos(x[2] + beta);
    f[1] = u[0] * std::sin(x[2] + beta);
    f[2] = u[0] * std::sin(beta) / _lr;
}

In a 4-wheel omnidirectional robot the mathematical model of kinematics is:

vx( t ) = ( ω 1 + ω 2 + ω 3 + ω 4 ) · 4/r;

vy(t) = (−ω1 + ω2 + ω3 − ω4) · 4/r;

ωz(t) = (−ω1 +ω2 −ω3 +ω4)· r/(4(lx +ly);

But I don't know the angular speed of each wheel, how do I convert the u? This is my problem !!

R_B gravatar image R_B  ( 2021-01-13 04:20:26 -0500 )edit

You've pasted some random equation without explanation what is what. If you really want some help, define exactly what is your control (u), states (x) and what is your ODE in x and u terms. I don't know what you mean by "convert the u". If that mean, how to pack it into Twist message, then it's up to you: you can do whatever you want unless your low level controller will understand it. Sorry, but if someone claims to be PhD, some precision in asking questions is required

soldierofhell gravatar image soldierofhell  ( 2021-01-13 04:53:59 -0500 )edit

For example, I'm putting into Twist message acceleration and then later convert Twist to AckermannDrive. Even in mpc_local_planner examples you have steering angle instead of angular.z

soldierofhell gravatar image soldierofhell  ( 2021-01-13 04:58:15 -0500 )edit

Sorry not to be explicit. But it is not an easy task to implement the MPC in an omnidirectional robot, and I have several questions.

R_B gravatar image R_B  ( 2021-01-28 11:19:24 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-01-11 08:10:38 -0500

Seen: 133 times

Last updated: Jan 11 '21