Skip to content

Commit 276120d

Browse files
authored
Succeed power on command on PolyScope 5 when robot is running (#397)
We check for the robot state being IDLE and retry that with a very high timeout by default. This commit also accepts the robot to be in RUNNING in order to succeed. Otherwise the robot will reply "Powering on" through the dashboard interface, but the state will stay unchanged because it is already idling. Thus, the call will fail (and block very long) while the pure dashboard call would be succeeding.
1 parent c67fec4 commit 276120d

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/ur/dashboard_client_implementation_g5.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ DashboardResponse DashboardClientImplG5::commandPowerOn(const std::chrono::durat
438438
DashboardResponse response;
439439
try
440440
{
441-
response.message = retryCommandString("power on", "Powering on", "robotmode", "Robotmode: IDLE", timeout);
441+
response.message = retryCommandString("power on", "Powering on", "robotmode", "Robotmode: (IDLE|RUNNING)", timeout);
442442
response.ok = true;
443443
}
444444
catch (const UnexpectedResponse& e)

tests/test_dashboard_client_g5.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,43 @@ TEST_F(DashboardClientTestG5, connect)
9191
ASSERT_TRUE(response.ok);
9292
}
9393

94+
TEST_F(DashboardClientTestG5, power_cycle)
95+
{
96+
EXPECT_TRUE(dashboard_client_->connect());
97+
DashboardResponse response;
98+
99+
// Cycle from POWER_OFF to IDLE to RUNNING
100+
response = dashboard_client_->commandPowerOff();
101+
EXPECT_TRUE(response.ok);
102+
response = dashboard_client_->commandPowerOn(std::chrono::seconds(5));
103+
EXPECT_TRUE(response.ok);
104+
response = dashboard_client_->commandBrakeRelease();
105+
EXPECT_TRUE(response.ok);
106+
107+
// Calling power_on on a brake-released robot should succeed
108+
response = dashboard_client_->commandPowerOn(std::chrono::seconds(5));
109+
EXPECT_TRUE(response.ok);
110+
111+
// Power off from brake-released state (RUNNING)
112+
response = dashboard_client_->commandPowerOff();
113+
EXPECT_TRUE(response.ok);
114+
115+
// Power off from powered_on state (IDLE)
116+
dashboard_client_->commandPowerOn();
117+
response = dashboard_client_->commandPowerOff();
118+
EXPECT_TRUE(response.ok);
119+
120+
// Power off from powered_on state (IDLE)
121+
dashboard_client_->commandPowerOff();
122+
response = dashboard_client_->commandPowerOff();
123+
EXPECT_TRUE(response.ok);
124+
125+
// Brake release from POWER_OFF should succeed
126+
dashboard_client_->commandPowerOff();
127+
response = dashboard_client_->commandBrakeRelease();
128+
EXPECT_TRUE(response.ok);
129+
}
130+
94131
TEST_F(DashboardClientTestG5, run_program)
95132
{
96133
EXPECT_TRUE(dashboard_client_->connect());

0 commit comments

Comments
 (0)