ubuntu20 ros kobuki全纪录

  • 安装ros noetic
  • 安装kobuki
  • 双目相机
  • 安装IMU ros
  • 安装激光雷达ust-10lx
  • 安装map_server
  • 建图
  • 保存地图
  • 导航

安装ros noetic

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'

sudo apt install curl # if you haven't already installed curl

curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

sudo apt update

sudo apt install ros-noetic-desktop-full

echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc

source ~/.bashrc

sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential

sudo rosdep init

rosdep update

https://blog.csdn.net/qq_43725844/article/details/104296793
http://wiki.ros.org/noetic/Installation/Ubuntu

安装kobuki

mkdir -p kobuki_ws/src
cd kobuki_ws
catkin_make

https://gitcode.net/weixin_38221101/kobuki 复制三个文件到src里

kobuki_keyop
kobuki_node
kobuki_safety_controller

https://gitee.com/jack-richer/yujin_ocs_noetic_devel/tree/master/yujin_ocs-0.8.2 复制一个文件到src里

yocs-controllers
sudo apt install ros-noetic-kobuki* ros-noetic-ecl-streams

连接kobuki, 配置udev别名

rosrun kobuki_ftdi create_udev_rules

查看是否有kobuki

ls /dev

编译

cd kobuki_ws
catkin_make

运行kobuki节点

source devel/setup.bash
roslaunch kobuki_node minimal.launch

新建终端,操控kobuki

cd kobuki_ws
source devel/setup.bash
roslaunch kobuki_keyop keyop.launch

https://blog.csdn.net/weixin_43563233/article/details/113046351

双目相机

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE

sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u

sudo apt-get install librealsense2-dkms

sudo apt-get install librealsense2-utils

sudo apt-get install librealsense2-dev

sudo apt-get install librealsense2-dbg

测试

realsense-viewer

打开左侧开关就能看到了。


安装ros版

sudo apt-get install ros-$ROS_DISTRO-realsense2-camera

roscd realsense2_camera
cd launch
sudo gedit  rs_camera.launch

修改此文件

  "depth_width"         default="640"/>
  "depth_height"        default="480"/>
  
  "color_width"         default="640"/>
  "color_height"        default="480"/>

  "enable_sync"               default="true"/>
  "align_depth"               default="true"/>

启动相机

roslaunch realsense2_camera rs_camera.launch

https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md
https://blog.csdn.net/weixin_43563233/article/details/119118122
https://github.com/IntelRealSense/realsense-ros

安装IMU ros

sudo apt install ros-noetic-imu-filter-madgwick

安装激光雷达ust-10lx

sudo apt install ros-noetic-urg-node

查看网卡ipmaddr

sudo gedit /etc/network/interfaces

加入

    auto eth0  
    allow-hotplug eth0  
    iface eth0 inet static  
          address 192.168.0.20  
          netmask 255.255.255.0 

注意,eth0为网桥,如果interfaces里用了eth0,那就找ipmaddr里其他的网桥(避开wifi)

测一下

ping 192.168.0.10
roscore
rosrun urg_node urg_node _ip_address:=192.168.0.10

注意,ping和ros用10,之前的文件不能是10

安装map_server

sudo apt-get install ros-noetic-tf2-sensor-msgs

https://github.com/ros-planning/navigation 把里面的map_server下载到src里,catkin_make
如果缺东西,就这么干

rosdep where-defined sdl #打开链接找对应的东西
sudo apt-get install libsdl1.2-dev
sudo apt-get install libsdl-image1.2-dev
catkin_make
source devel/setup.bash

https://blog.csdn.net/banzhuan133/article/details/88998433
http://wiki.ros.org/map_server

建图

安装rtabmap

sudo apt install ros-noetic-rtabmap-ros

启动相机和IMU

roslaunch realsense2_camera rs_camera.launch \
    align_depth:=true \
    unite_imu_method:="linear_interpolation" \
    enable_gyro:=true \
     enable_accel:=true

$ rosrun imu_filter_madgwick imu_filter_node \
    _use_mag:=false \
    _publish_tf:=false \
    _world_frame:="enu" \
    /imu/data_raw:=/camera/imu \
    /imu/data:=/rtabmap/imu

启动kobuki

roslaunch kobuki_node minimal.launch

启动建图

roslaunch rtabmap_ros rtabmap.launch \
    rtabmap_args:="--delete_db_on_start --Optimizer/GravitySigma 0.3" \
    depth_topic:=/camera/aligned_depth_to_color/image_raw \
    rgb_topic:=/camera/color/image_raw \
    camera_info_topic:=/camera/color/camera_info \
    approx_sync:=false \
    wait_imu_to_init:=true \
    imu_topic:=/rtabmap/imu

控制小车

cd kobuki_ws
source devel/setup.bash
roslaunch kobuki_keyop keyop.launch

保存地图

rosrun map_server map_saver -f /open/rtab_db/mymap map:=/rtabmap/grid_map

可视化

rtabmap-databaseViewer /open/rtab_db/rtabmap.db

publish地图

rosrun map_server map_server /open/rtab_db/mymap.yaml

导航

安装

sudo apt-get install ros-noetic-move-base
sudo apt-get install ros-noetic-amcl
sudo apt-get install ros-noetic-map-server
sudo apt install ros-noetic-navigation
sudo apt install ros-noetic-depthimage-to-laserscan
roslaunch kobuki_node minimal.launch
roslaunch kobuki_keyop keyop.launch
roslaunch realsense2_camera rs_camera.launch     align_depth:=true     unite_imu_method:="linear_interpolation"     enable_gyro:=true      enable_accel:=true
rosrun imu_filter_madgwick imu_filter_node     _use_mag:=false     _publish_tf:=false     _world_frame:="enu"     /imu/data_raw:=/camera/imu     /imu/data:=/rtabmap/imu
roslaunch rtabmap_ros rtabmap.launch localization:=true
roslaunch mrobot_nav move_dwa.launch

rtabmap.launch加一句

"tf" type="static_transform_publisher" name="link3_broadcaster" args="0 0 0.2 0 0 0 1 base_footprint camera_link 100" /> 

move_dwa.launch如下




  <!-- Move base -->

  "move_base" type="move_base" respawn="false" name="move_base" output="screen">
    "$(find mrobot_nav)/launch/param/costmap_common_params.yaml" command="load" ns="global_costmap" />
    "$(find mrobot_nav)/launch/param/costmap_common_params.yaml" command="load" ns="local_costmap" />
    "$(find mrobot_nav)/launch/param/local_costmap_params.yaml" command="load" />
    "$(find mrobot_nav)/launch/param/global_costmap_params.yaml" command="load" />
    "$(find mrobot_nav)/launch/param/move_base_params.yaml" command="load" />
    "$(find mrobot_nav)/launch/param/dwa_local_planner_params.yaml" command="load" />

    from="cmd_vel" to="/mobile_base/commands/velocity"/>
    from="odom" to="/odom"/>
    from="map" to="/rtabmap/grid_map"/>
    <!-- from="scan"    to="/rtabmap/local_grid_obstacle"/> -->
  </node>
  
  "depthimage_to_laserscan" type="depthimage_to_laserscan" name="depthimage_to_laserscan">
    <param name="scan_height" value="10"/>
    <param name="output_frame_id" value="camera_depth_frame"/>
    <param name="range_min" value="0.45"/>
    from="image" to="/camera/aligned_depth_to_color/image_raw"/>
    from="scan" to="/scan"/>
  </node>

</launch>

tf tree
amcl

你可能感兴趣的:(ROS,自动驾驶,ubuntu,linux,ros)