@@ -428,7 +428,7 @@ int main(int argc, char** argv) {
428
428
// / Visualize Geofence
429
429
publishGeoFence (geofence_pub, geofence_polygon);
430
430
431
- // /TODO: Parse mission to generate reference path
431
+ // Parse mission to generate reference path
432
432
std::vector<Eigen::Vector3d> waypoint_list;
433
433
json mission = data[" mission" ][" items" ];
434
434
for (auto mission_item : mission) {
@@ -440,7 +440,6 @@ int main(int argc, char** argv) {
440
440
const double waypoint_lat = mission_item[" params" ][4 ];
441
441
const double waypoint_lon = mission_item[" params" ][5 ];
442
442
const double waypoint_relative_alt = mission_item[" params" ][6 ];
443
- Eigen::Vector3d waypoint_wgs84 (waypoint_lat, waypoint_lon, waypoint_relative_alt);
444
443
Eigen::Vector3d waypoint_lv03;
445
444
GeoConversions::forward (waypoint_lat, waypoint_lon, 0.0 , waypoint_lv03.x (), waypoint_lv03.y (),
446
445
waypoint_lv03.z ()); // / FIXME: Assuming zero AMSL
@@ -457,6 +456,30 @@ int main(int argc, char** argv) {
457
456
458
457
publishWaypoints (waypoint_pub, waypoint_list);
459
458
459
+ // / Parse rally points from mission file
460
+ std::vector<Eigen::Vector3d> rallypoint_list;
461
+ const double map_width_x = terrain_map->getGridMap ().getLength ().x ();
462
+ const double map_width_y = terrain_map->getGridMap ().getLength ().y ();
463
+ const Eigen::Vector2d map_pos = terrain_map->getGridMap ().getPosition ();
464
+
465
+ json mission_rallypoints = data[" rallyPoints" ][" points" ];
466
+ for (auto rallypoint : mission_rallypoints) {
467
+ std::cout << " - Rallypoint: " << rallypoint << std::endl;
468
+ const double rallypoint_lat = rallypoint[0 ];
469
+ const double rallypoint_lon = rallypoint[1 ];
470
+ const double rallypoint_relative_alt = rallypoint[2 ];
471
+ Eigen::Vector3d rallypoint_lv03;
472
+ GeoConversions::forward (rallypoint_lat, rallypoint_lon, 0.0 , rallypoint_lv03.x (), rallypoint_lv03.y (),
473
+ rallypoint_lv03.z ()); // / FIXME: Assuming zero AMSL
474
+ ESPG map_coordinate;
475
+ Eigen::Vector3d map_origin;
476
+ terrain_map->getGlobalOrigin (map_coordinate, map_origin);
477
+ Eigen::Vector3d rallypoint_local = rallypoint_lv03 - map_origin;
478
+ rallypoint_local.z () = terrain_map->getGridMap ().atPosition (" elevation" , rallypoint_local.head (2 )) + rallypoint_relative_alt;
479
+ rallypoint_list.push_back (rallypoint_local);
480
+ }
481
+ publishRallyPoints (rallypoint_pub, rallypoint_list, radius, Eigen::Vector3d (1.0 , 0.0 , 0.0 ));
482
+
460
483
terrain_map->getGridMap ().setTimestamp (ros::Time::now ().toNSec ());
461
484
publishGridMap (grid_map_pub, terrain_map->getGridMap ());
462
485
@@ -468,10 +491,6 @@ int main(int argc, char** argv) {
468
491
// / TODO: Get bounds from gridmap
469
492
planner->setBoundsFromMap (terrain_map->getGridMap ());
470
493
471
- const double map_width_x = terrain_map->getGridMap ().getLength ().x ();
472
- const double map_width_y = terrain_map->getGridMap ().getLength ().y ();
473
- const Eigen::Vector2d map_pos = terrain_map->getGridMap ().getPosition ();
474
-
475
494
Eigen::Vector3d start{Eigen::Vector3d (map_pos (0 ) + 0.4 * map_width_x, map_pos (1 ) - 0.35 * map_width_y, 0.0 )};
476
495
Eigen::Vector3d updated_start;
477
496
if (validatePosition (terrain_map, start, updated_start)) {
@@ -509,28 +528,6 @@ int main(int argc, char** argv) {
509
528
510
529
path.appendSegment (goal_loiter_path);
511
530
512
- // / Generate candidate rally points
513
- std::cout << " Generating rally points" << std::endl;
514
- const int num_rally_points = 6 ;
515
- std::vector<Eigen::Vector3d> rally_points;
516
- for (int i = 0 ; i < num_rally_points; i++) {
517
- bool sample_is_valid = false ;
518
- while (!sample_is_valid) {
519
- Eigen::Vector3d random_sample;
520
- random_sample (0 ) =
521
- getRandom (map_pos (0 ) - (0.4 * map_width_x - radius), map_pos (0 ) + (0.4 * map_width_x - radius));
522
- random_sample (1 ) =
523
- getRandom (map_pos (1 ) - (0.4 * map_width_y - radius), map_pos (1 ) + (0.4 * map_width_y - radius));
524
- Eigen::Vector3d candidate_loiter_position = random_sample;
525
- Eigen::Vector3d new_loiter_position;
526
- sample_is_valid = validatePosition (terrain_map->getGridMap (), candidate_loiter_position, new_loiter_position);
527
- if (sample_is_valid) {
528
- rally_points.push_back (new_loiter_position);
529
- }
530
- }
531
- }
532
- publishRallyPoints (rallypoint_pub, rally_points, radius, Eigen::Vector3d (1.0 , 1.0 , 0.0 ));
533
-
534
531
std::cout << " Successfully Generated rally points" << std::endl;
535
532
536
533
// / TODO: Iterate over path segments to find abort paths
@@ -540,7 +537,7 @@ int main(int argc, char** argv) {
540
537
std::cout << " - segment ID: " << segment_id << std::endl;
541
538
Eigen::Vector3d segment_end = path_segment.states .back ().position ;
542
539
Eigen::Vector3d segment_end_tangent = path_segment.states .back ().velocity ;
543
- planner->setupProblem (segment_end, segment_end_tangent, rally_points );
540
+ planner->setupProblem (segment_end, segment_end_tangent, rallypoint_list );
544
541
Path abort_path;
545
542
if (planner->Solve (10.0 , abort_path)) {
546
543
std::cout << " [TestRRTCircleGoal] Found Solution!" << std::endl;
0 commit comments