@@ -242,15 +242,16 @@ const RobotMotion = (props) => {
242
242
* @param {flexSizeOuter } - flexbox percentage for parent element rendering everything
243
243
* @param {flexSizeTextInner } - flexbox percentage for child element rendering text
244
244
* @param {flexSizeVisualInner } - flexbox percentage for child element rendering visual
245
- * @param {progress } - progress proportion; if null progress bar not shown
246
245
* @param {text } - action status text
247
246
* @param {showTime } - indicates if elapsed time needs to be shown
248
247
* @param {time } - calculated elapsed time, 0 if time not available
248
+ * @param {progress } - progress proportion; if null progress bar not shown
249
+ * @param {retry } - indicates if retry needed for error
249
250
*
250
251
* @returns {JSX.Element } the action status text, progress bar or blank view
251
252
*/
252
253
const actionStatusTextAndVisual = useCallback (
253
- ( flexSizeOuter , flexSizeTextInner , flexSizeVisualInner , text , showTime , time , progress ) => {
254
+ ( flexSizeOuter , flexSizeTextInner , flexSizeVisualInner , text , showTime , time , progress , retry = false ) => {
254
255
return (
255
256
< >
256
257
< View style = { { flex : flexSizeOuter , flexDirection : dimension , alignItems : 'center' , justifyContent : 'center' , width : '100%' } } >
@@ -260,6 +261,22 @@ const RobotMotion = (props) => {
260
261
</ p >
261
262
< p style = { { fontSize : motionTextFontSize } } > { text } </ p >
262
263
{ showTime ? < p style = { { fontSize : motionTextFontSize } } > Elapsed Time: { time } sec</ p > : < > </ > }
264
+ { retry ? (
265
+ < Button
266
+ variant = 'warning'
267
+ className = 'mx-2 btn-huge'
268
+ size = 'lg'
269
+ onClick = { resumeCallback }
270
+ style = { {
271
+ width : '90%' ,
272
+ height : '20%'
273
+ } }
274
+ >
275
+ < h5 style = { { textAlign : 'center' , fontSize : motionTextFontSize } } > Retry</ h5 >
276
+ </ Button >
277
+ ) : (
278
+ < > </ >
279
+ ) }
263
280
</ View >
264
281
< View
265
282
style = { {
@@ -276,7 +293,7 @@ const RobotMotion = (props) => {
276
293
</ >
277
294
)
278
295
} ,
279
- [ dimension , props . waitingText , motionTextFontSize , waitingTextFontSize ]
296
+ [ dimension , props . waitingText , motionTextFontSize , waitingTextFontSize , resumeCallback ]
280
297
)
281
298
282
299
/**
@@ -288,39 +305,36 @@ const RobotMotion = (props) => {
288
305
( actionStatus , flexSizeOuter ) => {
289
306
let flexSizeTextInner = 1
290
307
let flexSizeVisualInner = 1
291
- let text
292
- let time
293
- let showTime
308
+ let text = 'Robot is paused'
309
+ let showTime = false
310
+ let time = 0
311
+ let progress = null
294
312
switch ( actionStatus . actionStatus ) {
295
313
case ROS_ACTION_STATUS_EXECUTE :
296
314
if ( actionStatus . feedback ) {
297
- let progress = 1 - actionStatus . feedback . motion_curr_distance / actionStatus . feedback . motion_initial_distance
298
315
if ( ! actionStatus . feedback . is_planning ) {
299
316
let moving_elapsed_time = actionStatus . feedback . motion_time . sec + actionStatus . feedback . motion_time . nanosec / 10 ** 9
300
317
text = 'Robot is moving...'
301
318
time = Math . round ( moving_elapsed_time * 100 ) / 100
302
319
showTime = true
320
+ progress = 1 - actionStatus . feedback . motion_curr_distance / actionStatus . feedback . motion_initial_distance
303
321
// Calling CircleProgessBar component to visualize robot motion of moving
304
322
return < > { actionStatusTextAndVisual ( flexSizeOuter , flexSizeTextInner , flexSizeVisualInner , text , showTime , time , progress ) } </ >
305
323
} else {
306
324
let planning_elapsed_time = actionStatus . feedback . planning_time . sec + actionStatus . feedback . planning_time . nanosec / 10 ** 9
307
325
text = 'Robot is thinking...'
308
326
time = Math . round ( planning_elapsed_time * 100 ) / 100
309
327
showTime = true
310
- return < > { actionStatusTextAndVisual ( flexSizeOuter , flexSizeTextInner , flexSizeVisualInner , text , showTime , time , null ) } </ >
328
+ return < > { actionStatusTextAndVisual ( flexSizeOuter , flexSizeTextInner , flexSizeVisualInner , text , showTime , time , progress ) } </ >
311
329
}
312
330
} else {
313
331
// If you haven't gotten feedback yet, assume the robot is planning
314
332
text = 'Robot is thinking...'
315
- time = 0
316
- showTime = false
317
- return < > { actionStatusTextAndVisual ( flexSizeOuter , flexSizeTextInner , flexSizeVisualInner , text , showTime , time , null ) } </ >
333
+ return < > { actionStatusTextAndVisual ( flexSizeOuter , flexSizeTextInner , flexSizeVisualInner , text , showTime , time , progress ) } </ >
318
334
}
319
335
case ROS_ACTION_STATUS_SUCCEED :
320
336
text = 'Robot has finished'
321
- time = 0
322
- showTime = false
323
- return < > { actionStatusTextAndVisual ( flexSizeOuter , flexSizeTextInner , flexSizeVisualInner , text , showTime , time , null ) } </ >
337
+ return < > { actionStatusTextAndVisual ( flexSizeOuter , flexSizeTextInner , flexSizeVisualInner , text , showTime , time , progress ) } </ >
324
338
case ROS_ACTION_STATUS_ABORT :
325
339
/**
326
340
* TODO: Just displaying that the robot faced an error is not useful
@@ -329,20 +343,14 @@ const RobotMotion = (props) => {
329
343
* users on how to troubleshoot/fix it.
330
344
*/
331
345
text = 'Robot encountered an error'
332
- time = 0
333
- showTime = false
334
- return < > { actionStatusTextAndVisual ( flexSizeOuter , flexSizeTextInner , flexSizeVisualInner , text , showTime , time , null ) } </ >
346
+ return (
347
+ < > { actionStatusTextAndVisual ( flexSizeOuter , flexSizeTextInner , flexSizeVisualInner , text , showTime , time , progress , true ) } </ >
348
+ )
335
349
case ROS_ACTION_STATUS_CANCELED :
336
- text = 'Robot is paused'
337
- time = 0
338
- showTime = false
339
- return < > { actionStatusTextAndVisual ( flexSizeOuter , flexSizeTextInner , flexSizeVisualInner , text , showTime , time , null ) } </ >
350
+ return < > { actionStatusTextAndVisual ( flexSizeOuter , flexSizeTextInner , flexSizeVisualInner , text , showTime , time , progress ) } </ >
340
351
default :
341
352
if ( paused ) {
342
- text = 'Robot is paused'
343
- time = 0
344
- showTime = false
345
- return < > { actionStatusTextAndVisual ( flexSizeOuter , flexSizeTextInner , flexSizeVisualInner , text , showTime , time , null ) } </ >
353
+ return < > { actionStatusTextAndVisual ( flexSizeOuter , flexSizeTextInner , flexSizeVisualInner , text , showTime , time , progress ) } </ >
346
354
} else {
347
355
return (
348
356
< View
0 commit comments