在RVIZ中启动移动机器人模型,并实现横向移动

本文记录了如何在ROS RVIZ环境中启动一个具有四瑞典轮的移动机器人模型,并实现了该模型的横向移动。作者通过修改diff_controller.py文件,使其能够处理额外的linear.y值,从而实现独特的运动控制。
摘要由CSDN通过智能技术生成

(转载请注明作者和出处:https://yangningbocn.github.io 未经允许请勿用于商业用途)
本博客只是个人学习记录使用,瞎写写,内容比较粗糙。编写过程中,借鉴了古月居大神的smartcar和ROS-WIKI以及其它一些大神的内容。

引入古月居大神的链接使用smartcar进行仿真smartcar源码上传

下面我针对自己的机器人编写的代码和文件。

launch文件

<launch>  

    <param name="/use_sim_time" value="false" />  

 

    <!-- Load the URDF/Xacro model of our robot -->  

    <arg name="urdf_file" default="$(find xacro)/xacro.py '$(find smartcar_description)/urdf/smartcar.urdf.xacro'" />  

    <arg name="gui" default="true" />  
    <param name="robot_description" command="$(arg urdf_file)" />  
    <param name="use_gui" value="$(arg gui)"/>  
    <node name="arbotix" pkg="arbotix_python" type="arbotix_driver" output="screen">  
        <rosparam file="$(find smartcar_description)/config/smartcar_arbotix.yaml" command="load" /> 
        <param name="sim" value="true"/>  
    </node>  

    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" >  

    </node>  

    <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher">  

        <param name="publish_frequency" type="double" value="20.0" />  

    </node>  

 

     <!-- We need a static transforms for the wheels -->  

     <node pkg="tf" type="static_transform_publisher" name="odom_left_wheel_broadcaster" args="0 0 0 0 0 0 /base_link /left_front_link 100" />  

     <node pkg="tf" type="static_transform_publisher" name="odom_right_wheel_broadcaster" args="0 0 0 0 0 0 /base_link /right_front_link 100" />  
 

    <node name="rviz" pkg="rviz" type="rviz" args="-d $(find smartcar_description)/urdf.rviz" />  

</launch>

xacro文件包括三部分:

  1. smartcar_body
<?xml version="1.0"?>  
<robot name="smartcar" xmlns:xacro="http://ros.org/wiki/xacro">  
  <xacro:property name="M_PI" value="3.14159"/>    
  <!-- Macro for SmartCar body. Including Gazebo extensions, but does not include Kinect -->  
  <xacro:include filename="$(find smartcar_description)/urdf/gazebo.urdf.xacro"/>  
  <xacro:property name="base_x" value="0.33" />  
  <xacro:property name="base_y" value="0.33" />  
  <xacro:macro name="smartcar_body">  
    <link name="base_footprint">
      <inertial>
        <mass value="0.0001" />
        <origin xyz="0 0 0" />
        <inertia ixx="0.0001" ixy="0.0" ixz="0.0"
            iyy="0.0001" iyz="0.0" 
            izz="0.0001" />
      </inertial>
      <visual>
          <origin xyz="0 0 0" rpy="0 0 0" />
          <geometry>
              <box size="0.001 0.001 0.001" />
          </geometry>
      </visual>
    </link>


    <joint name="base_footprint_joint" type="fixed">
      <origin xyz="0 0 0" rpy="0 0 0" />
      <parent link="base_footprint"/>
      <child link="base_link" />
    </joint>


    <link
    name="base_link">
    <inertial>
      <origin
        xyz="0.0032273 -0.060593 1.3595E-05"
        rpy="0 0 0" />
      <mass
        value="4.2623" />
      <inertia
        ixx="0.04568"
        ixy="-0.00094545"
        ixz="-8.9814E-06"
        iyy="0.11402"
        iyz="5.3399E-06"
        izz="0.11035" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0.23"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://smartcar_description/meshes/base_link.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="1 1 1 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0.23"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://smartcar_description/meshes/base_link.STL" />
      </geometry>
    </collision>
  </link>
  <link
    name="left_front_wheel">
    <inertial>
      <origin
        xyz="0 -1.98217916108356E-05 0"
        rpy="0 0 0" />
      <mass
        value="0.176438810476987" />
      <inertia
        ixx="8.8965933887671E-05"
        ixy="-1.27636183461175E-23"
        ixz="8.0831821149659E-23"
        iyy="8.89898462049031E-05"
        iyz="2.16519665002917E-23"
        izz="0.000130905430632044" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geome
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值