Skip to content
This repository has been archived by the owner on Dec 1, 2020. It is now read-only.

Commit

Permalink
Fix writing idle color
Browse files Browse the repository at this point in the history
  • Loading branch information
Olav de Haas committed May 20, 2020
1 parent 6843e7b commit 85ed8ad
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void writeColor(Color color);
// High voltage is enabled when HIGH and disabled when LOW
int hv_enabled = LOW;
// True when a gait is being executed, false otherwise
bool active = false;
bool is_connected = false;

ros::NodeHandle nh;

Expand All @@ -56,22 +56,19 @@ void setColorCallback(const std_msgs::ColorRGBA& color)

void errorCallback(const march_shared_resources::Error& /* error */)
{
active = false;
writeColor(colors::ERROR);
}

void instructionResponseCallback(const march_shared_resources::GaitInstructionResponse& response)
{
if (response.result == response.GAIT_FINISHED)
{
active = false;
writeColor(colors::IDLE);
}
}

void currentGaitCallback(const std_msgs::String& /* gait */)
{
active = true;
writeColor(colors::ACTIVE);
}

Expand Down Expand Up @@ -119,10 +116,12 @@ void loop()

if (!nh.connected())
{
is_connected = false;
writeColor(colors::OFF);
}
else if (!active)
else if (!is_connected)
{
is_connected = true;
writeColor(colors::IDLE);
}
nh.spinOnce();
Expand Down

0 comments on commit 85ed8ad

Please sign in to comment.