ROS基础入门与备忘
lglgang
lglgang 3271 1
2016-06-08 20:59
==================================================================
增加时间同步:
选择一台服务器,IP为10.168.10.10
sudo apt-get install chrony
sudo vi /etc/chrony/chrony.conf
server 0.debian.pool.ntp.org offline minpoll 8
server 1.debian.pool.ntp.org offline minpoll 8
server 2.debian.pool.ntp.org offline minpoll 8
server 3.debian.pool.ntp.org offline minpoll 8
->
server 1.cn.pool.ntp.org
server 1.asia.pool.ntp.org
server 0.asia.pool.ntp.org
下面的IP为允许访问的IP
allow 10/8
allow 192.168/16
allow 172.16/12
重启chrony服务即可
sudo service chrony restart


其他节点:
使用chrony工具
只需要将“server”项修改为上面的时间服务器即可
server 10.168.10.10
或:
 使用ntpd
yum install ntp
修改配置文件,添加“server 10.168.10.10” 到下面的配置文件vi /etc/ntp.conf
==================================================================
刻录ubuntu系统:
remastersys
sudo remastersys
sudo remastersys disk cdfs
sudo remasteryss dist iso filename.iso
/home/remastersys
==================================================================
安装rbx1包:
cd ~/catkin_ws/src
git clone https://github.com/pirobot/rbx1.git
cd rbx1
git checkout hydro-devel
cd ~/catkin_ws
catkin_make
source ~/catkin_ws/devel/setup.bash
==================================================================
增加USB串口权限更改:
/dev/ttyUSB0
增加权限
创建文件/etc/udev/rules.d/70-ttyusb.rules
在文件内增加一行
KERNEL=="ttyUSB[0-9]*", MODE="0666"
重新插入USB转串口设备,普通用户就有权限访问了。
==================================================================
设置环境变量:
gedit ~/.bashrc
add source ~/catkin_ws/devel/setup.bash
==================================================================
简单的收发测试:
cd ~/catkin_ws
catkin_make
roscore
rosrun beginner_tutorials talker
rosrun beginner_tutorials listener
==================================================================
模拟导航测试:
roscore
roslaunch rbx1_bringup fake_turtlebot.launch
roslaunch rbx1_nav fake_move_base_blank_map.launch
rosrun rviz rviz -d /home/ligang/catkin_ws/src/rbx1/rbx1_nav/nav.rviz


非全路径:
roscore
roslaunch rbx1_bringup fake_turtlebot.launch
roslaunch rbx1_nav fake_move_base_blank_map.launch
rosrun rviz rviz -d 'rospack find rbx1_nav'/nav.rviz
==================================================================


rostopic pub /move_base_simple/goal geometry_msgs/PoseStamped \ '{ header: { frame_id: "map" }, pose: { position: { x: 1.0, y: 1.4, z: 0 } ,orientation: { x: 0, y: 0, z: 0, w: 1}}}'




rostopic pub /move_base_simple/goal geometry_msgs/PoseStamped \ '{ header: { frame_id: "map" }, pose: { position: { x: 0.0, y: 0.4, z: 0 } ,orientation: { x: 0, y: 0, z: 0, w: 1}}}'




wget http://pr.willowgarage.com/data/gmapping/basic_localization_stage.bag
rosbag play --clock basic_localization_stage.bag
==================================================================
扫描数据,制造地图
在单个计算机上运行:
https://github.com/DaikiMaekawa/hector_slam_example
安装另一个包
https://github.com/tu-darmstadt-ros-pkg/hector_slam
1,roscore
2,roslaunch hector_slam_example hector_rplidar.launch
3,roslaunch rplidar_ros rplidar.launch


 问题:no such package hector_geotiff
 Waiting for tf transform data between frames /map and /base_link to become available
[ERROR] [1464747037.885943685]: The plugin failed to load for some reason. Error: According to the loaded plugin descriptions the class hector_geotiff_plugins/TrajectoryMapWriter with base class type hector_geotiff::MapWriterPluginInterface does not exist. Declared types are


[hector_mapping-9] process has died [pid 6941, exit code -11, cmd /opt/ros/hydro/lib/hector_mapping/hector_mapping __name:=hector_mapping __log:=/home/ligang/.ros/log/6f406894-2799-11e6-b330-a088b48fb934/hector_mapping-9.log].
log file: /home/ligang/.ros/log/6f406894-2799-11e6-b330-a088b48fb934/hector_mapping-9*.log


[rospack] Warning: no such package hector_geotiff
[ERROR] [1464747326.998373367]: The plugin failed to load for some reason. Error: According to the loaded plugin descriptions the class hector_geotiff_plugins/TrajectoryMapWriter with base class type hector_geotiff::MapWriterPluginInterface does not exist. Declared types are
[ INFO] [1464747326.998484746]: Geotiff node started




==================================================================
双机构建ROS系统:


在两个个计算机上运行
笔记本:
ubuntu 笔记本名字,通过hostname命令查询
Zeroconf主机名:ubuntu.local
192.168.20.215


台式机:
ligang-MS-7817 台式机名字,通过hostname命令查询
Zeroconf主机名:ligang-MS-7817.local
192.168.20.163




在两台计算机上安装chrony 用于时间同步
sudo apt-get install chrony
ubuntu系统自带Zeroconf功能


使用ping测试连通性:
台式机上运行:测试与笔记本的连通性
ping ubuntu.local
笔记本上运行:测试与台式机的连通性
ping ligang-MS-7817.local


笔记本作为机器人使用:
export ROS_HOSTNAME=ubuntu.local
roscore


台式机上运行:
export ROS_HOSTNAME=ligang-MS-7817.local
export ROS_MASTER_URI=http://ubuntu.local:11311
设置环境变量:
gedit ~/.bashrc
add export ROS_MASTER_URI=http://ubuntu.local:11311


检查时间同步:
sudo ntpdate -b ubuntu.local
查询topic
rostopic list
==================================================================
双机上运行:
笔记本,启动激光雷达:
roslaunch rplidar_ros rplidar.launch
台式机,启动gmapping
roslaunch hector_slam_example hector_rplidar.launch
==================================================================
gmapping步骤:
如果是从源安装,需要编译:
rosmake gmapping


生成一个bag
Bring up启动机器人(带激光雷达扫描,并发布数据),使用joystick手柄遥控
记录雷达数据:
rosbag record -O mylaserdata /base_scan /tf


或者下载一个bag数据包
wget http://pr.willowgarage.com/data/gmapping/basic_localization_stage.bag


启动ROS
roscore


使用sim时间
rosparam set use_sim_time true


启动slam_gmapping, 带激光扫描,生成地图
rosrun gmapping slam_gmapping scan:=base_scan


PR2
rosrun gmapping slam_gmapping scan:=base_scan _odom_frame:=odom_combined


在新的终端中回放bag数据


rosbag play --clock <name of the bag that you downloaded / created in step 2>


保存生成的图像
rosrun map_server map_saver -f aaamap
察看图像
 eog aaamap.pgm




观察生成的图像
rosrun rviz rviz
Add a display with a map, set to the topic /map
==================================================================
rbx2的学习:
roslaunch rbx2_description box_robot_base_only.launch
roslaunch zhsdbot_description box_robot_base_only.launch
roslaunch rbx2_description pi_robot_base_with_laser.launch
roslaunch rbx2_bringup fake_box_robot_with_gripper.launch
rosrun rviz rviz -d 'rospack find rbx2_description'/urdf.rviz
rosrun rviz rviz -d 'rospack find zhsdbot_description'/urdf.rviz
rosrun rviz rviz -d 'rospack find rbx2_bringup'/sim.rviz
arbotix_gui
catkin_create_pkg zhsdbot_description roscpp rospy urdf
==================================================================
分享:
游客
要评论请先登录 或者 注册
roswiki BOSS 2016-06-08 22:00 沙发
感谢分享
返回顶部