麦克纳姆轮控制模型

<u>参考文献</u>:https://zhuanlan.zhihu.com/p/20282234

image-20200717140334838

o型和x型的区别是 沿着x轴平移时的区别 把v1,3 和 v2,4 换一下方向

创建c++对象

pa_MecanumModel.h文件

#ifndef __pa_MecanumModel_H_
#define __pa_MecanumModel_H_

typedef struct
{
    float x;
    float y;
} pa_Vector;

typedef struct
{
    float angularVelocity;
    pa_Vector velocity;
} pa_KinematicsModel;

typedef struct
{
    float velocityM1;
    float velocityM2;
    float velocityM3;
    float velocityM4;
} pa_KinematicsMotorVelocities;

class pa_MecanumModel
{
public:
    pa_MecanumModel();
    pa_KinematicsModel kinematicsModel;
    void updateKinematics(float vx, float vy, float av);
    pa_KinematicsMotorVelocities calcMotorsStates();

private:
    void initModel();
    short modelW;
    short modelH;
    pa_KinematicsMotorVelocities motorVelocities;
};

#endif

pa_MecanumModel.cpp文件

#include "pa_MecanumModel.h"

void pa_MecanumModel::initModel()
{
    kinematicsModel.velocity.x = 0;
    kinematicsModel.velocity.y = 0;
    kinematicsModel.angularVelocity = 0;

    modelH = 0;
    modelW = 0;
}

pa_MecanumModel::pa_MecanumModel()
{
    initModel();
}

void pa_MecanumModel::updateKinematics(float vx, float vy, float av)
{
    this->kinematicsModel.velocity.x = vx;
    this->kinematicsModel.velocity.y = vy;
    this->kinematicsModel.angularVelocity = av;
}

pa_KinematicsMotorVelocities pa_MecanumModel::calcMotorsStates()
{
    this->motorVelocities.velocityM1 = kinematicsModel.velocity.y + kinematicsModel.velocity.x + kinematicsModel.angularVelocity * (modelW + modelH);
    this->motorVelocities.velocityM2 = kinematicsModel.velocity.y - kinematicsModel.velocity.x - kinematicsModel.angularVelocity * (modelW + modelH);
    this->motorVelocities.velocityM3 = kinematicsModel.velocity.y + kinematicsModel.velocity.x - kinematicsModel.angularVelocity * (modelW + modelH);
    this->motorVelocities.velocityM4 = kinematicsModel.velocity.y - kinematicsModel.velocity.x + kinematicsModel.angularVelocity * (modelW + modelH);
}

//如果轮子是
© 2021 hanbaoaaa record.浙ICP备20005263号
asdad
联系方式 asdasd
2021-5-8 4:19
sss
回复数 (0) 点击展开
加载更多

新增评论

称呼
联系方式
邮箱(选填)
内容

提交

取消