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

Commit 85ed8ad

Browse files
author
Olav de Haas
committed
Fix writing idle color
1 parent 6843e7b commit 85ed8ad

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void writeColor(Color color);
3535
// High voltage is enabled when HIGH and disabled when LOW
3636
int hv_enabled = LOW;
3737
// True when a gait is being executed, false otherwise
38-
bool active = false;
38+
bool is_connected = false;
3939

4040
ros::NodeHandle nh;
4141

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

5757
void errorCallback(const march_shared_resources::Error& /* error */)
5858
{
59-
active = false;
6059
writeColor(colors::ERROR);
6160
}
6261

6362
void instructionResponseCallback(const march_shared_resources::GaitInstructionResponse& response)
6463
{
6564
if (response.result == response.GAIT_FINISHED)
6665
{
67-
active = false;
6866
writeColor(colors::IDLE);
6967
}
7068
}
7169

7270
void currentGaitCallback(const std_msgs::String& /* gait */)
7371
{
74-
active = true;
7572
writeColor(colors::ACTIVE);
7673
}
7774

@@ -119,10 +116,12 @@ void loop()
119116

120117
if (!nh.connected())
121118
{
119+
is_connected = false;
122120
writeColor(colors::OFF);
123121
}
124-
else if (!active)
122+
else if (!is_connected)
125123
{
124+
is_connected = true;
126125
writeColor(colors::IDLE);
127126
}
128127
nh.spinOnce();

0 commit comments

Comments
 (0)