参照ROS2官方例程,在server端配置cancel_callback,在client端调用cancel_goal_async,但是不生效!
链接:https://github.com/ros2/examples/blob/master/rclpy/actions/minimal_action_client/examples_rclpy_minimal_action_client/client_cancel.py
-
-
-
参照ROS2官方例程,在server端配置cancel_callback,在client端调用cancel_goal_async,但是不生效!
链接:https://github.com/ros2/examples/blob/master/rclpy/actions/minimal_action_client/examples_rclpy_minimal_action_client/client_cancel.py -
你的应用版本过低,请升至最新版本后登陆
-
使用easy_handeye 标定点击plan找不到没有good plan,
6507e0ec-ba1d-4c7b-af02-bf6809d8971b-image.png多试几次姿势后找到了解决plan 但是没有execute
会报这个错误
7aff9030-f65e-46e0-a068-854ab2e5caf2-image.png -
最近发了这样一个问题,在Intel 13代 CPU上 分别是 i9-13900HX i7-13700KF i5-13600KF 上安装ROS2 humble,然后播放ros2 bag,打开rviz2 查看点云数据,如下图,当选择Best Effort时,会出现点云丢帧现象,表现为画面卡顿。用ros2 topic hz 查看点云话题,显示远低于10hz
在c++代码实现中,如果为下午中RMW QOS POLICY RELIABILITY BEST EFFORT,则订阅点云频率很低,改为RMW QOS POLICY RELIABILITY RELIABLE时则正常。
以上现象在3台设备上的都出现,系统为Ubuntu22.04.4 内核版本为 6.5
不知道各位安装在13代 intel cpu上 ubuntu22.04 ros2 humble 环境下有无上述现象
FrsrCmBBxHA77E_svnfxFU0Ik6-U.jpg FoCjLu4brYqduvRBXcC4M4FWXety.png -
远程连接指令ssh -X unitree@xxxxxx;此步没有问题
但是运行rosrun rviz rviz后出现如下问题
本机ubuntu版本为18.04-melodicdccc7b17-4af4-4c96-b25d-63dbc6a96244-图片.png
-
launch文件:09fca5a1-9ae1-4f6c-95aa-f1a02852c1e5-image.png
setup.py文件:0bf1f2c5-9db4-4585-ac3c-20d2852c87be-image.png
运行时报错ros2 launch charging_hub_recognition launch_display.launch.py
0f19054a-dcc9-484e-96be-594f9b1c1d4c-image.png
这个命令可以:ros2 run charging_hub_recognition charging_hub_recognition 运行,为什么?
用launch启动自己本身不可以吗? -
sudo apt install ros-noetic-desktop-full
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
ros-noetic-desktop-full 已经是最新版 (1.5.0-1focal.20240402.145422)。
您也许需要运行“apt --fix-broken install”来修正上面的错误。
下列软件包有未满足的依赖关系:
python3-rosdep-modules : 依赖: python3-rospkg-modules (>= 1.4.0) 但是它将不会被安装
依赖: python3-catkin-pkg-modules (>= 0.4.0) 但是它将不会被安装
python3-rosdistro-modules : 依赖: python3-catkin-pkg-modules 但是它将不会被安装
依赖: python3-rospkg-modules 但是它将不会被安装
ros-noetic-rospack : 依赖: python3-catkin-pkg-modules 但是它将不会被安装
ros-noetic-rqt-gui : 依赖: python3-rospkg-modules 但是它将不会被安装
ros-noetic-rqt-robot-monitor : 依赖: python3-rospkg-modules 但是它将不会被安装
E: 有未能满足的依赖关系。请尝试不指明软件包的名字来运行“apt --fix-broken install”(也可以指定一个解决办法)。
jinjieyan@jinjieyan-virtual- -
[ERROR] [cartographer_node-2]: process has died [pid 10541, exit code -6, cmd '/opt/ros/humble/lib/cartographer_ros/cartographer_node -configuration_directory /opt/ros/humble/share/cartographer_ros/configuration_files -configuration_basename map_builder.lua --ros-args --params-file /tmp/launch_params_z3tr0g8s -r echoes:=horizontal_laser_2d'].
-
369baaca-2beb-4f8b-8068-2f6a57153669-image.png
再之后
005f7164-5709-42f5-a039-fb7e274dea83-image.png -
下列软件包有未满足的依赖关系:
ros-melodic-desktop-full : 依赖: ros-melodic-desktop 但是它将不会被安装
依赖: ros-melodic-perception 但是它将不会被安装
依赖: ros-melodic-simulators 但是它将不会被安装
依赖: ros-melodic-urdf-sim-tutorial 但是它将不会被安装
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。
Run CMD Task:[sudo apt install ros-melodic-desktop-full -y]
[-]Result:code:100 dic-urdf-sim-tutorial 但是它将不会被安装 -
四驱板在运行动手学ROS2中的pid控制实现教程中程序只能控制两个电机的速度
使用四驱板学习pid控制过程中我发现在我按照电路图修改引脚部分代码后仍只能控制前两路电机(注释部分我没有修改)
#include <Arduino.h> #include <micro_ros_platformio.h> // 包含用于 ESP32 的 micro-ROS PlatformIO 库 #include <WiFi.h> // 包含 ESP32 的 WiFi 库 #include <rcl/rcl.h> // 包含 ROS 客户端库 (RCL) #include <rclc/rclc.h> // 包含用于 C 的 ROS 客户端库 (RCLC) #include <rclc/executor.h> // 包含 RCLC 执行程序库,用于执行订阅和发布 #include <geometry_msgs/msg/twist.h> // 包含 ROS2 geometry_msgs/Twist 消息类型 #include <Esp32PcntEncoder.h> // 包含用于计数电机编码器脉冲的 ESP32 PCNT 编码器库 #include <Esp32McpwmMotor.h> // 包含使用 ESP32 的 MCPWM 硬件模块控制 DC 电机的 ESP32 MCPWM 电机库 #include <PidController.h> // 包含 PID 控制器库,用于实现 PID 控制 Esp32PcntEncoder encoders[4]; // 创建一个长度为 4 的 ESP32 PCNT 编码器数组 rclc_executor_t executor; // 创建一个 RCLC 执行程序对象,用于处理订阅和发布 rclc_support_t support; // 创建一个 RCLC 支持对象,用于管理 ROS2 上下文和节点 rcl_allocator_t allocator; // 创建一个 RCL 分配器对象,用于分配内存 rcl_node_t node; // 创建一个 RCL 节点对象,用于此基于 ESP32 的机器人小车 rcl_subscription_t subscriber; // 创建一个 RCL 订阅对象,用于订阅 ROS2 消息 geometry_msgs__msg__Twist sub_msg; // 创建一个 ROS2 geometry_msgs/Twist 消息对象 Esp32McpwmMotor motor; // 创建一个 ESP32 MCPWM 电机对象,用于控制 DC 电机 float out_motor_speed[4]; // 创建一个长度为 2 的浮点数数组,用于保存输出电机速度 float current_speeds[4]; // 创建一个长度为 2 的浮点数数组,用于保存当前电机速度 PidController pid_controller[4]; // 创建PidController的两个对象 void twist_callback(const void *msg_in) { const geometry_msgs__msg__Twist *twist_msg = (const geometry_msgs__msg__Twist *)msg_in; float linear_x = twist_msg->linear.x; // 获取 Twist 消息的线性 x 分量 float angular_z = twist_msg->angular.z; // 获取 Twist 消息的角度 z 分量 if (linear_x == 0 && angular_z == 0) // 如果 Twist 消息没有速度命令 { pid_controller[0].update_target(0); // 更新控制器的目标值 pid_controller[1].update_target(0); pid_controller[2].update_target(0); pid_controller[3].update_target(0); motor.updateMotorSpeed(0, 0); // 停止第一个电机 motor.updateMotorSpeed(1, 0); // 停止第二个电机 motor.updateMotorSpeed(2, 0); motor.updateMotorSpeed(3, 0); return; // 退出函数 } // for(int index=0;index<4;index++) // { // if(pid_controller[index].target_==0) // { // // motor.updateMotorSpeed(index,0); // out_motor_speed[index]=0; // } // else{ // pid_controller[index].update_target(linear_x*1000); // } // } // if(pid_controller) // // 根据线速度和角速度控制两个电机的转速 if (linear_x != 0) { pid_controller[0].update_target(linear_x * 1000); // 使用mm/s作为target pid_controller[1].update_target(linear_x * 1000); pid_controller[2].update_target(linear_x * 1000); pid_controller[3].update_target(linear_x * 1000); } } // 这个函数是一个后台任务,负责设置和处理与 micro-ROS 代理的通信。 void microros_task(void *param) { // 设置 micro-ROS 代理的 IP 地址。 IPAddress agent_ip; agent_ip.fromString("192.168.31.121");//192.168.110.115 // 使用 WiFi 网络和代理 IP 设置 micro-ROS 传输层。 set_microros_wifi_transports("Xiaomi_E2EF", "opencvrobot", agent_ip, 8888); // 等待 2 秒,以便网络连接得到建立。 delay(2000); // 设置 micro-ROS 支持结构、节点和订阅。 allocator = rcl_get_default_allocator(); rclc_support_init(&support, 0, NULL, &allocator); rclc_node_init_default(&node, "esp32_car", "", &support); rclc_subscription_init_default( &subscriber, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(geometry_msgs, msg, Twist), "/cmd_vel"); // 设置 micro-ROS 执行器,并将订阅添加到其中。 rclc_executor_init(&executor, &support.context, 1, &allocator); rclc_executor_add_subscription(&executor, &subscriber, &sub_msg, &twist_callback, ON_NEW_DATA); // 循环运行 micro-ROS 执行器以处理传入的消息。 while (true) { delay(100); rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100)); } } // 这个函数根据编码器读数更新两个轮子速度。 void update_speed() { // 初始化静态变量以存储上一次更新时间和编码器读数。 static uint64_t last_update_time = millis(); static int64_t last_ticks[4]; // 获取自上次更新以来的经过时间。 uint64_t dt = millis() - last_update_time; if (dt == 0) return; // 获取当前的编码器读数并计算当前的速度。 int32_t pt[4]; pt[0] = encoders[0].getTicks() - last_ticks[0]; pt[1] = encoders[1].getTicks() - last_ticks[1]; pt[2] = encoders[2].getTicks() - last_ticks[2]; pt[3] = encoders[3].getTicks() - last_ticks[3]; current_speeds[0] = float(pt[0] * 0.1051566) / dt * 1000; current_speeds[1] = float(pt[1] * 0.1051566) / dt * 1000; current_speeds[2] = float(pt[2] * 0.1051566) / dt * 1000; current_speeds[3] = float(pt[3] * 0.1051566) / dt * 1000; // 更新上一次更新时间和编码器读数。 last_update_time = millis(); last_ticks[0] = encoders[0].getTicks(); last_ticks[1] = encoders[1].getTicks(); last_ticks[2] = encoders[2].getTicks(); last_ticks[3] = encoders[3].getTicks(); } void setup() { // 初始化串口通信,波特率为115200 Serial.begin(115200); // 将两个电机分别连接到引脚22、23和12、13上 motor.attachMotor(0, 12, 22); motor.attachMotor(1, 17, 16); motor.attachMotor(2, 33, 25); motor.attachMotor(3, 26, 27); // motor.attachMotor(0, 33, 25); // 将电机0连接到引脚33和引脚25 // motor.attachMotor(1, 26, 27); // 将电机1连接到引脚26和引脚27 // motor.attachMotor(2, 12, 22); // 将电机2连接到引脚12和引脚22 // motor.attachMotor(3, 16, 17); // 将电机3连接到引脚16和引脚17 // 在引脚32、33和26、25上初始化两个编码器 // encoders[0].init(0, 36, 39); // encoders[1].init(1, 35, 32); // encoders[2].init(2, 14, 23); // encoders[3].init(3, 13, 15); encoders[0].init(0, 14, 23); encoders[1].init(1, 13, 15); encoders[2].init(2, 36, 39); encoders[3].init(3, 35, 32); // 初始化PID控制器的kp、ki和kd pid_controller[0].update_pid(0.625, 0.125, 0.0); pid_controller[1].update_pid(0.625, 0.125, 0.0); pid_controller[2].update_pid(0.625, 0.125, 0.0); pid_controller[3].update_pid(0.625, 0.125, 0.0); // 初始化PID控制器的最大输入输出,MPCNT大小范围在正负100之间 pid_controller[0].out_limit(-100, 100); pid_controller[1].out_limit(-100, 100); pid_controller[2].out_limit(-100, 100); pid_controller[3].out_limit(-100, 100); // 在核心0上创建一个名为"microros_task"的任务,栈大小为10240 xTaskCreatePinnedToCore(microros_task, "microros_task", 10240, NULL, 1, NULL, 0); } void loop() { // 更新电机速度 update_speed(); for (int index = 0; index < 4; index++) { // 目标速度为0时停止控制,解决 #https://fishros.org.cn/forum/topic/1372 问题 if (pid_controller[index].target_ == 0) { out_motor_speed[index] = 0; } else { // 使用 pid_controller 控制器对电机速度进行 PID 控制 out_motor_speed[index] = pid_controller[index].update(current_speeds[index]); } // 将 PID 控制器的输出值作为电机的目标速度进行控制0 motor.updateMotorSpeed(index, out_motor_speed[index]); // fishlog_debug("pid", "index:%d target:%f current:%f out=%f", index, pid_controller[index].target_, kinematics.motor_speed(index), out_motor_speed[index]); } // // 计算最新的电机输出值 // out_motor_speed[0] = pid_controller[0].update(current_speeds[0]); // out_motor_speed[1] = pid_controller[1].update(current_speeds[1]); // out_motor_speed[2] = pid_controller[2].update(current_speeds[2]); // out_motor_speed[3] = pid_controller[3].update(current_speeds[3]); // // 更新电机0和电机1的速度值 // motor.updateMotorSpeed(0, out_motor_speed[0]); // motor.updateMotorSpeed(1, out_motor_speed[1]); // motor.updateMotorSpeed(2, out_motor_speed[2]); // motor.updateMotorSpeed(3, out_motor_speed[3]); // 延迟10毫秒 delay(10); }
前面两个关于电机的例程运行起来都正常,应该不是驱动板和电机编码器的问题我在询问chatGPT后也不知道问题出现在哪里,查看了Esp32McpwmMotor.cpp后也没找到哪里出问题了
-
这是我在学习ros2通信基础的时候遇到的问题,以下是我的代码,我的代码和网上提供的代码整体逻辑应该是一致的,但是我在终端按crtl+c的时候会弹出signal_handler(signum=2),我不清楚这是什么意思;其次我还想请问:
if (!rclcpp::ok())
{
RCLCPP_ERROR(this->get_logger(), "等待服务的过程中被打断...");
return;
}
这段代码什么时候加上呢?我发现不加上这段代码,crtl+C就无法暂停我的程序
wang2.cpp
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"
#include "std_msgs/msg/u_int32.hpp"
#include "village_interfaces/srv/sell_novel.hpp"
#include <queue>using std::placeholders::_1;
using std::placeholders::_2;/*
创建一个类节点,名字叫做SingleDogNode,继承自Node.
*/
class SingleDogNode : public rclcpp::Node
{public:
sell_novels_callback_group = this->create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive); sell_server = this->create_service<village_interfaces::srv::SellNovel>("sell_novel", std::bind(&SingleDogNode::sell_novel_callback, this, _1, _2), rmw_qos_profile_services_default, sell_novels_callback_group); }
// 构造函数,有一个参数为节点名称
SingleDogNode(std::string name) : Node(name)
{
// 打印一句自我介绍
RCLCPP_INFO(this->get_logger(), "大家好,我是单身狗%s.", name.c_str());
// 创建一个订阅者来订阅李四写的小说,通过名字sexy_girl
sub_novel = this->create_subscription<std_msgs::msg::String>("sexy_girl", 10, std::bind(&SingleDogNode::topic_callback, this, _1));
// 创建发布者
pub_money = this->create_publisher<std_msgs::msg::UInt32>("sexy_girl_money", 10);private:
// 声明一个发布者(成员变量),用于给李四钱 rclcpp::Publisher<std_msgs::msg::UInt32>::SharedPtr pub_money; rclcpp::CallbackGroup::SharedPtr sell_novels_callback_group; rclcpp::Service<village_interfaces::srv::SellNovel>::SharedPtr sell_server; // maishu void sell_novel_callback(const village_interfaces::srv::SellNovel::Request::SharedPtr request, const village_interfaces::srv::SellNovel::Response::SharedPtr response) { RCLCPP_INFO(this->get_logger(), "shoudaole %d", request->money); unsigned int num = (int)request->money; if(num > novels_queue.size()) { RCLCPP_INFO(this->get_logger(), "%ld<%d", novels_queue.size(), num); rclcpp::Rate rate(1); while (novels_queue.size() < num) { if(!rclcpp::ok()) { RCLCPP_ERROR(this->get_logger(), "程序被终止了"); return ; } RCLCPP_INFO(this->get_logger(), "%ld", num - novels_queue.size()); rate.sleep(); } } RCLCPP_INFO(this->get_logger(), "%ld > %d", novels_queue.size(), num); for(int i = 0; i<(int)num; i++) { response->novels.push_back(novels_queue.front()); novels_queue.pop(); } } // 收到话题数据的回调函数 void topic_callback(const std_msgs::msg::String::SharedPtr msg) { // 新建一张人民币 std_msgs::msg::UInt32 money; money.data = 10; // 发送人民币给李四 pub_money->publish(money); novels_queue.push(msg->data); RCLCPP_INFO(this->get_logger(), "朕已阅:'%s',打赏李四:%d 元的稿费", msg->data.c_str(), money.data); };
std::queuestd::string novels_queue;
// 声明一个订阅者(成员变量),用于订阅小说
rclcpp::Subscription<std_msgs::msg::String>::SharedPtr sub_novel;};
int main(int argc, char argv)
{
rclcpp::init(argc, argv);
/产生一个Wang2的节点/
auto node = std::make_shared<SingleDogNode>("wang2");
rclcpp::executors::MultiThreadedExecutor executor;
executor.add_node(node);
/ 运行节点,并检测退出信号/
executor.spin();
rclcpp::shutdown();
return 0;
}zhang3.cpp#include "rclcpp/rclcpp.hpp"
#include "village_interfaces/srv/sell_novel.hpp"// 提前声明的占位符,留着创建客户端的时候用
using std::placeholders::_1;/*
创建一个类节点,名字叫做PoorManNode,继承自Node.
*/
class PoorManNode : public rclcpp::Node
{public:
void buy_novels() { while (!novel_client->wait_for_service(std::chrono::seconds(1))) { //等待时检测rclcpp的状态 if (!rclcpp::ok()) { RCLCPP_ERROR(this->get_logger(), "等待服务的过程中被打断..."); return; } RCLCPP_INFO(this->get_logger(), "等待服务端上线中"); } auto request = std::make_shared<village_interfaces::srv::SellNovel_Request>(); request->money = 5; novel_client->async_send_request(request, std::bind(&PoorManNode::novels_callback, this, _1)); }
/* 构造函数 */
PoorManNode(std::string name) : Node(name)
{
// 打印一句自我介绍
RCLCPP_INFO(this->get_logger(), "大家好,我是得了穷病的张三.");
novel_client = this->create_client<village_interfaces::srv::SellNovel>("sell_novel");
}private:
RCLCPP_INFO(this->get_logger(), "ok %ld", result->novels.size()); for(const std::string& novel:result->novels) { RCLCPP_INFO(this->get_logger(), "%s", novel.c_str()); } }
rclcpp::Client<village_interfaces::srv::SellNovel>::SharedPtr novel_client;
void novels_callback(rclcpp::Client<village_interfaces::srv::SellNovel>::SharedFuture response)
{
auto result = response.get();};
/主函数/
int main(int argc, char argv)
{
rclcpp::init(argc, argv);
/产生一个Zhang3的节点/
auto node = std::make_shared<PoorManNode>("zhang3");
node->buy_novels();
/ 运行节点,并检测rclcpp状态/
rclcpp::spin(node);
rclcpp::shutdown();
return 0;
} -
标题:fishbot雷达建图中断 提问:使用激光雷达进行测试建图时,开始建图不到一分钟出现报错,建图中断 问题描述: 具体细节和上下文:
) 驱动雷达
2) 建图测试
3) 退出
#? 1
UART2SOCKET:8888->/tmp/fishbot_laser
Prepare to Accept connect!
3 <socket.socket fd=6, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('172.17.0.2', 8888), raddr=('192.168.43.165', 62416)> 4
PTY: Opened /dev/pts/1 for 0.0.0.0:8888
[YDLIDAR INFO] Current ROS Driver Version: 1.4.5
[YDLIDAR]:SDK Version: 1.4.5
[YDLIDAR]:Lidar running correctly ! The health status: good
[YDLIDAR] Connection established in [/tmp/fishbot_laser][115200]:
Firmware version: 1.5
Hardware version: 1
Model: S4
Serial: 2020101300002268
[YDLIDAR]:Fixed Size: 360
[YDLIDAR]:Sample Rate: 3K
[YDLIDAR INFO] Current Sampling Rate : 3K
[YDLIDAR INFO] Now YDLIDAR is scanning ......
timout count: 1
[ERROR] [1713344387.186853131] [ydlidar_node]: Failed to get scan
timout count: 2
[ERROR] [1713344389.187233959] [ydlidar_node]: Failed to get scan
[ERROR] [1713344391.188039318] [ydlidar_node]: Failed to get scan
[ERROR] [1713344393.188949412] [ydlidar_node]: Failed to get scan
[ERROR] [1713344395.189370541] [ydlidar_node]: Failed to get scan
[ERROR] [1713344397.190185397] [ydlidar_node]: Failed to get scan
[ERROR] [1713344399.191660545] [ydlidar_node]: Failed to get scan
[ERROR] [1713344401.191919681] [ydlidar_node]: Failed to get scan
[ERROR] [1713344403.192957289] [ydlidar_node]: Failed to get scan
[ERROR] [1713344405.193506477] [ydlidar_node]: Failed to get scan
[ERROR] [1713344407.194619107] [ydlidar_node]: Failed to get scan
[ERROR] [1713344409.195089088] [ydlidar_node]: Failed to get scan#? 2
尝试过的解决方法:
[INFO] [launch]: All log files can be found below /root/.ros/log/2024-04-21-08-26-05-220524-08d262fab448-251
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [laser_x2-1]: process started with pid [252]
[INFO] [static_transform_publisher-2]: process started with pid [254]
[INFO] [cartographer_node-3]: process started with pid [256]
[INFO] [cartographer_occupancy_grid_node-4]: process started with pid [268]
[INFO] [rviz2-5]: process started with pid [270]
[static_transform_publisher-2] [WARN] [1713687965.313838746] []: Old-style arguments are deprecated; see --help for new-style arguments
[static_transform_publisher-2] [INFO] [1713687965.325799112] [static_tf_pub_laser]: Spinning until stopped - publishing transform
[static_transform_publisher-2] translation: ('0.000000', '0.000000', '0.000000')
[static_transform_publisher-2] rotation: ('0.000000', '0.000000', '0.000000', '1.000000')
[static_transform_publisher-2] from 'base_link' to 'laser_frame'
[rviz2-5] QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
[cartographer_node-3] [INFO] [1713687965.407037161] [cartographer logger]: I0421 08:26:05.000000 256 configuration_file_resolver.cc:41] Found '/workspace/install/fishbot_laser_driver/share/fishbot_laser_driver/config/fishbot_laser_2d.lua' for 'fishbot_laser_2d.lua'.
[cartographer_node-3] [INFO] [1713687965.407333627] [cartographer logger]: I0421 08:26:05.000000 256 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/map_builder.lua' for 'map_builder.lua'.
[cartographer_node-3] [INFO] [1713687965.407357973] [cartographer logger]: I0421 08:26:05.000000 256 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/map_builder.lua' for 'map_builder.lua'.
[cartographer_node-3] [INFO] [1713687965.407391739] [cartographer logger]: I0421 08:26:05.000000 256 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/pose_graph.lua' for 'pose_graph.lua'.
[cartographer_node-3] [INFO] [1713687965.407410052] [cartographer logger]: I0421 08:26:05.000000 256 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/pose_graph.lua' for 'pose_graph.lua'.
[cartographer_node-3] [INFO] [1713687965.407506443] [cartographer logger]: I0421 08:26:05.000000 256 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder.lua' for 'trajectory_builder.lua'.
[cartographer_node-3] [INFO] [1713687965.407523370] [cartographer logger]: I0421 08:26:05.000000 256 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder.lua' for 'trajectory_builder.lua'.
[cartographer_node-3] [INFO] [1713687965.409681341] [cartographer logger]: I0421 08:26:05.000000 256 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder_2d.lua' for 'trajectory_builder_2d.lua'.
[cartographer_node-3] [INFO] [1713687965.409753337] [cartographer logger]: I0421 08:26:05.000000 256 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder_2d.lua' for 'trajectory_builder_2d.lua'.
[cartographer_node-3] [INFO] [1713687965.409878367] [cartographer logger]: I0421 08:26:05.000000 256 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder_3d.lua' for 'trajectory_builder_3d.lua'.
[cartographer_node-3] [INFO] [1713687965.409895396] [cartographer logger]: I0421 08:26:05.000000 256 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder_3d.lua' for 'trajectory_builder_3d.lua'.
[cartographer_node-3] [INFO] [1713687965.434317083] [cartographer logger]: I0421 08:26:05.000000 256 map_builder_bridge.cpp:136] Added trajectory with ID '0'.
[rviz2-5] [INFO] [1713687966.720573653] [rviz2]: Stereo is NOT SUPPORTED
[rviz2-5] [INFO] [1713687966.721400194] [rviz2]: OpenGl version: 4.1 (GLSL 4.1)
[rviz2-5] [INFO] [1713687966.757898421] [rviz2]: Stereo is NOT SUPPORTED
[cartographer_node-3] [INFO] [1713687990.218718154] [cartographer logger]: I0421 08:26:30.000000 256 ordered_multi_queue.cc:172] All sensor data for trajectory 0 is available starting at '638492847902104249'.
[cartographer_node-3] [INFO] [1713687990.218761352] [cartographer logger]: I0421 08:26:30.000000 256 collated_trajectory_builder.cc:81] scan rate: unknown
[cartographer_node-3] [WARN] [1713687990.219176106] [cartographer logger]: W0421 08:26:30.000000 256 pose_extrapolator.cc:168] Queue too short for velocity estimation. Queue duration: 0 s
[cartographer_node-3] [INFO] [1713687990.221447106] [cartographer logger]: I0421 08:26:30.000000 256 pose_graph_2d.cc:148] Inserted submap (0, 0).
[rviz2-5] [INFO] [1713687990.391474751] [rviz2]: Trying to create a map of size 68 x 91 using 1 swatches
[rviz2-5] [ERROR] [1713687990.423338297] [rviz2]: Vertex Program:rviz/glsl120/indexed_8bit_image.vert Fragment Program:rviz/glsl120/indexed_8bit_image.frag GLSL link result :
[rviz2-5] active samplers with a different type refer to the same texture image unit
[rviz2-5] [INFO] [1713687992.407318504] [rviz2]: Trying to create a map of size 69 x 91 using 1 swatches
[rviz2-5] [INFO] [1713687993.400064229] [rviz2]: Trying to create a map of size 89 x 118 using 1 swatches
[rviz2-5] [INFO] [1713687994.391925904] [rviz2]: Trying to create a map of size 90 x 118 using 1 swatches
[rviz2-5] [INFO] [1713687998.396203407] [rviz2]: Trying to create a map of size 132 x 140 using 1 swatches
[rviz2-5] [INFO] [1713687999.416110199] [rviz2]: Trying to create a map of size 143 x 140 using 1 swatches
[rviz2-5] [INFO] [1713688000.212715186] [rviz2]: Message Filter dropping message: frame 'laser_frame' at time 1713687990.210 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
[cartographer_node-3] [INFO] [1713688005.282019885] [cartographer logger]: I0421 08:26:45.000000 256 collated_trajectory_builder.cc:81] scan rate: 2.22 Hz 4.50e-01 s +/- 5.82e-01 s (pulsed at 100.01% real time)
[laser_x2-1] timout count: 1
[laser_x2-1] [ERROR] [1713688009.430782352] [ydlidar_node]: Failed to get scan
[laser_x2-1] timout count: 2
[laser_x2-1] [ERROR] [1713688011.431114965] [ydlidar_node]: Failed to get scan
[laser_x2-1] [ERROR] [1713688013.431611985] [ydlidar_node]: Failed to get scan
[laser_x2-1] [ERROR] [1713688015.431873842] [ydlidar_node]: Failed to get scan
[laser_x2-1] [ERROR] [1713688017.432290740] [ydlidar_node]: Failed to get scan
后面持续同上
ebe7c3df-c5d7-4c2e-a462-d803234ae6d7-image.png
05ab739e-f0bc-463e-af35-9e7b5f97ef48-image.png1、重新烧录
以上方法均失败
2、更换新的雷达及转接板 -
wang2.cpp编译成功,运行后,运行rqt输入2,再运行li4,王二这边一直显示缺书不订阅。不运行rqt,或者王二书满足购买要求,王二可以订书。
-
错误日志(controller_manager节点未启动):
tingbo@DESKTOP-NHH5E05:~/chapt6/chapt6_ws$ ros2 launch fishbot_description gazebo_sim.launch.py [INFO] [launch]: All log files can be found below /home/tingbo/.ros/log/2024-04-21-08-51-56-788969-DESKTOP-NHH5E05-53549 [INFO] [launch]: Default logging verbosity is set to INFO /home/tingbo/chapt6/chapt6_ws/install/fishbot_description/share/fishbot_description/urdf/fishbot/fishbot.urdf.xacro [INFO] [robot_state_publisher-1]: process started with pid [53559] [INFO] [gzserver-2]: process started with pid [53561] [INFO] [gzclient-3]: process started with pid [53563] [INFO] [spawn_entity.py-4]: process started with pid [53565] [robot_state_publisher-1] [INFO] [1713660717.309174822] [robot_state_publisher]: got segment back_caster_link [robot_state_publisher-1] [INFO] [1713660717.309279822] [robot_state_publisher]: got segment base_footprint [robot_state_publisher-1] [INFO] [1713660717.309287622] [robot_state_publisher]: got segment base_link [robot_state_publisher-1] [INFO] [1713660717.309291422] [robot_state_publisher]: got segment camera_link [robot_state_publisher-1] [INFO] [1713660717.309294622] [robot_state_publisher]: got segment camera_optical_link [robot_state_publisher-1] [INFO] [1713660717.309297822] [robot_state_publisher]: got segment front_caster_link [robot_state_publisher-1] [INFO] [1713660717.309300822] [robot_state_publisher]: got segment imu_link [robot_state_publisher-1] [INFO] [1713660717.309304122] [robot_state_publisher]: got segment laser_cylinder_link [robot_state_publisher-1] [INFO] [1713660717.309307222] [robot_state_publisher]: got segment laser_link [robot_state_publisher-1] [INFO] [1713660717.309310322] [robot_state_publisher]: got segment left_wheel_link [robot_state_publisher-1] [INFO] [1713660717.309313222] [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] [1713660717.741308120] [spawn_entity]: Spawn Entity started [spawn_entity.py-4] [INFO] [1713660717.741623420] [spawn_entity]: Loading entity published on topic /robot_description [spawn_entity.py-4] /opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/qos.py:307: UserWarning: DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL is deprecated. Use DurabilityPolicy.TRANSIENT_LOCAL instead. [spawn_entity.py-4] warnings.warn( [spawn_entity.py-4] [INFO] [1713660717.743272920] [spawn_entity]: Waiting for entity xml on /robot_description [spawn_entity.py-4] [INFO] [1713660717.857605420] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30 [spawn_entity.py-4] [INFO] [1713660717.858030320] [spawn_entity]: Waiting for service /spawn_entity [spawn_entity.py-4] [INFO] [1713660719.113670715] [spawn_entity]: Calling service /spawn_entity [gzclient-3] [Msg] Waiting for master. [gzclient-3] [Msg] Connected to gazebo master @ http://127.0.0.1:11345 [gzclient-3] [Msg] Publicized address: 172.18.192.236 [gzclient-3] [Wrn] [GuiIface.cc:120] QStandardPaths: wrong permissions on runtime directory /run/user/1000/, 0755 instead of 0700 [gzserver-2] [Msg] Waiting for master. [gzserver-2] [Msg] Connected to gazebo master @ http://127.0.0.1:11345 [gzserver-2] [Msg] Publicized address: 172.18.192.236 [gzserver-2] [Msg] Loading world file [/home/tingbo/chapt6/chapt6_ws/install/fishbot_description/share/fishbot_description/world/custom_room.world] [gzserver-2] [Wrn] [Event.cc:61] Warning: Deleting a connection right after creation. Make sure to save the ConnectionPtr from a Connect call [gzserver-2] [INFO] [1713660719.924237512] [depth_camera]: Publishing camera info to [/camera_sensor/camera_info] [gzserver-2] [INFO] [1713660719.925709812] [depth_camera]: Publishing depth camera info to [/camera_sensor/depth/camera_info] [gzserver-2] [INFO] [1713660719.926327212] [depth_camera]: Publishing pointcloud to [/camera_sensor/points] [gzclient-3] [Wrn] [Event.cc:61] Warning: Deleting a connection right after creation. Make sure to save the ConnectionPtr from a Connect call [gzserver-2] [Err] [Plugin.hh:212] Failed to load plugin libgazebo_ros_ray_sensor.os: libgazebo_ros_ray_sensor.os: cannot open shared object file: No such file or directory [spawn_entity.py-4] [INFO] [1713660720.044935411] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [fishbot] [gzserver-2] [INFO] [1713660720.066235711] [gazebo_ros2_control]: Loading gazebo_ros2_control plugin [gzserver-2] [INFO] [1713660720.072410111] [gazebo_ros2_control]: Starting gazebo_ros2_control plugin in namespace: / [gzserver-2] [INFO] [1713660720.072523911] [gazebo_ros2_control]: Starting gazebo_ros2_control plugin in ros 2 node: gazebo_ros2_control [gzserver-2] [INFO] [1713660720.077647911] [gazebo_ros2_control]: connected to service!! robot_state_publisher [gzserver-2] [INFO] [1713660720.079397911] [gazebo_ros2_control]: Received urdf from param server, parsing... [gzserver-2] [INFO] [1713660720.079481211] [gazebo_ros2_control]: Loading parameter files /home/tingbo/chapt6/chapt6_ws/install/fishbot_description/share/fishbot_description/config/fishbot_ros2_controller.yaml [gzserver-2] [ERROR] [1713660720.079710611] [gazebo_ros2_control]: parser error Couldn't parse params file: '--params-file /home/tingbo/chapt6/chapt6_ws/install/fishbot_description/share/fishbot_description/config/fishbot_ros2_controller.yaml'. Error: Cannot have a value before ros__parameters at line 1, at ./src/parse.c:793, at ./src/rcl/arguments.c:406 [gzserver-2] [INFO] [spawn_entity.py-4]: process has finished cleanly [pid 53565] [gzserver-2] [Wrn] [Publisher.cc:135] Queue limit reached for topic /gazebo/default/pose/local/info, deleting message. This warning is printed only once.fishbot_ros2_controller.yaml代码:
controller_manager: ros_parameters: update_rate: 100 use_sim_time: truefishbot_ros2_control.xacro代码:
<?xml version="1.0"?> <robot xmlns:xacro="http://www.ros.org/wiki/xacro"> <xacro:macro name="fishbot_ros2_control"> <ros2_control name="FishBotGazeboSystem" type="system"> <hardware> <plugin>gazebo_ros2_contro/GazeboSystem</plugin> </hardware> <joint name="left_wheel_joint"> <command_interface name="velocity"> <param name="min">-1</param> <param name="max">1</param> </command_interface> <command_interface name="effort"> <param name="min">-0.1</param> <param name="max">0.1</param> </command_interface> <state_interface name="position" /> <state_interface name="velocity" /> <state_interface name="effort" /> </joint> <joint name="right_wheel_joint"> <command_interface name="velocity"> <param name="min">-1</param> <param name="max">1</param> </command_interface> <command_interface name="effort"> <param name="min">-0.1</param> <param name="max">0.1</param> </command_interface> <state_interface name="position" /> <state_interface name="velocity" /> <state_interface name="effort" /> </joint> </ros2_control> <gazebo> <plugin filename="libgazebo_ros2_control.so" name="gazebo_ros2_control"> <parameters>$(find fishbot_description)/config/fishbot_ros2_controller.yaml</parameters> </plugin> </gazebo> </xacro:macro> </robot>fishbot.urdf.xacro代码:
<?xml version="1.0"?> <robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="fishbot"> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/base.urdf.xacro" /> <!--传感器组件--> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/sensor/imu.urdf.xacro" /> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/sensor/laser.urdf.xacro" /> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/sensor/camera.urdf.xacro" /> <xacro:base_xacro length="0.12" radius="0.1" /> <!--传感器--> <xacro:imu_xacro xyz="0.0 0.0 0.02" /> <xacro:laser_xacro xyz="0.0 0.0 0.1" /> <xacro:camera_xacro xyz="0.1 0.0 0.075" /> <!--执行器组件--> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/actuator/wheel.urdf.xacro" /> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/actuator/caster.urdf.xacro" /> <!--执行器主动轮+从动轮--> <xacro:wheel_xacro wheel_name="left" xyz="0.0 0.1 -0.06" /> <xacro:wheel_xacro wheel_name="right" xyz="0.0 -0.1 -0.06" /> <xacro:caster_xacro caster_name="front" xyz="0.08 0.0 -0.076" /> <xacro:caster_xacro caster_name="back" xyz="-0.08 0.0 -0.076" /> <!--gazebo插件--> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/plugins/gazebo_control_plugin.xacro"/> <!--<xacro:gazebo_control_plugin />--> <!--激光雷达传感器插件--> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/plugins/gazebo_sensor_plugin.xacro"/> <xacro:gazebo_sensor_plugin /> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/fishbot_ros2_control.xacro"/> <xacro:fishbot_ros2_control /> </robot>gazebo_sim.launch.py代码:
import launch import launch_ros from ament_index_python.packages import get_package_share_directory from launch.launch_description_sources import PythonLaunchDescriptionSource import launch_ros.parameter_descriptions def generate_launch_description(): robot_name_in_model = "fishbot" urdf_tutorial_path = get_package_share_directory('fishbot_description') default_model_path = urdf_tutorial_path + '/urdf/fishbot/fishbot.urdf.xacro' default_world_path = urdf_tutorial_path + '/world/custom_room.world' print(str(default_model_path)) action_declare_arg_mode_path = launch.actions.DeclareLaunchArgument( name='model', default_value=str(default_model_path), description='URDF 的绝对路径') robot_description = launch_ros.parameter_descriptions.ParameterValue( launch.substitutions.Command( ['xacro ', launch.substitutions.LaunchConfiguration('model')]), value_type=str) robot_state_publisher_node = launch_ros.actions.Node( package='robot_state_publisher', executable='robot_state_publisher', parameters=[{'robot_description': robot_description}]) launch_gazebo = launch.actions.IncludeLaunchDescription( PythonLaunchDescriptionSource([get_package_share_directory('gazebo_ros'), '/launch', '/gazebo.launch.py']), launch_arguments=[('world', default_world_path), ('verbose', 'true')]) spawn_entity_node = launch_ros.actions.Node( package='gazebo_ros', executable='spawn_entity.py', arguments=['-topic', '/robot_description', '-entity', robot_name_in_model, ]) return launch.LaunchDescription([ action_declare_arg_mode_path, robot_state_publisher_node, launch_gazebo, spawn_entity_node ]) -
dujutese@dujutese-virtual-machine:~/fishbot$ ros2 launch fishbot_navigation2 navigation2.launch.py
PackageNotFoundError: "package 'nav2_bringup' not found, searching: ['/home/dujutese/fishbot/install/fishbot_navigation2', '/home/dujutese/fishbot/install/fishbot_interfaces', '/home/dujutese/fishbot/install/fishbot_description', '/home/dujutese/fishbot/install/fishbot_cartographer', '/home/dujutese/fishbot/install/fishbot_bringup', '/opt/ros/humble']" InvalidFrontendLaunchFileError: The launch file may have a syntax error, or its format is unknown
[INFO] [launch]: All log files can be found below /home/dujutese/.ros/log/2024-04-20-22-30-50-521955-dujutese-virtual-machine-38209
[INFO] [launch]: Default logging verbosity is set to INFO
[ERROR] [launch]: Caught exception in launch (see debug for traceback): Caught multiple exceptions when trying to load file of format [py]:
dujutese@dujutese-virtual-machine:~/fishbot$
重要提示
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码