Skip to content

Commit e5af8d2

Browse files
committed
✨ feat: Add set_detector_color parameter to configuration and logic
1 parent a8049d6 commit e5af8d2

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

config/standard_robot_pp_ros2.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ standard_robot_pp_ros2:
55
flow_control: none
66
parity: none
77
stop_bits: "1"
8+
set_detector_color: false
89
record_rosbag: false
910
debug: false
1011

include/standard_robot_pp_ros2/standard_robot_pp_ros2.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class StandardRobotPpRos2Node : public rclcpp::Node
5656
std::unique_ptr<drivers::serial_driver::SerialPortConfig> device_config_;
5757
std::unique_ptr<drivers::serial_driver::SerialDriver> serial_driver_;
5858
bool record_rosbag_;
59+
bool set_detector_color_;
5960

6061
std::thread receive_thread_;
6162
std::thread send_thread_;

src/standard_robot_pp_ros2.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,9 @@ void StandardRobotPpRos2Node::getParams()
204204
device_config_ =
205205
std::make_unique<drivers::serial_driver::SerialPortConfig>(baud_rate, fc, pt, sb);
206206

207-
debug_ = declare_parameter("debug", false);
208207
record_rosbag_ = declare_parameter("record_rosbag", false);
208+
set_detector_color_ = declare_parameter("set_detector_color", false);
209+
debug_ = declare_parameter("debug", false);
209210
}
210211

211212
/********************************************************/
@@ -648,12 +649,14 @@ void StandardRobotPpRos2Node::publishRobotStatus(ReceiveRobotStatus & robot_stat
648649

649650
robot_status_pub_->publish(msg);
650651

651-
uint8_t detect_color;
652-
if (getDetectColor(robot_status.data.robot_id, detect_color)) {
653-
if (!initial_set_param_ || detect_color != previous_receive_color_) {
654-
previous_receive_color_ = detect_color;
655-
setParam(rclcpp::Parameter("detect_color", detect_color));
656-
std::this_thread::sleep_for(std::chrono::milliseconds(500));
652+
if (set_detector_color_) {
653+
uint8_t detect_color;
654+
if (getDetectColor(robot_status.data.robot_id, detect_color)) {
655+
if (!initial_set_param_ || detect_color != previous_receive_color_) {
656+
previous_receive_color_ = detect_color;
657+
setParam(rclcpp::Parameter("detect_color", detect_color));
658+
std::this_thread::sleep_for(std::chrono::milliseconds(500));
659+
}
657660
}
658661
}
659662
}

0 commit comments

Comments
 (0)