重点检查下小车的惯性矩阵相关设置值
我之前遇到过相关值设置的不对,小车出现倾斜并绕自身中心轴旋转
环境为ubuntu16.04 + ros kinetic
自己通过xacro搭建的2个驱动轮,2个万向随动轮的小车
注意,惯性矩阵最好用一个单独的xacro,然后通过
<xacro:include filename="inertial_matrix_algorithm.xacro" />
进行调用
mrobot.xacro如下:
<robot name="mrobot" xmlns:xacro="http://www.ros.org/wiki/xacro">
<xacro:include filename="inertial_matrix_algorithm.xacro" /> <xacro:include filename="base.xacro" /> <xacro:include filename="camera.xacro" /> <xacro:include filename="laser.xacro" /></robot>
惯性矩阵 计算xacro文件如下:
<robot name="inertial_matrix_algorithm" xmlns:xacro="http://www.ros.org/wiki/xacro">
<xacro:macro name="sphere_inertial_matrix" params="m r"> <inertial> <mass value="${m}" /> <inertia ixx="${2*m*r*r/5}" ixy="0" ixz="0" iyy="${2*m*r*r/5}" iyz="0" izz="${2*m*r*r/5}" /> </inertial> </xacro:macro> <xacro:macro name="cylinder_inertial_matrix" params="m r l"> <inertial> <mass value="${m}" /> <inertia ixx="${m*(3*r*r+l*l)/12}" ixy="0" ixz="0" iyy="${m*(3*r*r+l*l)/12}" iyz="0" izz="${m*r*r/2}" /> </inertial> </xacro:macro> <xacro:macro name="box_inertial_matrix" params="m l w h"> <inertial> <mass value="${m}" /> <inertia ixx="${m*(h*h + l*l)/12}" ixy="0" ixz="0" iyy="${m*(w*w + l*l)/12}" iyz="0" izz="${m*(w*w + h*h)/12}" /> </inertial> </xacro:macro></robot>