当前位置:网站首页>如何在gazebo进行 joint的转动控制

如何在gazebo进行 joint的转动控制

2022-08-09 10:36:00 华为云

下面总结 如何在gazebo进行 joint的转动控制

xacro文件

设置两个link

    <link name="rotate_link">        <visual>        <origin xyz="0 0 0" rpy="0 0 0" />        <geometry >            <box size="${size_rotate_link_x} ${size_rotate_link_y} ${size_rotate_link_z}" />        </geometry>            <material name="LightGray" />         </visual>        <collision>        <origin xyz="0 0 0" rpy="0 0 0" />        <geometry >            <box size="${size_rotate_link_x} ${size_rotate_link_y} ${size_rotate_link_z}" />        </geometry>        </collision>           <inertial>            <mass value="${massGain*1}"/>            <inertia ixx="${massGain*1}" ixy="0.0" ixz="0.0" iyy="${massGain*1}" iyz="0.0" izz="${massGain*1}"/>        </inertial>     </link>    <gazebo reference="rotate_link">        <material>Gazebo/Grey</material>        <turnGravityOff>true</turnGravityOff>    </gazebo>
    <link name="rotate_platform_base_link">        <visual>        <origin xyz="0 0 0" rpy="0 0 0" />        <geometry >            <box size="${size_rotate_platform_base_link_x} ${size_rotate_platform_base_link_y} ${size_rotate_platform_base_link_z}" />        </geometry>            <material name="LightGray" />         </visual>        <collision>        <origin xyz="0 0 0" rpy="0 0 0" />        <geometry >            <box size="${size_rotate_platform_base_link_x} ${size_rotate_platform_base_link_y} ${size_rotate_platform_base_link_z}" />        </geometry>        </collision>           <inertial>            <mass value="${massGain*1}"/>            <inertia ixx="${massGain*1}" ixy="0.0" ixz="0.0" iyy="${massGain*1}" iyz="0.0" izz="${massGain*1}"/>        </inertial>     </link>    <gazebo reference="rotate_platform_base_link">        <material>Gazebo/Black</material>        <turnGravityOff>true</turnGravityOff>    </gazebo>    </xacro:macro>

两个基本的link
设置完后,设置 joint

设置joint

    <joint name="rotate_joint" type="continuous">        <parent link="rotate_platform_base_link"/>        <child link="rotate_link"/>        <origin xyz="0.075 0 0.225" rpy="0 0 0" />        <axis xyz="1 0 0" />        <limit effort="10" velocity="1000" />    </joint>
  • continuous 进行速度控制 一直转
  • revolute 进行位置控制 有上下限

设置transmission

    <transmission name="rotate_joint_transmission">    <type>transmission_interface/SimpleTransmission</type>    <joint name="rotate_joint">      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>    </joint>    <actuator name="motor1">      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>      <mechanicalReduction>1</mechanicalReduction>    </actuator>    </transmission>

设置 gazebo

    <gazebo>      <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">        <robotNamespace>/rotate_platform</robotNamespace>        <controlPeriod>0.01</controlPeriod>        <robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>      </plugin>    </gazebo>

xacro设置完毕

配置yaml文件

rotate_platform:  joint_state_controller:    type: joint_state_controller/JointStateController    publish_rate: 50    rotate_velocity_controller:    type: effort_controllers/JointVelocityController    joint: rotate_joint    pid: {p: 1, i: 0.0, d: 0.0, i_clamp: 0.0}

joint的名字要和上面对应

配置launch文件

    <rosparam file="$(find slam_sensor_sim_gazebo)/config/rotate_control.yaml" command="load"/>    <node name="controller_manager" pkg="controller_manager" type="spawner" respawn="false"        output="screen" ns="/rotate_platform" args="joint_state_controller rotate_velocity_controller --shutdown-timeout 3"/>
原网站

版权声明
本文为[华为云]所创,转载请带上原文链接,感谢
https://bbs.huaweicloud.com/blogs/369447