Robot simulation-Arbotix+rviz

table of Contents

1. Introduction to Arbotix

  • A hardware control board for controlling motors and steering gears;
  • Provide the corresponding ROS function package;
  • A differential speed controller is provided to update the odometer status of the robot by receiving speed control commands.

Two, Arbotix installation

instruction

cd ~/catkin_ws/src
sudo git clone git://github.com/vanadiumlabs/arbotix_ros.git

Insert picture description here
Back to the workspace to compile

cd ~/catkin_ws
catkin_make

Insert picture description here
An error occurs during compilation, as shown in the figure
Insert picture description here
Query error
/home/zxw/catkin_ws/src/learning_communication/src/listener.cpp:4:28: error: ‘std_mmsgs’ does not name a type void chatterCallback(const std_mmsgs::String::ConstPtr& msg)

Error:'std_mmsgs' does not specify a type
const std_mmsgs::String:: consttr&msg does not specify a type

Enter the file directory according to the error prompt to modify and
Insert picture description here
re-run the command compilation, and
Insert picture description here
after the result is resolved, the compilation can be successful.

In fact, I don't know that there will be more than one m. Generally, there will be a corresponding position in the error message, and it is enough to modify the error message.

Three, the corresponding configuration

Configure the launch-urdf file

cd ~/catkin_ws/src/mbot_description/urdf
mkdir xacro
cd xacro
sudo gedit mbot_with_camera.xacro

Insert picture description here
Paste the following code into the text

<?xml version="1.0"?>
<robot name="mbot" xmlns:xacro="http://www.ros.org/wiki/xacro">
    <xacro:property name="M_PI" value="3.1415926"/>
    <xacro:property name="base_radius" value="0.20"/>
    <xacro:property name="base_length" value="0.16"/>

    <xacro:property name="wheel_radius" value="0.06"/>
    <xacro:property name="wheel_length" value="0.025"/>
    <xacro:property name="wheel_joint_y" value="0.19"/>
    <xacro:property name="wheel_joint_z" value="0.05"/>

    <xacro:property name="caster_radius" value="0.015"/> 
    <xacro:property name="caster_joint_x" value="0.18"/>
    <xacro:property name="camera_joint_x" value="0.17"/>
	<xacro:property name="camera_joint_z" value="0.10"/>
    <material name="yellow">
        <color rgba="1 0.4 0 1"/>
    </material>
    <material name="black">
        <color rgba="0 0 0 0.95"/>
    </material>
    <material name="gray">
        <color rgba="0.75 0.75 0.75 1"/>
    </material>
    <xacro:macro name="wheel" params="prefix reflect">
        <joint name="${prefix}_wheel_joint" type="fixed">
            <origin xyz="0 ${reflect*wheel_joint_y} ${-wheel_joint_z}" rpy="0 0 0"/>
            <parent link="base_link"/>
            <child link="${prefix}_wheel_link"/>
            <axis xyz="0 1 0"/>
        </joint>

        <link name="${prefix}_wheel_link">
            <visual>
                <origin xyz="0 0 0" rpy="${M_PI/2} 0 0" />
                <geometry>
                    <cylinder radius="${wheel_radius}"  length = "${wheel_length}"/>
                </geometry>
                <material name="gray" />
            </visual>
        </link>
    </xacro:macro>
    <xacro:macro name="caster" params="prefix reflect">
        <joint name="${prefix}_caster_joint" type="fixed">
            <origin xyz="${reflect*caster_joint_x} 0 ${-(base_length/2 + caster_radius)}" rpy="0 0 0"/>
            <parent link="base_link"/>
            <child link="${prefix}_caster_link"/>
            <axis xyz="0 1 0"/>
        </joint>

        <link name="${prefix}_caster_link">
            <visual>
                <origin xyz="0 0 0" rpy="0 0 0"/>
                <geometry>
                    <sphere radius="${caster_radius}" />
                </geometry>
                <material name="black" />
            </visual>
        </link>
    </xacro:macro>
	<xacro:macro name="camera" params="prefix reflect">
        <joint name="camera_joint" type="fixed">
            <origin xyz="${camera_joint_x} 0 ${camera_joint_z}" rpy="0 0 0"/>
            <parent link="base_link"/>
            <child link="camera_link"/>
        </joint>

        <link name="camera_link">
            <visual>
	            <origin xyz=" 0 0 0 " rpy="0 0 0" />
	            <geometry>
	                <box size="0.03 0.04 0.04" />
	       
	            </geometry>
	            <material name="black"/>
	        </visual>
        </link>
    </xacro:macro>
    <!--定义主体base -->
        <xacro:macro name="mbot_base">  
        <link name="base_footprint"> 
            <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 ${base_length/2 + caster_radius*2}" rpy="0 0 0" />        
            <parent link="base_footprint"/>
            <child link="base_link" />
        </joint>

        <link name="base_link">
            <visual>
                <origin xyz=" 0 0 0" rpy="0 0 0" />
                <geometry>
                    <cylinder length="${base_length}" radius="${base_radius}"/>
                </geometry>
                <material name="yellow" />
            </visual>
        </link>

        <wheel prefix="left" reflect="-1"/> 
        <wheel prefix="right" reflect="1"/> 

        <caster prefix="front" reflect="-1"/> 
        <caster prefix="back" reflect="1"/> 
        <camera/>
    </xacro:macro>
</robot>

instruction

sudo gedit mbot.xacro

Same as above

<?xml version="1.0"?>
<robot name="arm" xmlns:xacro="http://www.ros.org/wiki/xacro">
    <xacro:include filename="$(find mbot_description)/urdf/xacro/mbot_base.xacro" /> 
    <mbot_base/>    
</robot>

instruction

cd ~/catkin_ws/src/mbot_description/launch/xacro
sudo gedit arbotix_mbot_with_camera_xacro.launch

Insert picture description here

Same as above

<launch>
	<arg name="model" default="$(find xacro)/xacro --inorder '$(find mbot_description)/urdf/xacro/mbot.xacro'" />
	<arg name="gui" default="false" />
	<param name="robot_description" command="$(arg model)" />
	<param name="use_gui" value="$(arg gui)"/>
	<node name="arbotix" pkg="arbotix_python" type="arbotix_driver" output="screen">        
        <rosparam file="$(find mbot_description)/config/fake_mbot_arbotix.yaml" command="load" />
        <param name="sim" value="true"/>
    </node>
	<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
	<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
	<node name="rviz" pkg="rviz" type="rviz" args="-d $(find mbot_description)/config/mbot_arbotix.rviz" required="true" />
</launch>

Configure controller parameters

cd ~/catkin_ws/src/mbot_description/config
sudo gedit fake_mbot_arbotix.yaml

Insert picture description here
document content

controllers: {
    
    
   base_controller: {
    
    
       type: diff_controller, 
       base_frame_id: base_footprint, 
       base_width: 0.26, 
       ticks_meter: 4100, 
       Kp: 12, 
       Kd: 12, 
       Ki: 0, 
       Ko: 50, 
       accel_limit: 1.0 
    }
}

Four, simulation demonstration

Start the simulation

roslaunch mbot_description arbotix_mbot_with_camera_xacro.launch 

Set according to the figure to
Insert picture description here
Insert picture description here
start the control node

roslaunch mbot_teleop mbot_teleop.launch

Insert picture description here
If an error message appears, the solution is as follows:
execute the command

export |grep ROS

Insert picture description here
Download the corresponding feature pack
https://gitee.com/harrietlh/mbot_teleop/tree/master/mbot_teleop .
The downloaded file into the ~ /catkin_ws/srcdirectory, in ~/catkin_wsthe nextcatkin_make
Insert picture description here

  • The corresponding software package is not installed, check if there is a corresponding software package in your src folder
  • You can use the tab key to automatically complete the package name when you enter the package name and launch file name incorrectly.
  • There is a problem with the environment variable setting. Have you executed it before executing roslaunch source/opt/ros/kinetic/setup.bash(take the kinetic version as an example) and source your workspace. If it is ~/.bashrcto change the environment variable by modifying the file. The corresponding modification will not take effect until a command line window is reopened. You can use roscd your package to test whether there is a problem with the environment variables. If it is normal, then you should be able to access your own software package in this way.
  • Not a valid ROS package such as a ROS package written by myself, but no CMakeLists.txtfiles and package.xmlfiles are added

链接里面的网站还需要注册,挺麻烦的,这里有我弄好的,分享到网盘,有需要的可以自行下载

https://pan.baidu.com/s/1UXRAX34wDkNYaqPQjVBhjg .
Extraction code:a98g

Compile again to view the result, the instruction is like a red box
Insert picture description here
Insert picture description here

The error is resolved.
Demonstration effect
![Insert picture description here](https://img-blog.csdnimg.cn/20210321011506673.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0LFF_size

Five, summary and reference materials

1. Summary

Arbotix is ​​a very important entry-level simulation simulator. We can implement navigation and positioning on arbotix and realize basic functions in the simulation environment.

2. Reference materials

Successfully resolved ROS error RLException: [turtlebot3_fake.launch] is neither a launch file in package [turtlebot3_fake] .
ArbotiX+rviz function simulation .

Guess you like

Origin blog.csdn.net/QWERTYzxw/article/details/115031716