@@ -70,9 +70,10 @@ int main(int argc, char* argv[])
7070 {
7171 policy = DashboardClient::ClientPolicy::G5 ;
7272 }
73- else if (version_information->minor < 11 )
73+ else if (version_information->minor < 12 )
7474 {
75- URCL_LOG_ERROR (" DashboardClient examples require PolyScope version 10.11.0 or higher. Exiting now." );
75+ // We need isInRemoteControl for PolyScope X, which is only supported from version 10.12.0 on.
76+ URCL_LOG_ERROR (" DashboardClient examples require PolyScope version 10.12.0 or higher. Exiting now." );
7677 return 0 ;
7778 }
7879
@@ -84,6 +85,13 @@ int main(int argc, char* argv[])
8485 return 1 ;
8586 }
8687
88+ bool robot_in_remote_control = false ;
89+ // CB3 doesn't have remote control
90+ if (version_information->major >= 5 )
91+ {
92+ robot_in_remote_control = my_dashboard->commandIsInRemoteControl ();
93+ }
94+
8795 // Bring the robot to a defined state being powered off.
8896 if (version_information->major < 10 )
8997 {
@@ -99,106 +107,109 @@ int main(int argc, char* argv[])
99107
100108 my_dashboard->commandCloseSafetyPopup ();
101109 }
102- else
110+ else if (robot_in_remote_control)
103111 {
104112 // We're ignoring errors here since
105113 // powering off an already powered off robot will return an error.
106114 my_dashboard->commandPowerOff ();
107115 }
108116
109117 // Power it on
110- if (!my_dashboard->commandPowerOn ())
111- {
112- URCL_LOG_ERROR (" Could not send Power on command" );
113- return 1 ;
114- }
115-
116- // Release the brakes
117- if (!my_dashboard->commandBrakeRelease ())
118+ if (version_information->major < 10 || robot_in_remote_control)
118119 {
119- URCL_LOG_ERROR (" Could not send BrakeRelease command" );
120- return 1 ;
121- }
122-
123- // Load existing program
124- std::string program_file_name_to_be_loaded (" wait_program.urp" );
125- if (version_information->major >= 10 )
126- {
127- // For PolyScope X, the program doesn't have an ending
128- program_file_name_to_be_loaded = " wait_program" ;
129- }
130- if (!my_dashboard->commandLoadProgram (program_file_name_to_be_loaded))
131- {
132- URCL_LOG_ERROR (" Could not load %s program" , program_file_name_to_be_loaded.c_str ());
133- return 1 ;
134- }
135-
136- std::this_thread::sleep_for (std::chrono::seconds (1 ));
137-
138- // Play loaded program
139- if (!my_dashboard->commandPlay ())
140- {
141- URCL_LOG_ERROR (" Could not play program" );
142- return 1 ;
143- }
120+ if (!my_dashboard->commandPowerOn ())
121+ {
122+ URCL_LOG_ERROR (" Could not send Power on command" );
123+ return 1 ;
124+ }
144125
145- // Pause running program
146- if (!my_dashboard->commandPause ())
147- {
148- URCL_LOG_ERROR (" Could not pause program " );
149- return 1 ;
150- }
126+ // Release the brakes
127+ if (!my_dashboard->commandBrakeRelease ())
128+ {
129+ URCL_LOG_ERROR (" Could not send BrakeRelease command " );
130+ return 1 ;
131+ }
151132
152- // Continue
153- if (version_information->major >= 10 )
154- {
155- // For PolyScope X, the command is called "resume"
156- if (!my_dashboard->commandResume ())
133+ // Load existing program
134+ std::string program_file_name_to_be_loaded (" wait_program.urp" );
135+ if (version_information->major >= 10 )
136+ {
137+ // For PolyScope X, the program doesn't have an ending
138+ program_file_name_to_be_loaded = " wait_program" ;
139+ }
140+ if (!my_dashboard->commandLoadProgram (program_file_name_to_be_loaded))
157141 {
158- URCL_LOG_ERROR (" Could not resume program" );
142+ URCL_LOG_ERROR (" Could not load %s program" , program_file_name_to_be_loaded. c_str () );
159143 return 1 ;
160144 }
161- }
162- else
163- {
164- // For e-Series, the command is called "play"
145+
146+ std::this_thread::sleep_for ( std::chrono::seconds ( 1 ));
147+
148+ // Play loaded program
165149 if (!my_dashboard->commandPlay ())
166150 {
167- URCL_LOG_ERROR (" Could not resume program" );
151+ URCL_LOG_ERROR (" Could not play program" );
168152 return 1 ;
169153 }
170- }
171154
172- // Stop program
173- if (!my_dashboard->commandStop ())
174- {
175- URCL_LOG_ERROR (" Could not stop program" );
176- return 1 ;
177- }
155+ // Pause running program
156+ if (!my_dashboard->commandPause ())
157+ {
158+ URCL_LOG_ERROR (" Could not pause program" );
159+ return 1 ;
160+ }
178161
179- // Power it off
180- if (!my_dashboard->commandPowerOff ())
181- {
182- URCL_LOG_ERROR (" Could not send Power off command" );
183- return 1 ;
184- }
162+ // Continue
163+ if (version_information->major >= 10 )
164+ {
165+ // For PolyScope X, the command is called "resume"
166+ if (!my_dashboard->commandResume ())
167+ {
168+ URCL_LOG_ERROR (" Could not resume program" );
169+ return 1 ;
170+ }
171+ }
172+ else
173+ {
174+ // For e-Series, the command is called "play"
175+ if (!my_dashboard->commandPlay ())
176+ {
177+ URCL_LOG_ERROR (" Could not resume program" );
178+ return 1 ;
179+ }
180+ }
185181
186- if (version_information->major < 10 )
187- {
188- // Flush the log
189- if (!my_dashboard->commandSaveLog ())
182+ // Stop program
183+ if (!my_dashboard->commandStop ())
190184 {
191- URCL_LOG_ERROR (" Could not send the save log command " );
185+ URCL_LOG_ERROR (" Could not stop program " );
192186 return 1 ;
193187 }
194188
195- // Make a raw request and save the response
196- std::string program_state = my_dashboard->sendAndReceive (" programState" );
197- URCL_LOG_INFO (" Program state: %s" , program_state.c_str ());
189+ // Power it off
190+ if (!my_dashboard->commandPowerOff ())
191+ {
192+ URCL_LOG_ERROR (" Could not send Power off command" );
193+ return 1 ;
194+ }
198195
199- // The response can be checked with a regular expression
200- bool success = my_dashboard->sendRequest (" power off" , " Powering off" );
201- URCL_LOG_INFO (" Power off command success: %d" , success);
196+ if (version_information->major < 10 )
197+ {
198+ // Flush the log
199+ if (!my_dashboard->commandSaveLog ())
200+ {
201+ URCL_LOG_ERROR (" Could not send the save log command" );
202+ return 1 ;
203+ }
204+
205+ // Make a raw request and save the response
206+ std::string program_state = my_dashboard->sendAndReceive (" programState" );
207+ URCL_LOG_INFO (" Program state: %s" , program_state.c_str ());
208+
209+ // The response can be checked with a regular expression
210+ bool success = my_dashboard->sendRequest (" power off" , " Powering off" );
211+ URCL_LOG_INFO (" Power off command success: %d" , success);
212+ }
202213 }
203214
204215 return 0 ;
0 commit comments