Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed motor error lighting sequence #120

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ struct hsv_t {
s = 0.0;
v = 0.0;
}

bool operator==(hsv_t const& other)
{
return (h == other.h && s == other.s && v == other.v);
}

bool operator!=(hsv_t const& other)
{
return !(*this == other);
}
};

static const hsv_t COLOR_RED = hsv_t(0.0, 100.0, 37.5);
Expand All @@ -85,9 +95,9 @@ class ColorHSV
ColorHSV(hsv_t hsv);
static std::vector<ColorHSV> fade(ColorHSV start, ColorHSV end, uint32_t steps);
clearpath_platform_msgs::msg::RGB getRgbMsg();
double h() { return hsv_.h; };
double s() { return hsv_.s; };
double v() { return hsv_.v; };
double h() const { return hsv_.h; };
double s() const { return hsv_.s; };
double v() const { return hsv_.v; };

void setH(const double h)
{
Expand All @@ -104,6 +114,16 @@ class ColorHSV
hsv_.v = v;
}

bool operator==(const ColorHSV other) const
{
return (h() == other.h() && s() == other.s() && v() == other.v());
}

bool operator!=(const ColorHSV other) const
{
return !(*this == other);
}

private:
hsv_t hsv_;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,29 @@ class Sequence
return s;
}

bool operator==(Sequence const& other)
{
LightingSequence ls, other_ls;

ls = sequence_;
other_ls = other.getSequence();

for (std::size_t i = 0; i < sequence_.size(); i++)
{
if (ls.at(i) != other_ls.at(i))
{
return false;
}
}

return true;
}

bool operator!=(Sequence const& other)
{
return !(sequence_ == other.getSequence());
}

protected:
LightingSequence sequence_;
uint16_t current_state_, num_states_;
Expand Down
2 changes: 1 addition & 1 deletion clearpath_hardware_interfaces/src/lighting/lighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void Lighting::spinOnce()
}

// Change lighting sequence if state has changed
if (old_state_ != state_)
if (old_state_ != state_ || current_sequence_ != lighting_sequence_.at(old_state_))
{
current_sequence_ = lighting_sequence_.at(state_);
current_sequence_.reset();
Expand Down
Loading