二维码检测:添加了判断顺逆时针的规则和发布内容;临时修改发布话题到了vlm中
This commit is contained in:
@@ -9,12 +9,9 @@ from launch_ros.actions import Node
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
image_topic = LaunchConfiguration("image_topic", default="/image_raw")
|
||||
image_topic = LaunchConfiguration("image_topic", default="/image")
|
||||
|
||||
return LaunchDescription([
|
||||
DeclareLaunchArgument("image_topic",
|
||||
default_value="/image_raw",
|
||||
description="相机图像话题 (bgr8 / rgb8 / nv12 / mono8)"),
|
||||
|
||||
Node(
|
||||
package="qr_detection",
|
||||
|
||||
@@ -16,17 +16,17 @@ def generate_launch_description():
|
||||
use_buffer = LaunchConfiguration("use_buffer", default="true")
|
||||
|
||||
# USB 相机驱动 (v4l2)
|
||||
v4l2_camera = Node(
|
||||
package="v4l2_camera",
|
||||
executable="v4l2_camera_node",
|
||||
name="usb_camera",
|
||||
parameters=[{
|
||||
"video_device": camera_device,
|
||||
"image_size": [640, 480],
|
||||
"pixel_format": "YUYV",
|
||||
}],
|
||||
remappings=[("image_raw", image_topic)],
|
||||
)
|
||||
# camera = Node(
|
||||
# package="hobot_usb_cam",
|
||||
# executable="hobot_usb_cam",
|
||||
# name="hobot_usb_cam",
|
||||
# parameters=[{
|
||||
# "video_device": camera_device,
|
||||
# "image_size": [640, 480],
|
||||
# "pixel_format": "YUYV",
|
||||
# }],
|
||||
# remappings=[("image_raw", image_topic)],
|
||||
# )
|
||||
|
||||
# QR 识别
|
||||
qr_detector = Node(
|
||||
@@ -60,6 +60,6 @@ def generate_launch_description():
|
||||
DeclareLaunchArgument("use_buffer",
|
||||
default_value="true",
|
||||
description="信号消失后保持最近结果"),
|
||||
v4l2_camera,
|
||||
# v4l2_camera,
|
||||
qr_detector,
|
||||
])
|
||||
|
||||
@@ -34,8 +34,9 @@ public:
|
||||
std::bind(&QrDetectNode::sign_cb, this, std::placeholders::_1));
|
||||
|
||||
pub_ = create_publisher<std_msgs::msg::String>("qr_results", 10);
|
||||
pub_tts_ = create_publisher<std_msgs::msg::String>("/vlm_result", 10);
|
||||
|
||||
RCLCPP_INFO(get_logger(), "QR Detect ready, topic=%s", image_topic_.c_str());
|
||||
RCLCPP_INFO(get_logger(), "QR Detect ready, topic=%s, tts topic=/vlm_result", image_topic_.c_str());
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -84,13 +85,18 @@ private:
|
||||
|
||||
auto out = std_msgs::msg::String();
|
||||
if (n > 0) {
|
||||
out.data = zimg.symbol_begin()->get_data();
|
||||
if (out.data != last_) {
|
||||
RCLCPP_INFO(get_logger(), "QR: %s", out.data.c_str());
|
||||
last_ = out.data;
|
||||
const std::string qr_data = zimg.symbol_begin()->get_data();
|
||||
if (qr_data != last_) {
|
||||
RCLCPP_INFO(get_logger(), "QR: %s", qr_data.c_str());
|
||||
last_ = qr_data;
|
||||
}
|
||||
|
||||
if (!qr_data.empty() && qr_data.find_first_not_of("0123456789") == std::string::npos) {
|
||||
out.data = qr_data + " " + (((qr_data.back() - '0') % 2 == 1) ? "顺时针" : "逆时针");
|
||||
pub_->publish(out);
|
||||
pub_tts_->publish(out); // 同时发给TTS播报
|
||||
}
|
||||
}
|
||||
pub_->publish(out);
|
||||
}
|
||||
|
||||
void sign_cb(const std_msgs::msg::Int32::SharedPtr msg)
|
||||
@@ -102,6 +108,7 @@ private:
|
||||
rclcpp::Subscription<sensor_msgs::msg::Image>::SharedPtr sub_;
|
||||
rclcpp::Subscription<std_msgs::msg::Int32>::SharedPtr sign_sub_;
|
||||
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_;
|
||||
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_tts_; // 发给TTS语音播报
|
||||
|
||||
bool enabled_;
|
||||
std::string image_topic_;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
3 - 到达任务二起始阶段,执行顺/逆时针绕圈(可集成图生文)
|
||||
4 - 减速拍照,图像传入图生文节点,随后回到3(备用)
|
||||
5 - 完整走完一圈,执行任务三
|
||||
6 - 到达终点,停止
|
||||
2. 全部流程
|
||||
启动小车->slamtoolbox开始建图,并开始发布导航命令(这时候小车还不能动)->打开电机开关,小车开始行动->走到一半扫到二维码,发布在/qr_results上->停掉二维码节点(sign=5)和导航1,同时开始导航2到任务二入口并顺逆时针转圈->到达指定位置触发一次vlm请求->开始语音播报同时完成任务二、三
|
||||
*/
|
||||
@@ -17,16 +18,13 @@ static int ENTRY = 2;
|
||||
static int CIRCLE = 3;
|
||||
static int VLM = 4;
|
||||
static int TASK3 = 5;
|
||||
static int END = 6;
|
||||
|
||||
|
||||
class RacingControl : public rclcpp::Node
|
||||
{
|
||||
public:
|
||||
RacingControl() : Node("racing_control")
|
||||
{
|
||||
// 初始化状态指令
|
||||
state_command_ = QR_SEARCHING;
|
||||
}
|
||||
RacingControl();
|
||||
private:
|
||||
// 状态指令变量
|
||||
int state_command_;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "racing_control/racing_control.hpp"
|
||||
|
||||
RacingControl : Node("racing_control")
|
||||
{
|
||||
// 初始化状态指令
|
||||
state_command_ = QR_SEARCHING;
|
||||
}
|
||||
Reference in New Issue
Block a user