@@ -261,7 +261,7 @@ import _ from "lodash";
261
261
import L from " leaflet" ;
262
262
import ROSLIB from " roslib" ;
263
263
264
- let interval ;
264
+ let stuck_interval, intermediate_publish_interval ;
265
265
266
266
const WAYPOINT_TYPES = {
267
267
NO_SEARCH : 0 ,
@@ -433,42 +433,53 @@ export default {
433
433
},
434
434
435
435
beforeDestroy : function () {
436
- window .clearInterval (interval);
436
+ window .clearInterval (stuck_interval);
437
+ window .clearInterval (intermediate_publish_interval);
437
438
this .autonEnabled = false ;
438
439
this .sendEnableAuton ();
439
440
},
440
441
441
442
created : function () {
442
- ( this .course_pub = new ROSLIB.Service ({
443
+ this .course_pub = new ROSLIB.Topic ({
443
444
ros: this .$ros ,
444
- name: " /enable_auton" ,
445
- serviceType: " mrover/PublishEnableAuton" ,
446
- })),
447
- (this .nav_status_sub = new ROSLIB.Topic ({
448
- ros: this .$ros ,
449
- name: " /smach/container_status" ,
450
- messageType: " smach_msgs/SmachContainerStatus" ,
451
- })),
452
- (this .rover_stuck_pub = new ROSLIB.Topic ({
453
- ros: this .$ros ,
454
- name: " /rover_stuck" ,
455
- messageType: " std_msgs/Bool" ,
456
- })),
457
- // Make sure local odom format matches vuex odom format
458
- (this .odom_format_in = this .odom_format );
445
+ name: " /intermediate_enable_auton" ,
446
+ messageType: " mrover/EnableAuton" ,
447
+ });
448
+
449
+ this .nav_status_sub = new ROSLIB.Topic ({
450
+ ros: this .$ros ,
451
+ name: " /nav_state" ,
452
+ messageType: " std_msgs/String" ,
453
+ });
454
+
455
+ this .rover_stuck_pub = new ROSLIB.Topic ({
456
+ ros: this .$ros ,
457
+ name: " /rover_stuck" ,
458
+ messageType: " std_msgs/Bool" ,
459
+ });
460
+
461
+ // Make sure local odom format matches vuex odom format
462
+ this .odom_format_in = this .odom_format ;
459
463
460
464
this .nav_status_sub .subscribe ((msg ) => {
461
- if (msg .active_states [0 ] !== " OffState" && ! this .autonEnabled ) {
465
+ // If still waiting for nav...
466
+ if ((msg .data == " OffState" && this .autonEnabled ) ||
467
+ (msg .data !== " OffState" && ! this .autonEnabled )) {
462
468
return ;
463
469
}
470
+
464
471
this .waitingForNav = false ;
465
472
this .autonButtonColor = this .autonEnabled ? " green" : " red" ;
466
473
});
467
474
468
475
// Interval for publishing stuck status for training data
469
- interval = window .setInterval (() => {
476
+ stuck_interval = window .setInterval (() => {
470
477
this .rover_stuck_pub .publish ({ data: this .roverStuck });
471
478
}, 100 );
479
+
480
+ intermediate_publish_interval = window .setInterval (() => {
481
+ this .sendEnableAuton ();
482
+ }, 1000 );
472
483
},
473
484
474
485
mounted : function () {
@@ -490,12 +501,9 @@ export default {
490
501
}),
491
502
492
503
sendEnableAuton () {
493
- let course;
494
-
495
504
// If Auton Enabled send course
496
505
if (this .autonEnabled ) {
497
- course = {
498
- enable: true ,
506
+ this .course_pub .publish ({
499
507
// Map for every waypoint in the current route
500
508
waypoints: _ .map (this .route , (waypoint ) => {
501
509
const lat = waypoint .lat ;
@@ -516,20 +524,12 @@ export default {
516
524
id: parseInt (waypoint .id ),
517
525
};
518
526
}),
519
- };
527
+ enable: true
528
+ });
520
529
} else {
521
530
// Else send false and no array
522
- course = {
523
- enable: false ,
524
- waypoints: [],
525
- };
531
+ this .course_pub .publish ({waypoints: [], enable: false });
526
532
}
527
-
528
- const course_request = new ROSLIB.ServiceRequest ({
529
- enableMsg: course,
530
- });
531
-
532
- this .course_pub .callService (course_request, () => {});
533
533
},
534
534
535
535
openModal : function () {
@@ -677,8 +677,8 @@ export default {
677
677
678
678
toggleAutonMode : function (val ) {
679
679
this .setAutonMode (val);
680
- // This will trigger the yellow "waiting for nav" state of the checkbox only if we are enabling the button
681
- this .autonButtonColor = val ? " yellow" : " red " ;
680
+ // This will trigger the yellow "waiting for nav" state of the checkbox
681
+ this .autonButtonColor = " yellow" ;
682
682
this .waitingForNav = true ;
683
683
this .sendEnableAuton ();
684
684
},
0 commit comments