小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
[FishBot教程]7. FishBot-Nav2导航测试
-
7. FishBot-Nav2导航测试
你好,我是小鱼。本节是FishBot上手的最后一节,真机的导航测试。
在开始之前你需要完成前面几章的内容,确保雷达以及里程计等信息的正确。如未完成请返回:https://fishros.org.cn/forum/topic/923
小鱼测试导航所用到的软硬件信息如下:
- FishBot基础版*1台
- 装有Ubuntu22.04和ROS2的Linux笔记本或台式机
- 测试主要源码:https://github.com/fishros/fishbot/tree/v1.0.0
一、下载与编译导航代码
打开终端,输入下面的指令。
git clone https://github.com/fishros/fishbot.git -b v1.0.0 --depth=1 cd fishbot rosdep install --from-paths src --ignore-src -y -r # 安装依赖 sudo apt install ros-humble-joint-state-publisher # 继续装依赖 colcon build
如果你想下载Carto和Navigation2的源码请使用。
git clone --recursive https://github.com/fishros/fishbot.git -b v1.0.0 --depth=1 cd fishbot rosdep install --from-paths src --ignore-src -y -r # 安装依赖 colcon build
二、启动雷达与MicroROS
开两个终端,分别输入(后续该部分将集成至launch中则无需输入)
MicroROS
sudo docker run -it --rm -v /dev:/dev -v /dev/shm:/dev/shm --privileged --net=host microros/micro-ros-agent:$ROS_DISTRO udp4 --port 8888 -v6
雷达驱动,运行后选1
xhost + && sudo docker run -it --rm -v /dev:/dev -v /dev/shm:/dev/shm --privileged -v /tmp/.X11-unix:/tmp/.X11-unix --device /dev/snd -e DISPLAY=unix$DISPLAY -p 8889:8888 fishros2/fishbot_laser
接着开机,让机器人连上来!
三、启动bringup
cd fishbot source install/setup.bash ros2 launch fishbot_bringup fishbot_bringup.launch.py
bringup节点目前主要将odom话题转成tf并,并发布机器本体的tf广播
四、替换地图
在正式开始之前你需要将你之前建立好的地图导入进来,毕竟小鱼家的环境和你当前环境不同。
将地图文件复制到
fishbot/src/fishbot_navigation2/maps
文件夹下。
接着修改launch文件fishbot/src/fishbot_navigation2/launch/navigation2.launch.py
import os ... def generate_launch_description(): fishbot_navigation2_dir = get_package_share_directory('fishbot_navigation2') nav2_bringup_dir = get_package_share_directory('nav2_bringup') use_sim_time = LaunchConfiguration('use_sim_time', default='false') map_yaml_path = LaunchConfiguration('map',default=os.path.join(fishbot_navigation2_dir,'maps','你的地图名称.yaml')) ...
修改好后,再次编译
colcon build
五、导航测试
接着我们就可以启动导航了
source install/setup.bash ros2 launch fishbot_navigation2 navigation2.launch.py
启动后如上图所示,地图被正常加载出来了
接着我们需要告诉nav2当前机器人在地图的哪个位置,点击Rviz2工具栏——2D Pose Estimate,然后在地图上点个目标点并选择方向
接着你将看到全局代价地图以及被地代价地图以及激光在地图上都标记出来了
此时你可以使用rviz2的工具栏中的Nav2 Goal发送一个目标点,然后观察机器人运动即可。
六、总结
本节是简单的介绍了如何使用FishBot进行导航,本节的结束意味着我们的开发教程的正式开始,接下来小鱼将从最基础的电路图讲起,带你一起从头实现机器人的导航。
-
-
此回复已被删除! -
此回复已被删除! -
git clone https://github.com/fishros/fishbot.git -b v1.0.0 --depth=1 cd fishbot rosdep install --from-paths src --ignore-src -y -r # 安装依赖 colcon build
鱼哥,我在编译nav2_pure_pursuit_controller这个功能包的时候报错了,错误如下:
In file included from /home/zero/Code/SLAM/fishbot/src/nav2_pure_pursuit_controller/src/pure_pursuit_controller.cpp:8: /home/zero/Code/SLAM/fishbot/src/nav2_pure_pursuit_controller/include/nav2_pure_pursuit_controller/pure_pursuit_controller.hpp:45:18: error: ‘nav2_core::GoalChecker’ has not been declared 45 | nav2_core::GoalChecker *goal_checker) override; | ^~~~~~~~~~~ /home/zero/Code/SLAM/fishbot/src/nav2_pure_pursuit_controller/include/nav2_pure_pursuit_controller/pure_pursuit_controller.hpp:27:8: error: ‘void nav2_pure_pursuit_controller::PurePursuitController::configure(const WeakPtr&, std::string, std::shared_ptr<tf2_ros::Buffer>, std::shared_ptr<nav2_costmap_2d::Costmap2DROS>)’ marked ‘override’, but does not override 27 | void configure( | ^~~~~~~~~ /home/zero/Code/SLAM/fishbot/src/nav2_pure_pursuit_controller/include/nav2_pure_pursuit_controller/pure_pursuit_controller.hpp:42:36: error: ‘geometry_msgs::msg::TwistStamped nav2_pure_pursuit_controller::PurePursuitController::computeVelocityCommands(const PoseStamped&, const Twist&, int*)’ marked ‘override’, but does not override 42 | geometry_msgs::msg::TwistStamped computeVelocityCommands( | ^~~~~~~~~~~~~~~~~~~~~~~ /home/zero/Code/SLAM/fishbot/src/nav2_pure_pursuit_controller/include/nav2_pure_pursuit_controller/pure_pursuit_controller.hpp:58:8: error: ‘void nav2_pure_pursuit_controller::PurePursuitController::setSpeedLimit(const double&, const bool&)’ marked ‘override’, but does not override 58 | void setSpeedLimit(const double &speed_limit, | ^~~~~~~~~~~~~ /home/zero/Code/SLAM/fishbot/src/nav2_pure_pursuit_controller/src/pure_pursuit_controller.cpp:116:16: error: ‘nav2_core::GoalChecker’ has not been declared 116 | nav2_core::GoalChecker *goal_checker) { | ^~~~~~~~~~~ In file included from /opt/ros/foxy/include/class_loader/class_loader_core.hpp:57, from /opt/ros/foxy/include/class_loader/class_loader.hpp:55, from /opt/ros/foxy/include/class_loader/multi_library_class_loader.hpp:52, from /opt/ros/foxy/include/pluginlib/class_loader.hpp:58, from /opt/ros/foxy/include/nav2_costmap_2d/costmap_2d_ros.hpp:53, from /opt/ros/foxy/include/nav2_core/controller.hpp:42, from /home/zero/Code/SLAM/fishbot/src/nav2_pure_pursuit_controller/include/nav2_pure_pursuit_controller/pure_pursuit_controller.hpp:8, from /home/zero/Code/SLAM/fishbot/src/nav2_pure_pursuit_controller/src/pure_pursuit_controller.cpp:8: /opt/ros/foxy/include/class_loader/meta_object.hpp: In instantiation of ‘B* class_loader::impl::MetaObject<C, B>::create() const [with C = nav2_pure_pursuit_controller::PurePursuitController; B = nav2_core::Controller]’: /opt/ros/foxy/include/class_loader/meta_object.hpp:216:7: required from here /opt/ros/foxy/include/class_loader/meta_object.hpp:218:12: error: invalid new-expression of abstract class type ‘nav2_pure_pursuit_controller::PurePursuitController’ 218 | return new C; | ^~~~~ In file included from /home/zero/Code/SLAM/fishbot/src/nav2_pure_pursuit_controller/src/pure_pursuit_controller.cpp:8: /home/zero/Code/SLAM/fishbot/src/nav2_pure_pursuit_controller/include/nav2_pure_pursuit_controller/pure_pursuit_controller.hpp:15:7: note: because the following virtual functions are pure within ‘nav2_pure_pursuit_controller::PurePursuitController’: 15 | class PurePursuitController : public nav2_core::Controller { | ^~~~~~~~~~~~~~~~~~~~~ In file included from /home/zero/Code/SLAM/fishbot/src/nav2_pure_pursuit_controller/include/nav2_pure_pursuit_controller/pure_pursuit_controller.hpp:8, from /home/zero/Code/SLAM/fishbot/src/nav2_pure_pursuit_controller/src/pure_pursuit_controller.cpp:8: /opt/ros/foxy/include/nav2_core/controller.hpp:74:16: note: ‘virtual void nav2_core::Controller::configure(const SharedPtr&, std::string, const std::shared_ptr<tf2_ros::Buffer>&, const std::shared_ptr<nav2_costmap_2d::Costmap2DROS>&)’ 74 | virtual void configure( | ^~~~~~~~~ /opt/ros/foxy/include/nav2_core/controller.hpp:112:44: note: ‘virtual geometry_msgs::msg::TwistStamped nav2_core::Controller::computeVelocityCommands(const PoseStamped&, const Twist&)’ 112 | virtual geometry_msgs::msg::TwistStamped computeVelocityCommands( | ^~~~~~~~~~~~~~~~~~~~~~~ make[2]: *** [CMakeFiles/nav2_pure_pursuit_controller.dir/build.make:63: CMakeFiles/nav2_pure_pursuit_controller.dir/src/pure_pursuit_controller.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/nav2_pure_pursuit_controller.dir/all] Error 2 make: *** [Makefile:141: all] Error 2 --- Failed <<< nav2_pure_pursuit_controller [3.62s, exited with code 2] Summary: 5 packages finished [3.85s] 1 package failed: nav2_pure_pursuit_controller 1 package had stderr output: nav2_pure_pursuit_controller
这个错误该怎么改呢?
-
@444037843 在 [FishBot教程]7. FishBot-Nav2导航测试 中说:
nav2_pure_pursuit_controller
直接先删掉这个包吧,暂时用不倒,有时间我再更新下
-
你好,小鱼,小车电机转动运行后停止,有抱死后的高频鸣噪,是否可以适当调整停车抱死策略。
-
@萝卜头 有这个打算,下一个固件版本会解决,有时间也可以手动改下代码:https://github.com/fishros/fishbot_motion_control_microros
-
@小鱼 好的,我也看一下代码,还有个问题,每当控制板和雷达板连接到局域网后,若ubuntu终端退出docker运行的程序,再次启动agent,会连不上控制板和雷达板,路由器管理端显示两个设备在线,不知您是否遇到过此问题。
-
@萝卜头 你说的退出是直接关掉终端吗?还是先关闭程序再关闭终端。因为是使用docker,莞城终端不会打断原有程序的运行,所以再次启动就会出现占用情况,
除此之外还有一种可能,是因为网络不稳定造成的,比较推荐,小车直连电脑,或者小车直连路由器,路由器网线接电脑,这两种线路。
-
@小鱼 是Ctrl+C结束docker,再次运行或者再开新终端运行无法执行agent。
-
@萝卜头 可以贴一下log看看,具体提示什么
-
@小鱼 我现在还没回去,等我回去给贴一下
-
@小鱼 刚才测试了几次,应该是我直接关闭终端的缘故造成的,现在可以了,感谢!
-
你好,小鱼,我是双系统的22.04在输入:
git clone --recursive https://github.com/fishros/fishbot.git -b v1.0.0 --depth=1
fatal: 目标路径 'fishbot' 已经存在,并且不是一个空目录。
请问怎么处理这个问题,谢谢! -
@86181314 换个目录就行了,因为当前目录下已经存在了fishbot这一目录,也可以删掉
-
第一步出现了如下问题,不知如何解决 -
@小鱼 鱼哥,换个目录是什么意思?
-
又有新的问题 -
@921203724 别一次性运行太多指令,不然都搞不清楚是哪个出错,一步步来
看你的错误是克隆错误,已经存在fishbot工作空间了
-
@小鱼
已经下载了rosdepc,结果还是让我跑rosdep