Mobile robot chassis - four-wheel differential model (four independent wheels)

Mobile Robot Chassis - Four Wheel Differential Model

insert image description here

1. Principle of four-wheel differential model

An example of a four-wheel differential model chassis is shown in the figure below. For the front and rear wheels of the chassis, their speeds are synchronous, so under ideal conditions, the chassis motion can be regarded as a circular motion with the ICR as the center, and for the four wheels, the angular speed of the circular motion is consistent , the circular motion center ICR is always located on the y-axis extension line of the chassis geometric center COG, the distance between ICR and COG dc d_cdcConstrained, constrained and circular motion angular velocity ω c \omega_cohcRelated, the speed of the entire chassis is located at the velocity center COM, and vc v_c is usedvcIndicates that the instantaneous center velocity vc v_cvcBy component vcx v_{cx}vcxvcy v_{cy}vcySynthesis, set the speed of the four wheels as v 1 v_1v1v 2 v_2v2v 3 v_3v3v 4 v_4v4, which are determined by the preset target velocity vix v_{ix}vixand the lateral sliding velocity viy v_{iy}viyComposite ( i = 1 , 2 , 3 , 4 ) (i=1,2,3,4)i=1,2,3,4 ) , let the wheelbase between the left wheel and the right wheel beccc .
insert image description here
The angular velocity formula of circular motion is shown in formula 1.
ω c = vcdc (1) ω_c=\frac{v_c}{d_c}\tag{1}ohc=dcvc( 1 )
whereω c \omega_cohcis the angular velocity of circular motion, and the linear velocity is vc v_cvc, the radius of circular motion is ddd . letdc d_cdcThe angle with the y-axis is α c \alpha_cac, by vc v_cvcThe vertical relationship with ICR-COM can be vccos α c = vcx v_ccos\alpha_c=v_{cx}vccos αc=vcxfrom vcsin α c = vcy v_csin\alpha_c=v_{cy}vcs in αc=vcy,One of the following 2-dimensional functions:
ω c = vcdc = vccos α cdccos α c = vcxdcy ω c = vcdc = vcsin α cdcsin α c = vcydcx (2) \omega_c=\frac{v_c}{d_c}=\ frac{v_ccos\alpha_c}{d_ccos\alpha_c}=\frac{v_{cx}}{d_{cy}}\\ ω_c=\frac{v_c}{d_c}=\frac{v_csinα_c}{d_csinα_c}=\frac {v_{cy}}{d_{cx}}\tag{2}ohc=dcvc=dccos αcvccos αc=dcyvcxohc=dcvc=dcs in αcvcs in αc=dcxvcy( 2 )
From the condition that the angular velocities of the four wheels of the rotating rigid body are consistent, Equation 2 can be generalized to Equation 3:
ω c = vidi = vicos α idicos α i = vixdiy ω c = vidi = visin α idisin α i = viydix ( 3) \omega_c=\frac{v_i}{d_i}=\frac{v_icos\alpha_i}{d_icos\alpha_i}=\frac{v_{ix}}{d_{iy}}\\ ω_c=\frac{v_i} {d_i}=\frac{v_isinα_i}{d_isinα_i}=\frac{v_{iy}}{d_{ix}}\tag{3}ohc=divi=dicos αivicos αi=diyvixohc=divi=dis in αivis in αi=dixviy(3)
由式2和3得式4:
ω c = v c d c = v c x d c y = c c y d c x = v i x d i y = v i y d i x , ( i = 1 , 2 , 3 , 4 ) (4) ω_c=\frac{v_c}{d_c}=\frac{v_{cx}}{d_{cy}}=\frac{c_{cy}}{d_{cx}}=\frac{v_{ix}}{d_{iy}}=\frac{v_{iy}}{d_{ix}},(i=1,2,3,4)\tag{4} ohc=dcvc=dcyvcx=dcxccy=diyvix=dixviy,(i=1,2,3,4)( 4 )
At the same time,di d_idi(where i = 1, 2, 3, 4 i=1,2,3,4i=1,2,3,4 ) withdc d_cdcThe projection length on the x-axis and y-axis satisfies formula 5:
d 1 y = d 2 y = dcy − c 2 d 3 y = d 4 y = dcy + c 2 (5) d_{1y}=d_{2y} =d_{cy}-\frac{c}{2}\\ d_{3y}=d_{4y}=d_{cy}+\frac{c}{2}\tag{5}d1 the=d2 y=dcy2cd3 y=d4y=dcy+2c( 5 )
The four-wheel differential chassis sets the speeds of the left wheel and the right wheel asVL V_LVLand VR V_RVR, and in the case that the speeds of the front and rear wheels are strictly synchronized, constraints such as formula 6 can be established:
VL = v 1 x = v 2 x VR = v 3 x = v 4 x (6) V_L=v_{1x} =v_{2x}\\ V_R=v_{3x}=v_{4x}\tag{6}VL=v1x=v2 xVR=v3x _=v4x _( 6 )
combination of 4、5、6可得式7 shows conclusion:
VL = ω c ⋅ ( dcy − c 2 ) = ω cdcy − ω c ⋅ c 2 = vcx − ω c ⋅ c 2 VR = ω c ⋅ ( dcy + c 2 ) = ω cdcy + ω c ⋅ c 2 = vcx + ω c ⋅ c 2 (7) V_L=\omega_c\cdot(d_{cy}-\frac{c}{2})=\ omega_cd_{cy}-\omega_c\cdot\frac{c}{2}=v_{cx}-\omega_c\cdot\frac{c}{2}\\ V_R=ω_c⋅(d_{cy}+\frac{ c}{2})=ω_cd_{cy}+ω_c⋅\frac{c}{2}=v_{cx}+ω_c⋅\frac{c}{2}\tag{7}VL=ohc(dcy2c)=ohcdcyohc2c=vcxohc2cVR=ohc(dcy+2c)=ohcdcy+ohc2c=vcx+ohc2c( 7 )
Arrange Equation 7 and express it in the form of matrix multiplication to obtain the forward kinematics relationship of the four-wheel differential chassis, as shown in Equation 8: [ vcx ω c ] =
[ 1 2 1 2 − 1 c − 1 c ] [ VLVR ] (8) \left[\begin{array}{l} v_{cx} \\ \omega_{c} \end{array}\right]=\left[\begin{array}{cc } \frac{1}{2} & \frac{1}{2} \\ -\frac{1}{c} & -\frac{1}{c} \end{array}\right]\left[ \begin{array}{l} V_{L} \\ V_{R} \end{array}\right]\tag{8}[vcxohc]=[21c121c1][VLVR]( 8 )
Then the inverse kinematics formula can be obtained only by simple inverse transformation. The inverse kinematics model of the four-wheel differential is shown in formula 9:
[ VLVR ] = [ 1 − c 2 1 c 2 ] [ vcx ω c ] (9) \left[\begin{array}{l} V_{L} \\ V_{R} \end{array}\right]=\left[\begin{array}{cc} 1 & -\ frac{c}{2} \\ 1 & \frac{c}{2} \end{array}\right]\left[\begin{array}{l} v_{cx} \\ \omega_{c} \ end{array}\right]\tag{9}[VLVR]=[112c2c][vcxohc](9)

2. Engineering practice

2.1 Python implementation

import numpy as np

def forward_kinematics(vl, vr, d):
    """
    正向运动学模型:根据轮子速度计算机器人的运动

    参数:
    vl: 左侧轮子的速度
    vr: 右侧轮子的速度
    d: 轮子间距

    返回:
    x: 机器人的x坐标
    y: 机器人的y坐标
    theta: 机器人的角度(弧度)
    """
    R = d / 2.0
    omega = (vr - vl) / (2.0 * R)
    v = (vl + vr) / 2.0

    x = 0.0
    y = 0.0
    theta = 0.0

    if abs(omega) < 1e-10:
        x = v * np.cos(theta)
        y = v * np.sin(theta)
    else:
        ICC_x = x - R * np.sin(theta)
        ICC_y = y + R * np.cos(theta)
        x = np.cos(omega) * (x - ICC_x) - np.sin(omega) * (y - ICC_y) + ICC_x
        y = np.sin(omega) * (x - ICC_x) + np.cos(omega) * (y - ICC_y) + ICC_y
        theta = theta + omega

    return x, y, theta


def inverse_kinematics(x, y, theta, d):
    """
    逆向运动学模型:根据机器人的位置和角度计算轮子的速度

    参数:
    x: 机器人的x坐标
    y: 机器人的y坐标
    theta: 机器人的角度(弧度)
    d: 轮子间距

    返回:
    vl: 左侧轮子的速度
    vr: 右侧轮子的速度
    """
    R = d / 2.0

    vl = (2 * x - theta * d) / (2 * R)
    vr = (2 * x + theta * d) / (2 * R)

    return vl, vr


# 示例使用
vl = 2.0  # 左前轮速度
vr = 3.0  # 右前轮速度
vlr = -1.0  # 左后轮速度
vrr = 2.5  # 右后轮速度
d = 0.5  # 轮子间距

# 正向运动学
x, y, theta = forward_kinematics(vl, vr, d)
print("机器人的位置:(x={}, y={}), 角度:{}".format(x, y, theta))

# 逆向运动学
vl, vr = inverse_kinematics(x, y, theta, d)
print("左前轮速度:{}, 右前轮速度:{}".format(vl, vr))

2.2 C++ implementation

#include <iostream>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/assignment.hpp>
#include <boost/numeric/ublas/operation.hpp>
#include <boost/numeric/ublas/io.hpp>

namespace ublas = boost::numeric::ublas;

// 正向运动学模型
ublas::vector<double> forward_kinematics(double vl, double vr, double d) {
    
    
    double R = d / 2.0;
    double omega = (vr - vl) / (2.0 * R);
    double v = (vl + vr) / 2.0;

    ublas::vector<double> pose(3);
    pose[0] = 0.0;  // x
    pose[1] = 0.0;  // y
    pose[2] = 0.0;  // theta

    if (std::abs(omega) < 1e-10) {
    
    
        pose[0] = v * std::cos(pose[2]);
        pose[1] = v * std::sin(pose[2]);
    } else {
    
    
        double ICC_x = pose[0] - R * std::sin(pose[2]);
        double ICC_y = pose[1] + R * std::cos(pose[2]);
        pose[0] = std::cos(omega) * (pose[0] - ICC_x) - std::sin(omega) * (pose[1] - ICC_y) + ICC_x;
        pose[1] = std::sin(omega) * (pose[0] - ICC_x) + std::cos(omega) * (pose[1] - ICC_y) + ICC_y;
        pose[2] += omega;
    }

    return pose;
}

// 逆向运动学模型
ublas::vector<double> inverse_kinematics(double x, double y, double theta, double d) {
    
    
    double R = d / 2.0;

    ublas::vector<double> wheel_velocities(2);
    wheel_velocities[0] = (2 * x - theta * d) / (2 * R);
    wheel_velocities[1] = (2 * x + theta * d) / (2 * R);

    return wheel_velocities;
}

int main() {
    
    
    double vl = 2.0;  // 左前轮速度
    double vr = 3.0;  // 右前轮速度
    double vlr = -1.0;  // 左后轮速度
    double vrr = 2.5;  // 右后轮速度
    double d = 0.5;  // 轮子间距

    // 正向运动学
    ublas::vector<double> pose = forward_kinematics(vl, vr, d);
    std::cout << "机器人的位置:(x=" << pose[0] << ", y=" << pose[1] << "), 角度:" << pose[2] << std::endl;

    // 逆向运动学
    ublas::vector<double> wheel_velocities = inverse_kinematics(pose[0], pose[1], pose[2], d);
    std::cout << "左前轮速度:" << wheel_velocities[0] << ", 右前轮速度:" << wheel_velocities[1] << std::endl;

    return 0;
}

Guess you like

Origin blog.csdn.net/qq_38853759/article/details/131278439