Skip to content

Commit

Permalink
Add suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal-gorecki committed Aug 28, 2024
1 parent 91a7094 commit b86e9e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 8 additions & 4 deletions panther_gazebo/include/panther_gazebo/led_strip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#define PANTHER_GAZEBO_LED_STRIP_HPP_

#include <chrono>
#include <mutex>
#include <string>

#include <realtime_tools/realtime_box.h>
Expand Down Expand Up @@ -78,7 +77,7 @@ class LEDStrip : public gz::sim::System,
* @brief Return Light command based on light configuration specified in URDF file Light
* properties
*
* @param ecm Entity Component Manager
* @param ecm The entity component manager.
* @return Light command message
* @exception std::runtime_error if the light entity is not found.
*/
Expand All @@ -97,13 +96,19 @@ class LEDStrip : public gz::sim::System,

/**
* @brief Manage color of robot simulated lights based on the image message
*
* @param ecm The entity component manager.
* @param image The image message
*/
void VisualizeLights(gz::sim::EntityComponentManager & ecm, const gz::msgs::Image & image);

/**
* @brief Manage color of robot LED strip based on the image message
*
* @param image The image message
* @param light_pose The pose of the light
*/
void VisualizeMarkers(const gz::msgs::Image & image, const gz::math::Pose3d & lightPose);
void VisualizeMarkers(const gz::msgs::Image & image, const gz::math::Pose3d & light_pose);

/**
* @brief Create a marker element (single LED from LED Strip)
Expand All @@ -117,7 +122,6 @@ class LEDStrip : public gz::sim::System,
const uint id, const gz::math::Pose3d pose, const gz::math::Color & color,
const gz::math::Vector3d size);

// Parameters
std::string light_name_;
std::string image_topic_;
std::string ns_ = "";
Expand Down
8 changes: 4 additions & 4 deletions panther_gazebo/src/led_strip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "panther_gazebo/led_strip.hpp"

#include <stddef.h>
#include <cstddef>
#include <limits>

#include <gz/plugin/Register.hh>
Expand Down Expand Up @@ -182,8 +182,8 @@ gz::math::Color LEDStrip::CalculateMeanColor(const gz::msgs::Image & msg)
}
}

float max_value = std::numeric_limits<uint8_t>::max();
float norm_factor = max_value * pixel_count;
const float max_value = std::numeric_limits<uint8_t>::max();
const float norm_factor = max_value * pixel_count;

float norm_mean_r = sum_r / norm_factor;
float norm_mean_g = sum_g / norm_factor;
Expand Down Expand Up @@ -223,7 +223,7 @@ void LEDStrip::VisualizeMarkers(const gz::msgs::Image & image, const gz::math::P
double step_width = marker_width_ / image.width();
double step_height = marker_height_ / image.height();

float max_value = std::numeric_limits<uint8_t>::max();
const float max_value = std::numeric_limits<uint8_t>::max();
bool is_rgba = (image.pixel_format_type() == gz::msgs::PixelFormatType::RGBA_INT8);
int step = is_rgba ? 4 : 3;

Expand Down

0 comments on commit b86e9e5

Please sign in to comment.