diff --git a/rae_bringup/scripts/led_test.py b/rae_bringup/scripts/led_test.py index e6ac722..f9323a3 100755 --- a/rae_bringup/scripts/led_test.py +++ b/rae_bringup/scripts/led_test.py @@ -31,10 +31,10 @@ def listener_callback(self, msg): # Set LEDs based on battery level # Define colors for LEDs colors = { - "white": ColorPeriod(r=1.0, g=1.0, b=1.0, a=1.0, f =2.0), - "yellow": ColorPeriod(r=1.0, g=1.0, b=0.0, a=1.0, f =8.0), - "red": ColorPeriod(r=1.0, g=0.0, b=0.0, a=1.0, f =0.0), - "blue": ColorPeriod(r=0.0, g=0.0, b=1.0, a=1.0, f =0.0) + "white": ColorPeriod(r=1.0, g=1.0, b=1.0, a=1.0, frequency =2.0), + "yellow": ColorPeriod(r=1.0, g=1.0, b=0.0, a=1.0, frequency =8.0), + "red": ColorPeriod(r=1.0, g=0.0, b=0.0, a=1.0, frequency =0.0), + "blue": ColorPeriod(r=0.0, g=0.0, b=1.0, a=1.0, frequency =0.0) } @@ -42,7 +42,7 @@ def listener_callback(self, msg): # Create and publish LEDControl message for each LED led_msg = LEDControl() led_msg.header.stamp = self.get_clock().now().to_msg() - led_msg.data = [ColorPeriod(r=0.0, g=0.0, b=0.0, a=0.0, f =0.0)]*40 + led_msg.data = [ColorPeriod(r=0.0, g=0.0, b=0.0, a=0.0, frequency =0.0)]*40 for i in range(39): led_msg.single_led_n = 0 diff --git a/rae_hw/src/peripherals/led.cpp b/rae_hw/src/peripherals/led.cpp index a2b198f..47aafa2 100644 --- a/rae_hw/src/peripherals/led.cpp +++ b/rae_hw/src/peripherals/led.cpp @@ -79,7 +79,7 @@ namespace rae_hw setAllPixels(150, 10, 150, 0); transmitSPI(); - + timer_ = this->create_wall_timer(std::chrono::milliseconds(50), std::bind(&LEDNode::timer_callback, this)); RCLCPP_INFO(this->get_logger(), "LED node running!"); } @@ -104,28 +104,28 @@ namespace rae_hw uint8_t r = convertColor(currentData_->data[0].r); uint8_t g = convertColor(currentData_->data[0].g); uint8_t b = convertColor(currentData_->data[0].b); - setAllPixels(r, g, b, currentData_-> data[0].f); + setAllPixels(r, g, b, currentData_-> data[0].frequency); } else if (currentData_->control_type == currentData_->CTRL_TYPE_SINGLE) { uint8_t r = convertColor(currentData_->data[0].r); uint8_t g = convertColor(currentData_->data[0].g); uint8_t b = convertColor(currentData_->data[0].b); - setSinglePixel(currentData_->single_led_n, r, g, b, currentData_-> data[0].f); + setSinglePixel(currentData_->single_led_n, r, g, b, currentData_-> data[0].frequency); } else if (currentData_->control_type == currentData_->CTRL_TYPE_SPINNER) { uint8_t r = convertColor(currentData_->data[0].r); uint8_t g = convertColor(currentData_->data[0].g); uint8_t b = convertColor(currentData_->data[0].b); - spinner(r, g, b, currentData_ -> animation_size, currentData_ -> animation_quantity, currentData_-> data[0].f); + spinner(r, g, b, currentData_ -> animation_size, currentData_ -> animation_quantity, currentData_-> data[0].frequency); } else if (currentData_->control_type == currentData_->CTRL_TYPE_FAN) { uint8_t r = convertColor(currentData_->data[0].r); uint8_t g = convertColor(currentData_->data[0].g); uint8_t b = convertColor(currentData_->data[0].b); - fan(r, g, b, true, currentData_ -> animation_quantity, currentData_-> data[0].f); + fan(r, g, b, true, currentData_ -> animation_quantity, currentData_-> data[0].frequency); } else { @@ -134,7 +134,7 @@ namespace rae_hw uint8_t r = convertColor(currentData_->data[i].r); uint8_t g = convertColor(currentData_->data[i].g); uint8_t b = convertColor(currentData_->data[i].b); - setSinglePixel(i, r, g, b, currentData_-> data[i].f); + setSinglePixel(i, r, g, b, currentData_-> data[i].frequency); } } transmitSPI(); diff --git a/rae_msgs/msg/ColorPeriod.msg b/rae_msgs/msg/ColorPeriod.msg index 214b203..e918f99 100644 --- a/rae_msgs/msg/ColorPeriod.msg +++ b/rae_msgs/msg/ColorPeriod.msg @@ -1,5 +1,2 @@ -float32 r -float32 g -float32 b -float32 a -float32 f \ No newline at end of file +std_msgs/ColorRGBA color +float32 frequency