树莓派+hokuyo激光+gmapping+navigation

来源:互联网 发布:60魔兽世界数据库 编辑:程序博客网 时间:2024/05/18 09:03

树莓派+hokuyo激光+gmapping+navigation

准备工作:

下载turtlebot_appshokuyo_node包,并编译到自己创建的工作空间。

 

1.添加hokuyo激光设备规则文件

激光插入树莓派,查看hokuyo激光的pidvid

$lsusb

可以看到有一行为:

bus 001 Device 024 :  ID 15d1:0000

如果看不出自己激光的pidvid,那就拔掉激光,再运行lsusb,看下少了哪行东东,少的那行就是激光的pidvid

那么15d1:0000就是要看的东东

然后创建规则文件,输入如下命令新建一个激光的规则:

$cd /etc/udev/rules.d

$sudo vi /50-hokuyo.rules

在新建的50-hokuyo.rules文件中输入如下内容:

KERNEL=ttyACM[0-9]*, ACTION=="add", ATTRS{idVendor}=="15d1",  MODE="0666", GROUP="dialout", SYMLINK+="hokuyo"

保存退出,(如果觉得vi不好用的话,可现在桌面建个文档,再cp过去也可以)

增加当前用户对串口的默认访问权限:

$sudo usermod -a -G dialout 用户名(我的用户名为zhy

使规则生效:

$sudo server udev reload

$sudo server udev restart

这时插上激光,则

$ls /dev

会发现多出一个hokuyo的设备名,如果没看到则重启一下。

2.turtlebot_navigation/laser目录下写一个启动激光的launch文件,文件命名为hokuyo_laser.launch

内容为:

<launch>

  <node name="hokuyo" pkg="hokuyo_node" type="hokuyo_node" respawn="false" output="screen">

  

    <!-- Starts up faster, but timestamps will be inaccurate. -->

    <param name="calibrate_time" type="bool" value="false"/>

    

    <!-- Set the port to connect to here -->

    <param name="port" type="string" value="/dev/hokuyo"/>

    <param name="frame_id" type="string" value="laser"/>

    <param name="intensity" type="bool" value="false"/>

  </node>

  

  <node name="base_to_laser" pkg="tf" type="static_transform_publisher" args="0.11 0.00 0.23 0 0.0 0.0base_link laser 100"/>

  

</launch>

3.添加建图功能

修改turtlebot_navigation/launch/gmapping_demo.launch文件,修改后的内容如下:

<launch>

 

  <!--laser driver-->

  <include file="$(find turtlebot_navigation)/laser/hokuyo_laser.launch" />

 

  <!-- Gmapping -->

  <arg name="custom_gmapping_launch_file" default="$(find turtlebot_navigation)/launch/includes/gmapping/gmapping.launch.xml"/>

  <include file="$(arg custom_gmapping_launch_file)"/>

 

  <!-- Move base -->

  <include file="$(find turtlebot_navigation)/launch/includes/move_base.launch.xml"/>

 

</launch>

3.添加导航功能

修改turtlebot_navigation/launch/amcl_demo.launch文件,修改后的内容如下:

<launch>

 

  <!--laser driver-->

  <include file="$(find turtlebot_navigation)/laser/hokuyo_laser.launch" />

 

  <!-- Map server -->

  <arg name="map_file" default="/home/zhy/map.yaml"/>

  <node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" />

 

  <!-- AMCL -->

  <arg name="custom_amcl_launch_file" default="$(find turtlebot_navigation)/launch/includes/amcl/amcl.launch.xml"/>

  <arg name="initial_pose_x" default="0.0"/> <!-- Use 17.0 for willow's map in simulation -->

  <arg name="initial_pose_y" default="0.0"/> <!-- Use 17.0 for willow's map in simulation -->

  <arg name="initial_pose_a" default="0.0"/>

  <include file="$(arg custom_amcl_launch_file)">

    <arg name="initial_pose_x" value="$(arg initial_pose_x)"/>

    <arg name="initial_pose_y" value="$(arg initial_pose_y)"/>

    <arg name="initial_pose_a" value="$(arg initial_pose_a)"/>

  </include>

 

  <!-- Move base -->

  <include file="$(find turtlebot_navigation)/launch/includes/move_base.launch.xml">

  </include>

 

</launch>

4.启动建图

启动底盘:

$roslaunch turtlebot_bringup minimal.launch

启动gmapping

$roslaunch turtlebot_navigation gmapping_demo.launch

启动rviz

$roslaunch turtlebot_rviz_launchers view_navigation.launch

保存地图:

$rosrun map_server map_saver -f /home/zhy/map

4.启动导航

将上面那些都关掉

启动底盘:

$roslaunch turtlebot_bringup minimal.launch

启动nav

$roslaunch turtlebot_navigation amcl_demo.launch

启动rviz

$roslaunch turtlebot_rviz_launchers view_navigation.launch

原创粉丝点击