bd258953-bc17-4c7c-99d7-f890a20f049c-图片.png
首先是提示信息:
[INFO] [1753014822.443208735] [move_group_interface]: Ready to take commands for planning group left_hand.
Planning frame: base_link
[INFO] [1753014822.444405420] [moveit_ros.current_state_monitor]: Listening to joint states on topic 'joint_states'
[INFO] [1753014823.444763207] [moveit_ros.current_state_monitor]: Didn't receive robot state (joint angles) with recent timestamp within 1.000000 seconds. Requested time 1753014822.444444, but latest received state has time 0.000000.
Check clock synchronization if your are running ROS across multiple machines!
[ERROR] [1753014823.444899784] [move_group_interface]: Failed to fetch current robot state
根据官方文档一直查到提示信息在waitForCurrentState()的函数中被打印,函数主要逻辑是使用while阻塞等待回调执行,直到接收到数据的时间戳大于指定的目标时间,但是为了避免一直阻塞,函数会在每次循环求出与初始时间的间隔,然后做一个超时判断,可以看到提示信息第三个浮点数,含义是接收到数据的时间戳,但是它为0,这说明在对象初始化结束后,从未接收到过数据,回调函数没有被执行。检查回调绑定的函数startStateMonitor(),函数接受默认参数主题名joint_states,然后绑定回调然后打印监听中的信息。但是回调似乎不被执行。
已验证主题存在,并且数据正常发布,自已写一个订阅节点也能够正常输出得到的时间戳。
#include <memory> #include <stdio.h> #include <rclcpp/rclcpp.hpp> #include <moveit/move_group_interface/move_group_interface.h> #include <moveit_msgs/msg/move_it_error_codes.h> int main(int argc, char * argv[]) { // Initialize ROS and create the Node rclcpp::init(argc, argv); auto const node = std::make_shared<rclcpp::Node>( "ib_moveit", rclcpp::NodeOptions().automatically_declare_parameters_from_overrides(true) ); // Create a ROS logger auto const logger = rclcpp::get_logger("ib_moveit"); // Create the MoveIt MoveGroup Interface using moveit::planning_interface::MoveGroupInterface; auto move_group_interface = MoveGroupInterface(node, "left_hand"); std::string planning_frame = move_group_interface.getPlanningFrame(); printf("Planning frame: %s\n", planning_frame.c_str()); // Set a target Pose auto const target_pose = []{ geometry_msgs::msg::Pose msg; msg.orientation.x = 0.00503518; msg.orientation.y = 0.707089; msg.orientation.z = 0.707089; msg.orientation.w = 0.00503523; msg.position.x = 0.22454; msg.position.y = 0.424263; msg.position.z = 0.3421; return msg; }(); move_group_interface.setPoseTarget(target_pose); //move_group_interface.setRandomTarget(); auto target_pose_ = move_group_interface.getCurrentPose(); printf("Target Position: [x=%.3f, y=%.3f, z=%.3f]\n", target_pose_.pose.position.x, target_pose_.pose.position.y, target_pose_.pose.position.z); // Create a plan to that target pose auto const [success, plan] = [&move_group_interface]{ moveit::planning_interface::MoveGroupInterface::Plan msg; moveit::core::MoveItErrorCode error_code = move_group_interface.plan(msg); if (error_code == moveit::core::MoveItErrorCode::SUCCESS) { printf("Planning succeeded\n"); } else { // 输出详细错误信息 printf("Planning failed with error code: %d\n", error_code.val); // 检查特定错误类型 if (error_code == moveit_msgs::msg::MoveItErrorCodes::NO_IK_SOLUTION) { printf("No IK solution found for target pose!\n"); } else if (error_code == moveit_msgs::msg::MoveItErrorCodes::PLANNING_FAILED) { printf("General planning failure. Check constraints or environment.\n"); } } auto const ok = static_cast<bool>(error_code); return std::make_pair(ok, msg); }(); // Execute the plan if(success) { move_group_interface.execute(plan); } else { RCLCPP_ERROR(logger, "Planning failed!"); } // Shutdown ROS rclcpp::shutdown(); return 0; }CMake Error at components/micro_ros_espidf_component/CMakeLists.txt:90 (message):
FAILED: no such file or directory
以上是报错内容,cmake文件的第九十行是代码块的一部分,涉及libmicroros.mk这个文件,这个文件存在而且可以正常访问,克隆的仓库完整,但是不知道为什么还是报错,还恳请各位大佬帮忙看看,以下是cmake的部分代码块
execute_process(
WORKING_DIRECTORY ${COMPONENT_DIR}
RESULT_VARIABLE libmicroros_ret
COMMAND
${submake} -j -f libmicroros.mk
X_CC=${CMAKE_C_COMPILER}
X_AR=${CMAKE_AR}
X_STRIP=${CMAKE_STRIP}
X_CFLAGS=${CMAKE_C_FLAGS}
X_CXX=${CMAKE_CXX_COMPILER}
X_CXXFLAGS=${CMAKE_CXX_FLAGS}
C_STANDARD=${CMAKE_C_STANDARD}
MIDDLEWARE=${MIDDLEWARE}
BUILD_DIR=${CMAKE_BINARY_DIR}
IDF_INCLUDES=${IDF_INCLUDES}
IDF_PATH=${IDF_PATH}
IDF_TARGET=${IDF_TARGET}
APP_COLCON_META=${APP_COLCON_META}
IDF_VERSION_MAJOR=${IDF_VERSION_MAJOR}
IDF_VERSION_MINOR=${IDF_VERSION_MINOR}
EXTRA_ROS_PACKAGES=${EXTRA_ROS_PACKAGES}
)
if(libmicroros_ret AND NOT libmicroros_ret EQUAL 0)
message(FATAL_ERROR "FAILED: ${libmicroros_ret}")
endif()
00c18932-581b-4473-a8f4-6b717984c08e-image.png
bd258953-bc17-4c7c-99d7-f890a20f049c-图片.png
使用ROS2 humble开发机器人导航系统,主控机除了接入底盘STM32外,还接入了雷达和IMU。
请问我该选择树莓派4B还是5B?
运行如下代码时,如果使用fish的源码会出现的问题,
a5b2f5c7-de48-4b96-b3e4-db418b84034e.png
有:
50a0e1bb-a315-4de2-b706-004f298f95f7.png
就是时间戳的问题,因为我增大过slam_toolbox的online_async这个文件的配置文件的栈的大小和保存数据的时间但是都没有效果,也不是网络问题,然后就发现了只可能是时间戳的问题。电脑有自己的时钟,小车也是,就发现了odom2tf.cpp文件里面的一个地方出现了问题,时间戳应该都要用电脑的时间戳,不能两者混在一起。
具体的解释你们可以把代码发给AI问一下,我可能说的不清除,但是一定能解决。
只要按照下面的方法把时间戳统一到电脑的就完美解决问题了,
找到odom2tf.cpp文件,按照下面的改:
de71100b-d44d-4862-a5cb-bec133d9c35f.png
😊 😊 😊 😊
报错代码如下
Processing featheresp32 (platform: espressif32; board: featheresp32; framework: arduino) -------------------------------------------------------------------------------- Tool Manager: Installing espressif/toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5 Tool Manager: Error: Please read https://bit.ly/package-manager-ioerror Tool Manager: Warning! Package Mirror: HTTPSConnectionPool(host='dl.registry.ns3.platformio.org', port=443): Max retries exceeded with url: /tools/58/c9/d6f867f93b6e55491c200cb539274c8ae3dccf76daf29428aa64dd54d727/toolchain-xtensa-esp32-linux_x86_64-8.4.0+2021r2-patch5.tar.gz (Caused by ProxyError('Unable to connect to proxy', ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7cf79f596140>, 'Connection to fishros.org timed out. (connect timeout=10)')))是跟镜像问题相关吗?我在安装PlateformIO MicroROS开发环境前已经用一键安装命令更换了系统镜像源,并且根据视频教程【《ROS 2机器人开发从入门到实践》9.2.1开发平台介绍与安装】 https://www.bilibili.com/video/BV1pLf2YxEzv/?share_source=copy_web&vd_source=b55b762ce28a6ddb1537f871dc7d4a1d 配置完platformio.ini文件后,用
pio run编译运行时下载速度也特别慢。求各位大佬指点下解决方法。
如题,我自己整了个YDLIDAR X2激光雷达,用wifi发给电脑能收到,但是小鱼的雷达驱动的tcp通信无法解析,我想知道通信协议。
虚拟机使用VM,系统乌班图22.04
d05a7d8c-33b3-4f47-b9c4-22b0e579be28-image.png
ub@ub-virtual-machine:~/chapt6/chapt6_ws$ ros2 launch fishbot_description gazebo_sim.launch.py
[INFO] [launch]: All log files can be found below /home/ub/.ros/log/2025-07-16-20-10-55-594522-ub-virtual-machine-4590
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [robot_state_publisher-1]: process started with pid [4595]
[INFO] [gzserver-2]: process started with pid [4597]
[INFO] [gzclient-3]: process started with pid [4599]
[INFO] [spawn_entity.py-4]: process started with pid [4601]
[robot_state_publisher-1] [INFO] [1752667856.267970093] [robot_state_publisher]: got segment back_caster_link
[robot_state_publisher-1] [INFO] [1752667856.268156632] [robot_state_publisher]: got segment base_footprint
[robot_state_publisher-1] [INFO] [1752667856.268172869] [robot_state_publisher]: got segment base_link
[robot_state_publisher-1] [INFO] [1752667856.268181356] [robot_state_publisher]: got segment camera_link
[robot_state_publisher-1] [INFO] [1752667856.268188438] [robot_state_publisher]: got segment camera_optical_link
[robot_state_publisher-1] [INFO] [1752667856.268195597] [robot_state_publisher]: got segment front_caster_link
[robot_state_publisher-1] [INFO] [1752667856.268202887] [robot_state_publisher]: got segment imu_link
[robot_state_publisher-1] [INFO] [1752667856.268209962] [robot_state_publisher]: got segment laser_cylinder_link
[robot_state_publisher-1] [INFO] [1752667856.268216871] [robot_state_publisher]: got segment laser_link
[robot_state_publisher-1] [INFO] [1752667856.268223440] [robot_state_publisher]: got segment left_wheel_link
[robot_state_publisher-1] [INFO] [1752667856.268230619] [robot_state_publisher]: got segment right_wheel_link
[gzclient-3] Gazebo multi-robot simulator, version 11.10.2
[gzclient-3] Copyright (C) 2012 Open Source Robotics Foundation.
[gzclient-3] Released under the Apache 2 License.
[gzclient-3] http://gazebosim.org
[gzclient-3]
[gzserver-2] Gazebo multi-robot simulator, version 11.10.2
[gzserver-2] Copyright (C) 2012 Open Source Robotics Foundation.
[gzserver-2] Released under the Apache 2 License.
[gzserver-2] http://gazebosim.org
[gzserver-2]
[spawn_entity.py-4] [INFO] [1752667856.804856341] [spawn_entity]: Spawn Entity started
[spawn_entity.py-4] [INFO] [1752667856.805229257] [spawn_entity]: Loading entity published on topic /robot_description
[spawn_entity.py-4] [INFO] [1752667856.807024211] [spawn_entity]: Waiting for entity xml on /robot_description
[gzserver-2] [Wrn] [gazebo_ros_init.cpp:178]
[gzserver-2] # # ####### ####### ### ##### #######
[gzserver-2] ## # # # # # # # #
[gzserver-2] # # # # # # # # #
[gzserver-2] # # # # # # # # #####
[gzserver-2] # # # # # # # # #
[gzserver-2] # ## # # # # # # #
[gzserver-2] # # ####### # ### ##### #######
[gzserver-2]
[gzserver-2] This version of Gazebo, now called Gazebo classic, reaches end-of-life
[gzserver-2] in January 2025. Users are highly encouraged to migrate to the new Gazebo
[gzserver-2] using our migration guides (https://gazebosim.org/docs/latest/gazebo_classic_migration?utm_source=gazebo_ros_pkgs&utm_medium=cli)
[gzserver-2]
[gzserver-2]
[spawn_entity.py-4] [INFO] [1752667856.911160252] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30
[spawn_entity.py-4] [INFO] [1752667856.911831738] [spawn_entity]: Waiting for service /spawn_entity
[gzserver-2] [Msg] Waiting for master.
[gzserver-2] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
[gzserver-2] [Msg] Publicized address: 192.168.28.130
[gzserver-2] [Err] [RTShaderSystem.cc:480] Unable to find shader lib. Shader generating will fail. Your GAZEBO_RESOURCE_PATH is probably improperly set. Have you sourced <prefix>/share/gazebo/setup.bash?
[gzclient-3] [Msg] Waiting for master.
[gzclient-3] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
[gzclient-3] [Msg] Publicized address: 192.168.28.130
[gzclient-3] [Err] [RTShaderSystem.cc:480] Unable to find shader lib. Shader generating will fail. Your GAZEBO_RESOURCE_PATH is probably improperly set. Have you sourced <prefix>/share/gazebo/setup.bash?
[gzclient-3] [Wrn] [GuiIface.cc:120] Could not find the Qt platform plugin "wayland" in ""
[spawn_entity.py-4] [INFO] [1752667857.956423711] [spawn_entity]: Calling service /spawn_entity
[gzserver-2] [Msg] Loading world file [/home/ub/chapt6/chapt6_ws/install/fishbot_description/share/fishbot_description/world/custom_room.world]
[gzserver-2] [Err] [RenderEngine.cc:197] Failed to initialize scene
[gzserver-2] gzserver: /usr/include/boost/smart_ptr/shared_ptr.hpp:728: typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = gazebo::rendering::Scene; typename boost::detail::sp_member_access<T>::type = gazebo::rendering::Scene*]: Assertion `px != 0' failed.
[ERROR] [gzserver-2]: process has died [pid 4597, exit code -6, cmd 'gzserver /home/ub/chapt6/chapt6_ws/install/fishbot_description/share/fishbot_description/world/custom_room.world --verbose -slibgazebo_ros_init.so -slibgazebo_ros_factory.so -slibgazebo_ros_force_system.so'].
[gzserver-2]
[gzclient-3] [Err] [Scene.cc:227] Service call[/shadow_caster_material_name] timed out
[gzclient-3] [Err] [Scene.cc:249] Service call[/shadow_caster_render_back_faces] timed out
[gzclient-3] [Err] [RenderEngine.cc:197] Failed to initialize scene
[gzclient-3] [Err] [GLWidget.cc:177] GLWidget could not create a scene. This will likely result in a blank screen.
[gzclient-3] gzclient: /usr/include/boost/smart_ptr/shared_ptr.hpp:728: typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = gazebo::rendering::Camera; typename boost::detail::sp_member_access<T>::type = gazebo::rendering::Camera*]: 断言 "px != 0" 失败。
[ERROR] [gzclient-3]: process has died [pid 4599, exit code -6, cmd 'gzclient --gui-client-plugin=libgazebo_ros_eol_gui.so --verbose'].
[gzclient-3]
^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)
[robot_state_publisher-1] [INFO] [1752667879.936981925] [rclcpp]: signal_handler(signum=2)
[spawn_entity.py-4] Traceback (most recent call last):
[spawn_entity.py-4] File "/opt/ros/humble/lib/gazebo_ros/spawn_entity.py", line 372, in <module>
[spawn_entity.py-4] main()
[spawn_entity.py-4] File "/opt/ros/humble/lib/gazebo_ros/spawn_entity.py", line 367, in main
[spawn_entity.py-4] exit_code = spawn_entity_node.run()
[spawn_entity.py-4] File "/opt/ros/humble/lib/gazebo_ros/spawn_entity.py", line 228, in run
[spawn_entity.py-4] success = self._spawn_entity(entity_xml, initial_pose, spawn_service_timeout)
[spawn_entity.py-4] File "/opt/ros/humble/lib/gazebo_ros/spawn_entity.py", line 290, in _spawn_entity
[spawn_entity.py-4] rclpy.spin_once(self)
[spawn_entity.py-4] File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/init.py", line 206, in spin_once
[spawn_entity.py-4] executor.spin_once(timeout_sec=timeout_sec)
[spawn_entity.py-4] File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 751, in spin_once
[spawn_entity.py-4] self._spin_once_impl(timeout_sec)
[spawn_entity.py-4] File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 740, in _spin_once_impl
[spawn_entity.py-4] handler, entity, node = self.wait_for_ready_callbacks(timeout_sec=timeout_sec)
[spawn_entity.py-4] File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 723, in wait_for_ready_callbacks
[spawn_entity.py-4] return next(self._cb_iter)
[spawn_entity.py-4] File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 620, in _wait_for_ready_callbacks
[spawn_entity.py-4] wait_set.wait(timeout_nsec)
[spawn_entity.py-4] KeyboardInterrupt
[ERROR] [spawn_entity.py-4]: process has died [pid 4601, exit code -2, cmd '/opt/ros/humble/lib/gazebo_ros/spawn_entity.py -topic /robot_description -entity fishbot --ros-args'].
[INFO] [robot_state_publisher-1]: process has finished cleanly [pid 4595]
shaannj@shaannj-virtual-machine:~$ sudo apt install ros-humble-tf-transformations
[sudo] shaannj 的密码:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成
下列【新】软件包将被安装:
ros-humble-tf-transformations
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 276 个软件包未被升级。
需要下载 19.6 kB 的归档。
解压缩后会消耗 110 kB 的额外空间。
错误:1 http://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu jammy/main amd64 ros-humble-tf-transformations amd64 1.1.0-1jammy.20250325.170033
404 Not Found [IP: 2402:f000:1:400::2 80]
E: 无法下载 http://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu/pool/main/r/ros-humble-tf-transformations/ros-humble-tf-transformations_1.1.0-1jammy.20250325.170033_amd64.deb 404 Not Found [IP: 2402:f000:1:400::2 80]
E: 有几个软件包无法下载,要不运行 apt-get update 或者加上 --fix-missing 的选项再试试?
如题,楼主的ubuntu安装在win11的wsl2上,
numpy是安装在win系统中的,
但是根据AI,一般来说ros2调用numpy,会直接链接到ubuntu之外的numpy即win上的那个。
然后楼主根据AI的建议,重新设置了这个链接。
楼主问AI结果如下:
708ffdef-2232-49d7-a35f-c289188fd931-image.png
重新设置的代码如下。
555e9364-eba2-492b-b4f1-f627cc0fbbd8-image.png
起因:楼主正在学小鱼教程里手搓python节点的练习,colcon和source都正常,也已经安装了numpy,但是ros2 run 的时候报错。报错内容如下。
ros2 run village_li li4_node
Traceback (most recent call last):
File "/root/town_ws/install/village_li/lib/village_li/li4_node", line 33, in <module>
sys.exit(load_entry_point('village_li==0.0.0', 'console_scripts', 'li4_node')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/town_ws/install/village_li/lib/python3.12/site-packages/village_li/li4.py", line 7, in main
li4_node = Node('li4') # 创建节点
^^^^^^^^^^^
File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/node.py", line 240, in init
self._parameter_service = ParameterService(self)
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/parameter_service.py", line 35, in init
node.create_service(
File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/node.py", line 1725, in create_service
check_is_valid_srv_type(srv_type)
File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/type_support.py", line 51, in check_is_valid_srv_type
check_for_type_support(srv_type)
File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/type_support.py", line 29, in check_for_type_support
msg_or_srv_type.class.import_type_support()
File "/opt/ros/jazzy/lib/python3.12/site-packages/rcl_interfaces/srv/_describe_parameters.py", line 527, in import_type_support
_describe_parameters.Metaclass_DescribeParameters_Event.import_type_support()
File "/opt/ros/jazzy/lib/python3.12/site-packages/rcl_interfaces/srv/_describe_parameters.py", line 341, in import_type_support
from service_msgs.msg import ServiceEventInfo
File "/opt/ros/jazzy/lib/python3.12/site-packages/service_msgs/msg/init.py", line 1, in <module>
from service_msgs.msg._service_event_info import ServiceEventInfo # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ros/jazzy/lib/python3.12/site-packages/service_msgs/msg/_service_event_info.py", line 18, in <module>
import numpy # noqa: E402, I100
^^^^^^^^^^^^
ModuleNotFoundError: No module named 'numpy'
[ros2run]: Process exited with failure 1
希望各位大神帮帮忙呀!小仙什么都会做的(跪
项目地址:https://github.com/robomaster-oss/rmoss_gazebo.git
系统环境:
Ubuntu22.04
Ros2Humble
笔记本双系统,非ARM架构
缺少ros_gz_bridge这个包,尝试通过apt安装:sudo apt install ros-humble-ros-gz-bridge
报错
查看官网的文档,使用官方的推荐ROS2Humble下载方法:sudo apt-get install ros-${ROS_DISTRO}-ros-gz还是出现同样的报错
spaaaaace@spaaaaace-DRA-XX:~/Code/HBUT2025_rm_vision/lc_navigation/lc_navigation_2025/simulation_ws$ sudo apt-get install ros-${ROS_DISTRO}-ros-gz 正在读取软件包列表... 完成 正在分析软件包的依赖关系树... 完成 正在读取状态信息... 完成 没有可用的软件包 ros-humble-ros-gz,但是它被其它的软件包引用了。 这可能意味着这个缺失的软件包可能已被废弃, 或者只能在其他发布源中找到 E: 软件包 ros-humble-ros-gz 没有可安装候选尝试过换源,无果,求助
配置好雷达的wifi_ssid、wifi_pswd、server_ip,net_mode为默认的tcp
将跳帽修改到串口模式,跳帽接法如下图所示
8246065e-2fc2-4743-a448-47e4948113d9-图片.png
二、启动服务重新拉取docker镜像并启动服务
xhost + && sudo docker run -it --rm -p 8889:8889 -p 8889:8889/udp --privileged -v /dev:/dev -v /tmp/.X11-unix:/tmp/.X11-unix --device /dev/snd -e DISPLAY=unix$DISPLAY registry.cn-hangzhou.aliyuncs.com/fishros/fishbot_laser启动完成后,可以看到如下界面
ef868a6c-a4fa-4053-ab72-79538b7c20fd-图片.png
三、驱动雷达保证雷达板在通电状态,
选择1驱动雷达,回车,
选择3有线串口,回车,
接着选择1 /dev/ttyUSB0。我们尝试驱动雷达
25d915a2-b360-4cab-9c6f-88a7d68c5561-图片.png
等待雷达连接,未连接成功请先检查跳线帽是否更换到串口模式
驱动成功后,我们可以打开一个新的终端,输入ros2 topic list,查看是否有scan话题。
ros2 topic list3fdbe9e5-f359-4ba2-8f79-48cecdb14cb6-图片.png
此时在终端中打开rviz2,
7b15222c-c0e4-4784-8b50-4760957a6e15-图片.png
修改fixed frame为laser_frame,左下角点击add---by topic,添加LaserScan,
cfc168a2-1435-4d0e-8e3c-de655e0c6a84-图片.png
接着修改Qos为Best Effort,接着就能看到雷达的点云数据了
移动雷达,观察点云的变化
2b11e0a1-dafc-4c29-b667-23621795211a-图片.png
四、手动建图测试使用Crtl+C,打断驱动的运行,回车,
选择4返回上级
选择2建图测试
选择3有线串口
选择1/dev/ttyUSB0
c6ff60e9-e0ff-43aa-8095-8119ed160de2-图片.png
等待片刻,你应该可以直接看到一张地图出现
ae323491-a053-42a4-89de-c5f51db9cb2b-图片.png
你可以将FishBot放到地上,或者用手拿着fishbot,慢慢走一圈,观察地图的变化,也可以直接用键盘控制节点(需要根据上节教程个启动Agent)控制fishbot走一圈,看看能否得到完整的地图。
d0503e59-b7f1-4b8e-8cdb-aa08b452b9b8-图片.png
我们需要使用一个叫做nav2_map_server的工具。
安装nav2_map_server
保存地图
ros2 run nav2_map_server map_saver_cli --help可以看到有下面的用法
Usage: map_saver_cli [arguments] [--ros-args ROS remapping args] Arguments: -h/--help -t <map_topic> -f <mapname> --occ <threshold_occupied> --free <threshold_free> --fmt <image_format> --mode trinary(default)/scale/raw NOTE: --ros-args should be passed at the end of command line我们的地图话题为map,文件名字我们用fishbot_map,所以有下面这个这样写的命令行。
ros2 run nav2_map_server map_saver_cli -t map -f fishbot_map
接着我们就可以得到下面的两个文件
这两个文件就是对当前地图保存下来的文件,其中.pgm是地图的数据文件,.yaml后缀的是地图的描述文件。
跳帽在flash模式下,扫描配置,修改net_mode为udp,针对建图卡顿网络问题优化,udp对网络差的环境有更好的兼容性
82d83fa2-6063-4ba9-b445-aac19b873472-图片.png
配置完成后,将跳线帽调整到WIFI模式
cdfb78a8-adeb-45d1-9949-c11d9d45b756-图片.png
三、启动服务重新拉取docker镜像并运行:
xhost + && sudo docker run -it --rm -p 8889:8889 -p 8889:8889/udp -v /dev:/dev -v /tmp/.X11-unix:/tmp/.X11-unix --device /dev/snd -e DISPLAY=unix$DISPLAY registry.cn-hangzhou.aliyuncs.com/fishros/fishbot_laser启动完成后,可以看到如下页面
cc346c82-58de-441c-b770-9936d52d3b10-图片.png
四、驱动测试保证雷达板在通电状态
选择1驱动雷达,回车
选择2无线udp,回车,我们尝试驱动雷达
0bb1f40f-b525-455e-aa19-62b992e68ebb-图片.png
等待激光雷达udp连接
如果未连接成功,请检查是否符合下述现象和问题:
驱动成功后,我们可以打开一个新的终端,输入ros2 topic list,查看是否有/scan话题。 ros2 topic list
此时在终端中打开rviz2,修改fixed frame为laser_frame,左下角点击add---by topic,添加LaserScan,
c6ea58a3-0aab-4a9e-8a0f-bb00e894bea8-图片.png
接着修改Qos为Best Effort,接着就能看到雷达的点云数据了
移动雷达,观察点云的变化
f0e48929-c362-43bc-9909-5df28d01c4d2-图片.png
五、手动建图测试使用Crtl+C,打断驱动的运行,回车,
选择4返回上级
选择2建图测试
选择2无线udp
ae1b462f-0fe0-441e-91f1-86ba5a29567f-图片.png
等待片刻,你应该可以直接看到一张地图出现
a5cdca2e-f532-4a26-a6be-19c964720650-图片.png
你可以将FishBot放到地上,或者用手拿着fishbot,慢慢走一圈,观察地图的变化,也可以直接用键盘控制节点(需要根据上节教程个启动Agent)控制fishbot走一圈,看看能否得到完整的地图。
22bde3c5-5fee-4397-b669-1be9897ce4d3-图片.png
六、保存地图我们需要使用一个叫做nav2_map_server的工具。
安装nav2_map_server
保存地图
ros2 run nav2_map_server map_saver_cli --help可以看到有下面的用法
Usage: map_saver_cli [arguments] [--ros-args ROS remapping args] Arguments: -h/--help -t <map_topic> -f <mapname> --occ <threshold_occupied> --free <threshold_free> --fmt <image_format> --mode trinary(default)/scale/raw NOTE: --ros-args should be passed at the end of command line我们的地图话题为map,文件名字我们用fishbot_map,所以有下面这个这样写的命令行。
ros2 run nav2_map_server map_saver_cli -t map -f fishbot_map
接着我们就可以得到下面的两个文件
这两个文件就是对当前地图保存下来的文件,其中.pgm是地图的数据文件,.yaml后缀的是地图的描述文件。
配置助手配置雷达时net_mode默认为tcp
当配置完成后,需要将跳线帽调整到WIFI模式,这样雷达板将会把来自雷达的数据通过wifi转发给tcp服务。
0f1cc291-deda-42eb-a52c-46c6e30836d7-图片.png
调整完后,跳线帽接法如上图所示。
二、启动服务打开电脑,输入下面的指令,我们使用docker来下载雷达相关的驱动。
xhost + && sudo docker run -it --rm -p 8889:8889 -p 8889:8889/udp -v /dev:/dev -v /tmp/.X11-unix:/tmp/.X11-unix --device /dev/snd -e DISPLAY=unix$DISPLAY registry.cn-hangzhou.aliyuncs.com/fishros/fishbot_laser下载完成后,你可以看到下面的界面
0c4c4005-51ee-422b-8f56-2711b4433c4b-图片.png
保持雷达板在通电状态,输入1,回车,选择1无线tcp,我们尝试驱动雷达
b808fcb5-5643-486f-95a5-3a2b57ecec37-图片.png
看到上述界面,表示驱动成功。
如果没有看到上述界面,请检查是否符合下述现象和问题:
驱动成功后,我们可以打开一个新的终端,输入ros2 topic list,查看是否有scan话题。 ros2 topic list
5426580f-7835-43ed-86cc-71c6362c61b6-图片.png
在rviz中可视化点云数据:
此时打开rviz2,左下角点击add---by topic,添加LaserScan,并修改fixed frame为laser_frame
96f93e0e-75cb-481e-8ee6-7ad521fa8b87-图片.png
修改Qos为Best Effort,接着就能看到雷达的点云数据了
移动雷达,观察点云的变化
f69d084e-b2d7-45f4-9fd5-83e2835a60bf-图片.png
使用Crtl+C,打断驱动的运行,回车,
选择4返回上级
选择2建图测试
选择1无线tcp
52ade1bc-f6d6-4bc7-ba28-2602093c240c-图片.png
等待片刻,你应该可以直接看到一张地图出现
f3cf1f46-c483-4c2e-8890-569c22f0ee3b-图片.png
你可以将FishBot放到地上,或者用手拿着fishbot,慢慢走一圈,观察地图的变化,也可以直接用键盘控制节点(需要根据上节教程个启动Agent)控制fishbot走一圈,看看能否得到完整的地图。
ef03f587-7142-4062-b0c0-ddb76fddc692-图片.png
我们需要使用一个叫做nav2_map_server的工具。
安装nav2_map_server
保存地图
ros2 run nav2_map_server map_saver_cli --help可以看到有下面的用法
Usage: map_saver_cli [arguments] [--ros-args ROS remapping args] Arguments: -h/--help -t <map_topic> -f <mapname> --occ <threshold_occupied> --free <threshold_free> --fmt <image_format> --mode trinary(default)/scale/raw NOTE: --ros-args should be passed at the end of command line我们的地图话题为map,文件名字我们用fishbot_map,所以有下面这个这样写的命令行。
ros2 run nav2_map_server map_saver_cli -t map -f fishbot_map
接着我们就可以得到下面的两个文件
这两个文件就是对当前地图保存下来的文件,其中.pgm是地图的数据文件,.yaml后缀的是地图的描述文件。
e509d2e7-d36f-4582-98f3-e057062825a2-图片.png
为什么下面一直在等待?
源码
import rclpy
from rclpy.node import Node
from chapt4_interfaces.srv import FaceDetector
import face_recognition
import cv2
from ament_index_python.packages import get_package_share_directory #获取功能包share目录绝对路径
import os
from cv_bridge import CvBridge
import time
class FaceDetectNode(Node):
def init(self):
super().init('face_detect_node')
self.service_ = self.create_service(FaceDetector,'face_detect',self.detect_face_callback)
self.bridge = CvBridge()
self.number_of_times_to_upsample = 1
self.model = 'hog'
self.default_image_path = os.path.join(get_package_share_directory('demo_python_service') ,'resource/default.jpeg')
self.get_logger().info("人脸检测服务已经启动!")
def main():
rclpy.init()
node = FaceDetectNode()
rclpy.spin(node)
rclpy.shutdown()
ls@ls-OMEN-Gaming-Laptop-16-ae0xxx:~/chapter6/chapter6_ws$ ros2 launch fishbot_description display_robot.launch.py
[INFO] [launch]: All log files can be found below /home/ls/.ros/log/2025-07-14-22-50-13-406014-ls-OMEN-Gaming-Laptop-16-ae0xxx-7918
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [robot_state_publisher-1]: process started with pid [7920]
[INFO] [joint_state_publisher-2]: process started with pid [7922]
[INFO] [rviz2-3]: process started with pid [7924]
[robot_state_publisher-1] [INFO] [1752504613.535700714] [robot_state_publisher]: got segment back_caster_link
[robot_state_publisher-1] [INFO] [1752504613.535768118] [robot_state_publisher]: got segment base_footprint
[robot_state_publisher-1] [INFO] [1752504613.535774413] [robot_state_publisher]: got segment base_link
[robot_state_publisher-1] [INFO] [1752504613.535777807] [robot_state_publisher]: got segment camera_link
[robot_state_publisher-1] [INFO] [1752504613.535781003] [robot_state_publisher]: got segment front_caster_link
[robot_state_publisher-1] [INFO] [1752504613.535784553] [robot_state_publisher]: got segment imu_link
[robot_state_publisher-1] [INFO] [1752504613.535787920] [robot_state_publisher]: got segment laser_cylinder_link
[robot_state_publisher-1] [INFO] [1752504613.535791156] [robot_state_publisher]: got segment laser_link
[robot_state_publisher-1] [INFO] [1752504613.535794234] [robot_state_publisher]: got segment left_wheel_link
[robot_state_publisher-1] [INFO] [1752504613.535797336] [robot_state_publisher]: got segment right_wheel_link
[rviz2-3] /opt/ros/humble/lib/rviz2/rviz2: symbol lookup error: /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0: undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE
[ERROR] [rviz2-3]: process has died [pid 7924, exit code 127, cmd '/opt/ros/humble/lib/rviz2/rviz2 -d /home/ls/chapter6/chapter6_ws/install/fishbot_description/share/fishbot_description/config/rviz/display_model.rviz --ros-args'].
[joint_state_publisher-2] [INFO] [1752504613.756091603] [joint_state_publisher]: Waiting for robot_description to be published on the robot_description topic...
^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)
[robot_state_publisher-1] [INFO] [1752504624.928440216] [rclcpp]: signal_handler(signum=2)
[INFO] [robot_state_publisher-1]: process has finished cleanly [pid 7920]
[INFO] [joint_state_publisher-2]: process has finished cleanly [pid 7922]
版块
-
1.3k
主题4.9k
帖子 -
452
主题3.0k
帖子 -
67
主题261
帖子 -
1.1k
主题4.3k
帖子 -
1.0k
主题3.7k
帖子 -
5
主题11
帖子 -
358
主题1.6k
帖子