资料传递机器人实践
教室机器人送资料导航示例-CSDN直播
任务简介:
六艺楼S3某教室pgm图如下所示
机器人从学生座位区初始位置将资料运送到讲台区目标位置,示意图如下:
结合ROS1云课-01-32讲全部内容,使用云实践或自己搭建平台完成如上实践,并记录过程和相关数据。
https://img-blog.csdnimg.cn/4fe3c542eefc443d977f89baf9fe5570.gif
教室机器人送资料导航示例
提示如下:
01 一键配置
代码语言:javascript复制echo "-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
mQINBFzvJpYBEADY8l1YvO7iYW5gUESyzsTGnMvVUmlV3XarBaJz9bGRmgPXh7jc
VFrQhE0L/HV7LOfoLI9H2GWYyHBqN5ERBlcA8XxG3ZvX7t9nAZPQT2Xxe3GT3tro
u5oCR SyHN9xPnUwDuqUSvJ2eqMYb9B/Hph3OmtjG30jSNq9kOF5bBTk1hOTGPH4
K/AY0jzT6OpHfXU6ytlFsI47ZKsnTUhipGsKucQ1CXlyirndZ3V3k70YaooZ55rG
aIoAWlx2H0J7sAHmqS29N9jV9mo135d d TdLBXI0PXtiHzE9IPaX ctdSUrPnp
TwR99lxglpIG6hLuvOMAaxiqFBB/Jf3XJ8OBakfS6nHrWH2WqQxRbiITl0irkQoz
pwNEF2Bv0 Jvs1UFEdVGz5a8xexQHst/RmKrtHLct3iOCvBNqoAQRbvWvBhPjO/p
V5cYeUljZ5wpHyFkaEViClaVWqa6PIsyLqmyjsruPCWlURLsQoQxABcL8bwxX7UT
hM6CtH6tGlYZ85RIzRifIm2oudzV5l 8oRgFr9yVcwyOFT6JCioqkwldW52P1pk/
/SnuexC6LYqqDuHUs5NnokzzpfS6QaWfTY5P5tz4KHJfsjDIktly3mKVfY0fSPVV
okdGpcUzvz2hq1fqjxB6MlB/1vtk0bImfcsoxBmF7H 4E9ZN1sX/tSb0KQARAQAB
tCZPcGVuIFJvYm90aWNzIDxpbmZvQG9zcmZvdW5kYXRpb24ub3JnPokCVAQTAQgA
PgIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgBYhBMHPbjHmut6IaLFytPQu1vur
F8ZUBQJgsdhRBQkLTMW7AAoJEPQu1vurF8ZUTMwP/3f7EkOPIFjUdRmpNJ2db4iB
RQu5b2SJRG KIdbvQBzKUBMV6/RUhEDPjhXZI3zDevzBewvAMKkqs2Q1cWo9WV7Z
PyTkvSyey/Tjn PozcdvzkvrEjDMftIk8E1WzLGq7vnPLZ1q/b6Vq4H373Z EDWa
DaDwW72CbCBLWAVtqff80CwlI2x8fYHKr3VBUnwcXNHR4 nRABfAWnaU4k oTshC
Qucsd8vitNfsSXrKuKyz91IRHRPnJjx8UvGU4tRGfrHkw1505EZvgP02vXeRyWBR
fKiL1vGy4tCSRDdZO3ms2J2m08VPv65HsHaWYMnO rNJmMZj9d9JdL/9GRf5F6U0
quoIFL39BhUEvBynuqlrqistnyOhw8W/IQy/ymNzBMcMz6rcMjMwhkgm/LNXoSD1
1OrJu4ktQwRhwvGVarnB8ihwjsTxZFylaLmFSfaA OAlOqCLS1OkIVMzjW Ul6A6
qjiCEUOsnlf4CGlhzNMZOx3low6ixzEqKOcfECpeIj80a2fBDmWkcAAjlHu6VBhA
TUDG9e2xKLzV2Z/DLYsb3 n9QW7KO0yZKfiuUo6AYboAioQKn5jh3iRvjGh2Ujpo
22G oae3PcCc7G z12j6xIY709FQuA49dA2YpzMda0/OX4LP56STEveDRrO CnV6
WE F5FaIKwb72PL4rLi4
=i0tj
-----END PGP PUBLIC KEY BLOCK-----" >> ~/ros.asc
sudo apt-key add ros.asc
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
git clone https://gitcode.net/ZhangRelay/ros_book.git
sudo apt update
sudo apt install ros-kinetic-turtlebot-simulator -y
roslaunch turtlebot_stdr turtlebot_in_stdr.launch
这个过程完成了Key的更新,部分机器人功能包源码下载以及升级等。
相关命令:
1 gedit classroom.sh 2 chmod x classroom.sh 3 ./classroom.sh
02 定制环境
代码语言:javascript复制Invalid <arg> tag: environment variable 'TURTLEBOT_STDR_MAP_FILE' is not set.
Arg xml is <arg default="$(env TURTLEBOT_STDR_MAP_FILE)" name="map_file"/>
The traceback for the exception was written to the log file
文件路径:
/home/shiyanlou/Code/classroom_ws/src/turtlebot_stdr/maps/
复制turtlebot_in_stdr.launch为classroom.launch
使用catkin_make,编译后新建如下文件。
里面内容:
代码语言:javascript复制source /home/shiyanlou/Code/classroom_ws/devel/setup.zsh
export TURTLEBOT_STDR_MAP_FILE=/home/shiyanlou/Code/classroom_ws/src/turtlebot_stdr/maps/classroom.yaml
roslaunch turtlebot_stdr turtlebot_in_stdr.launch
涉及命令如下:
4 history 5 gedit .zshrc 6 unzip turtlebot_simulator-melodic.zip 7 catkin_make 8 gedit classroom.sh 9 cd src/turtlebot_stdr/maps 10 pwd 11 chmod x classroom.sh 12 ./classroom.sh
效果如下:
03 机器人
代码语言:javascript复制source /home/shiyanlou/Code/classroom_ws/devel/setup.zsh
export TURTLEBOT_STDR_MAP_FILE=/home/shiyanlou/Code/classroom_ws/src/turtlebot_stdr/maps/classroom.yaml
roslaunch turtlebot_stdr classroom.launch
机器人初始位置在导航地图中并没有正确配置。
修改如下(18.0和13.7):
代码语言:javascript复制<!--
Turtlebot navigation simulation:
- stdr
- move_base
- amcl
- map_server
- rviz view
-->
<launch>
<arg name="base" default="$(optenv TURTLEBOT_BASE kobuki)"/> <!-- create, rhoomba -->
<arg name="stacks" default="$(optenv TURTLEBOT_STACKS hexagons)"/> <!-- circles, hexagons -->
<arg name="3d_sensor" default="$(optenv TURTLEBOT_3D_SENSOR kinect)"/> <!-- kinect, asus_xtion_pro -->
<arg name="laser_topic" default="robot0/laser_0"/> <!-- default laser topic in stdr for 1 robot -->
<arg name="odom_topic" default="robot0/odom"/>
<arg name="odom_frame_id" default="map"/>
<arg name="base_frame_id" default="robot0"/>
<arg name="global_frame_id" default="world"/>
<!-- Name of the map to use (without path nor extension) and initial position -->
<arg name="map_file" default="$(env TURTLEBOT_STDR_MAP_FILE)"/>
<arg name="initial_pose_x" default="18.0"/>
<arg name="initial_pose_y" default="13.7"/>
<arg name="initial_pose_a" default="0.0"/>
<arg name="min_obstacle_height" default="0.0"/>
<arg name="max_obstacle_height" default="5.0"/>
<!-- ******************** Stdr******************** -->
<include file="$(find stdr_robot)/launch/robot_manager.launch" />
<!-- Run STDR server with a prefedined map-->
<node pkg="stdr_server" type="stdr_server_node" name="stdr_server" output="screen" args="$(arg map_file)"/>
<!--Spawn new robot at init position 2 2 0-->
<node pkg="stdr_robot" type="robot_handler" name="$(anon robot_spawn)" args="add $(find turtlebot_stdr)/robot/turtlebot.yaml $(arg initial_pose_x) $(arg initial_pose_y) 0"/>
<!-- Run Gui -->
<include file="$(find stdr_gui)/launch/stdr_gui.launch"/>
<!-- Run the relay to remap topics -->
<include file="$(find turtlebot_stdr)/launch/includes/relays.launch.xml"/>
<!-- ***************** Robot Model ***************** -->
<include file="$(find turtlebot_bringup)/launch/includes/robot.launch.xml">
<arg name="base" value="$(arg base)" />
<arg name="stacks" value="$(arg stacks)" />
<arg name="3d_sensor" value="$(arg 3d_sensor)" />
</include>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
<param name="use_gui" value="true"/>
</node>
<!-- Command Velocity multiplexer -->
<node pkg="nodelet" type="nodelet" name="mobile_base_nodelet_manager" args="manager"/>
<node pkg="nodelet" type="nodelet" name="cmd_vel_mux" args="load yocs_cmd_vel_mux/CmdVelMuxNodelet mobile_base_nodelet_manager">
<param name="yaml_cfg_file" value="$(find turtlebot_bringup)/param/mux.yaml"/>
<remap from="cmd_vel_mux/output" to="mobile_base/commands/velocity"/>
</node>
<!-- ****** Maps ***** -->
<node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)">
<param name="frame_id" value="$(arg global_frame_id)"/>
</node>
<!-- ************** Navigation *************** -->
<include file="$(find turtlebot_navigation)/launch/includes/move_base.launch.xml">
<arg name="odom_topic" value="$(arg odom_topic)"/>
<arg name="laser_topic" value="$(arg laser_topic)"/>
<arg name="odom_frame_id" value="$(arg odom_frame_id)"/>
<arg name="base_frame_id" value="$(arg base_frame_id)"/>
<arg name="global_frame_id" value="$(arg global_frame_id)"/>
</include>
<!-- ***************** Manually setting some parameters ************************* -->
<param name="move_base/local_costmap/obstacle_layer/scan/min_obstacle_height" value="$(arg min_obstacle_height)"/>
<param name="move_base/local_costmap/obstacle_layer/scan/max_obstacle_height" value="$(arg max_obstacle_height)"/>
<param name="move_base/global_costmap/obstacle_layer/scan/min_obstacle_height" value="$(arg min_obstacle_height)"/>
<param name="move_base/global_costmap/obstacle_layer/scan/max_obstacle_height" value="$(arg max_obstacle_height)"/>
<!-- ************** AMCL ************** -->
<include file="$(find turtlebot_navigation)/launch/includes/amcl/amcl.launch.xml">
<arg name="scan_topic" value="$(arg laser_topic)"/>
<arg name="use_map_topic" value="true"/>
<arg name="odom_frame_id" value="$(arg odom_frame_id)"/>
<arg name="base_frame_id" value="$(arg base_frame_id)"/>
<arg name="global_frame_id" value="$(arg global_frame_id)"/>
<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>
<!-- ********** Small tf tree connector between robot0 and base_footprint********* -->
<node name="tf_connector" pkg="turtlebot_stdr" type="tf_connector.py" output="screen"/>
<!-- **************** Visualisation **************** -->
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find turtlebot_stdr)/rviz/robot_navigation.rviz"/>
</launch>
使用2D Pose Estimate将机器人定位在rviz地图的对应位置,无需精确。
效果如下图:
记录机器人odom
代码语言:javascript复制pose:
pose:
position:
x: 18.0
y: 13.7
z: 0.0
orientation:
x: 0.0
y: 0.0
z: 0.0
w: 1.0
04 导航
使用2D Nav Goal设置目标点,并记录位置:
代码语言:javascript复制child_frame_id: "robot0"
pose:
pose:
position:
x: 12.6552529266
y: 14.5341912728
z: 0.0
orientation:
x: 0.0
y: -0.0
z: -0.99732847514
w: -0.0730473317482
对比起点和终点坐标。
起点:
终点:
05 附加-巡逻
编写代码实现机器人在起点和终点直接往复巡逻。
案例参考:
为了更好地保障仓库货物的安全,降低企业的运行成本,提高企业生产效率及产品质量,项目小组设计了一款基于ROS系统的仓库巡逻机器人,并对该仓库巡逻机器人进行了实验测试。实验测试结果表明:该机器人可以通过激光雷达进行地图构建和自主巡逻;通过报警系统与自身定位完成对仓库内的异常情况进行反馈和报警等相关任务;实现了自主导航、自主定位、报警和巡逻功能,具有可二次开发、成本低等优点。
针对室内大型场所的三防自动化困难问题,设计了一款室内安防巡逻与灭火多功能机器人,具有电子地图构建、定位、导航、事故处理与远程监控等功能。给出了该机器人总体组成与控制系统软硬件架构,并对机器人核心的电子地图自主构建功能做了实验测试。试验结果表明,该机器人可以自主构建出现实环境的电子地图,保证定位与导航功能的实现基础。