123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- #include <vector>
- #include <AP_BoardConfig/AP_BoardConfig.h>
- #include <AP_HAL/AP_HAL.h>
- #include <AP_Math/AP_Math.h>
- #include <AP_SmartRTL/AP_SmartRTL.h>
- // vectors defined below:
- // test_path_before
- // test_path_after_adding
- // test_path_after_simplifying
- // test_path_after_pruning
- // test_path_complete
- // assume that any point without a comment should be kept
- std::vector<Vector3f> test_path_before {
- {0.0, 0.0, 0.0},
- {3.0, 0.0, 0.0}, // simplified
- {3.0, 0.0, 0.0}, // not added
- {6.0, 0.0, 0.0}, // simplified
- {10.0, 0.0, 0.0},
- {10.0, 3.0, 0.0},
- {13.0, 3.0, 0.0},
- {13.0, 6.0, 0.0},
- {16.0, 6.0, 0.0},
- {16.0, 6.0, 1.0}, // not added
- {16.0, 8.0, 1.0},
- {18.0, 8.0, 0.0},
- {20.0, 10.0, 0.0},
- {20.0, 10.0, 10.0},
- {23.0, 10.0, 10.0},
- {23.0, 13.0, 10.0},
- {26.0, 13.0, 10.0},
- {26.0, 16.0, 10.0},
- {29.0, 16.0, 10.0},
- {29.0, 19.0, 10.0},
- {32.0, 19.0, 10.0},
- {32.0, 22.0, 10.0},
- {35.0, 22.0, 10.0},
- {35.0, 25.0, 10.0},
- {38.0, 25.0, 10.0},
- {38.0, 28.0, 10.0},
- {41.0, 28.0, 10.0},
- {41.0, 31.0, 10.0},
- {44.0, 31.0, 10.0},
- {44.0, 34.0, 10.0},
- {47.0, 34.0, 10.0},
- {47.0, 37.0, 10.0},
- {51.0, 37.0, 10.0},
- {51.0, 41.0, 10.0},
- {54.0, 41.0, 10.0},
- {54.0, 44.0, 10.0},
- {57.0, 44.0, 10.0},
- {57.0, 47.0, 10.0},
- {60.0, 47.0, 10.0},
- {60.0, 40.0, 10.0},
- {63.0, 40.0, 10.0},
- {63.0, 43.0, 10.0},
- {66.0, 43.0, 10.0},
- {66.0, 46.0, 10.0},
- {69.0, 46.0, 10.0},
- {69.0, 49.0, 10.0},
- {72.0, 49.0, 10.0},
- {72.0, 52.0, 10.0},
- {75.0, 52.0, 10.0},
- {75.0, 55.0, 10.0},
- {100.0, 100.0, 100.0}, // pruned
- {103.0, 100.0, 100.0}, // pruned
- {106.0, 103.0, 100.0}, // pruned
- {103.0, 106.0, 100.0}, // pruned
- {100.0, 103.0, 100.0}, // pruned
- {103.0, 100.0, 100.0}, // pruned
- {200.0, 200.0, 200.0},
- {203.0, 200.0, 200.0},
- {203.0, 203.0, 200.0},
- {206.0, 203.0, 200.0},
- {206.0, 206.0, 200.0},
- {209.0, 206.0, 200.0},
- {209.0, 209.0, 200.0},
- {212.0, 209.0, 200.0},
- {212.0, 212.0, 200.0},
- {220.0, 220.0, 200.0},
- {223.0, 220.0, 200.0}, // pruned
- {226.0, 223.0, 200.0}, // pruned
- {223.0, 226.0, 200.0}, // pruned
- {220.0, 223.0, 200.0}, // pruned
- {223.0, 220.0, 201.0}, // pruned
- {226.0, 223.0, 200.0}, // pruned
- {223.0, 226.0, 200.0}, // pruned
- {220.0, 223.0, 200.0}, // pruned
- {223.0, 220.0, 199.0}, // pruned
- {229.0, 220.0, 200.0},
- {300.0, 300.0, 300.0},
- {305.0, 300.0, 300.0}, // simplified, pruned
- {310.0, 300.0, 300.0}, // simplified, pruned
- {315.0, 300.5, 300.0}, // simplified, pruned
- {320.0, 299.5, 300.0}, // simplified, pruned
- {325.0, 300.5, 300.0}, // simplified, pruned
- {330.0, 299.5, 300.0}, // simplified, pruned
- {335.0, 300.5, 300.0}, // simplified, pruned
- {340.0, 299.5, 300.0}, // simplified, pruned
- {345.0, 300.5, 300.0}, // simplified, pruned
- {350.0, 300.0, 300.0}, // pruned
- {350.0, 300.0, 400.0}, // pruned
- {345.0, 300.5, 400.0}, // simplified, pruned
- {340.0, 299.5, 400.0}, // simplified, pruned
- {335.0, 300.5, 400.0}, // simplified, pruned
- {330.0, 299.5, 400.0}, // simplified, pruned
- {325.0, 300.5, 400.0}, // simplified, pruned
- {320.0, 299.5, 400.0}, // simplified, pruned
- {315.0, 300.5, 400.0}, // simplified, pruned
- {310.0, 300.0, 400.0}, // simplified, pruned
- {305.0, 300.0, 400.0}, // pruned
- {300.0, 300.0, 295.0},
- };
- std::vector<Vector3f> test_path_after_adding {
- {0.0, 0.0, 0.0}, // 0
- {3.0, 0.0, 0.0},
- {6.0, 0.0, 0.0},
- {10.0, 0.0, 0.0},
- {10.0, 3.0, 0.0},
- {13.0, 3.0, 0.0},
- {13.0, 6.0, 0.0},
- {16.0, 6.0, 0.0},
- {16.0, 8.0, 1.0},
- {18.0, 8.0, 0.0},
- {20.0, 10.0, 0.0}, // 10
- {20.0, 10.0, 10.0},
- {23.0, 10.0, 10.0},
- {23.0, 13.0, 10.0},
- {26.0, 13.0, 10.0},
- {26.0, 16.0, 10.0},
- {29.0, 16.0, 10.0},
- {29.0, 19.0, 10.0},
- {32.0, 19.0, 10.0},
- {32.0, 22.0, 10.0},
- {35.0, 22.0, 10.0}, // 20
- {35.0, 25.0, 10.0},
- {38.0, 25.0, 10.0},
- {38.0, 28.0, 10.0},
- {41.0, 28.0, 10.0},
- {41.0, 31.0, 10.0},
- {44.0, 31.0, 10.0},
- {44.0, 34.0, 10.0},
- {47.0, 34.0, 10.0},
- {47.0, 37.0, 10.0},
- {51.0, 37.0, 10.0}, // 30
- {51.0, 41.0, 10.0},
- {54.0, 41.0, 10.0},
- {54.0, 44.0, 10.0},
- {57.0, 44.0, 10.0},
- {57.0, 47.0, 10.0},
- {60.0, 47.0, 10.0},
- {60.0, 40.0, 10.0},
- {63.0, 40.0, 10.0},
- {63.0, 43.0, 10.0},
- {66.0, 43.0, 10.0}, // 40
- {66.0, 46.0, 10.0},
- {69.0, 46.0, 10.0},
- {69.0, 49.0, 10.0},
- {72.0, 49.0, 10.0},
- {72.0, 52.0, 10.0},
- {75.0, 52.0, 10.0},
- {75.0, 55.0, 10.0},
- {100.0, 100.0, 100.0},
- {103.0, 100.0, 100.0},
- {106.0, 103.0, 100.0}, // 50
- {103.0, 106.0, 100.0},
- {100.0, 103.0, 100.0},
- {103.0, 100.0, 100.0},
- {200.0, 200.0, 200.0},
- {203.0, 200.0, 200.0},
- {203.0, 203.0, 200.0},
- {206.0, 203.0, 200.0},
- {206.0, 206.0, 200.0},
- {209.0, 206.0, 200.0},
- {209.0, 209.0, 200.0}, // 60
- {212.0, 209.0, 200.0},
- {212.0, 212.0, 200.0},
- {220.0, 220.0, 200.0},
- {223.0, 220.0, 200.0},
- {226.0, 223.0, 200.0},
- {223.0, 226.0, 200.0},
- {220.0, 223.0, 200.0},
- {223.0, 220.0, 201.0},
- {226.0, 223.0, 200.0},
- {223.0, 226.0, 200.0}, // 70
- {220.0, 223.0, 200.0},
- {223.0, 220.0, 199.0},
- {229.0, 220.0, 200.0},
- {300.0, 300.0, 300.0},
- {305.0, 300.0, 300.0},
- {310.0, 300.0, 300.0},
- {315.0, 300.5, 300.0},
- {320.0, 299.5, 300.0},
- {325.0, 300.5, 300.0},
- {330.0, 299.5, 300.0}, // 80
- {335.0, 300.5, 300.0},
- {340.0, 299.5, 300.0},
- {345.0, 300.5, 300.0},
- {350.0, 300.0, 300.0},
- {350.0, 300.0, 400.0},
- {345.0, 300.5, 400.0},
- {340.0, 299.5, 400.0},
- {335.0, 300.5, 400.0},
- {330.0, 299.5, 400.0},
- {325.0, 300.5, 400.0}, // 90
- {320.0, 299.5, 400.0},
- {315.0, 300.5, 400.0},
- {310.0, 300.0, 400.0},
- {305.0, 300.0, 400.0},
- {300.0, 300.0, 295.0},
- };
- std::vector<Vector3f> test_path_after_simplifying {
- {0.0, 0.0, 0.0}, // 0
- {10.0, 0.0, 0.0},
- {10.0, 3.0, 0.0},
- {13.0, 3.0, 0.0},
- {13.0, 6.0, 0.0},
- {16.0, 6.0, 0.0},
- {16.0, 8.0, 1.0},
- {18.0, 8.0, 0.0},
- {20.0, 10.0, 0.0},
- {20.0, 10.0, 10.0},
- {23.0, 10.0, 10.0}, // 10
- {23.0, 13.0, 10.0},
- {26.0, 13.0, 10.0},
- {26.0, 16.0, 10.0},
- {29.0, 16.0, 10.0},
- {29.0, 19.0, 10.0},
- {32.0, 19.0, 10.0},
- {32.0, 22.0, 10.0},
- {35.0, 22.0, 10.0},
- {35.0, 25.0, 10.0},
- {38.0, 25.0, 10.0}, // 20
- {38.0, 28.0, 10.0},
- {41.0, 28.0, 10.0},
- {41.0, 31.0, 10.0},
- {44.0, 31.0, 10.0},
- {44.0, 34.0, 10.0},
- {47.0, 34.0, 10.0},
- {47.0, 37.0, 10.0},
- {51.0, 37.0, 10.0},
- {51.0, 41.0, 10.0},
- {54.0, 41.0, 10.0}, // 30
- {54.0, 44.0, 10.0},
- {57.0, 44.0, 10.0},
- {57.0, 47.0, 10.0},
- {60.0, 47.0, 10.0},
- {60.0, 40.0, 10.0},
- {63.0, 40.0, 10.0},
- {63.0, 43.0, 10.0},
- {66.0, 43.0, 10.0},
- {66.0, 46.0, 10.0},
- {69.0, 46.0, 10.0}, // 40
- {69.0, 49.0, 10.0},
- {72.0, 49.0, 10.0},
- {72.0, 52.0, 10.0},
- {75.0, 52.0, 10.0},
- {75.0, 55.0, 10.0},
- {100.0, 100.0, 100.0},
- {103.0, 100.0, 100.0},
- {106.0, 103.0, 100.0},
- {103.0, 106.0, 100.0},
- {100.0, 103.0, 100.0}, // 50
- {103.0, 100.0, 100.0},
- {200.0, 200.0, 200.0},
- {203.0, 200.0, 200.0},
- {203.0, 203.0, 200.0},
- {206.0, 203.0, 200.0},
- {206.0, 206.0, 200.0},
- {209.0, 206.0, 200.0},
- {209.0, 209.0, 200.0},
- {212.0, 209.0, 200.0},
- {212.0, 212.0, 200.0}, // 60
- {220.0, 220.0, 200.0},
- {223.0, 220.0, 200.0},
- {226.0, 223.0, 200.0},
- {223.0, 226.0, 200.0},
- {220.0, 223.0, 200.0},
- {223.0, 220.0, 201.0},
- {226.0, 223.0, 200.0},
- {223.0, 226.0, 200.0},
- {220.0, 223.0, 200.0},
- {223.0, 220.0, 199.0}, // 70
- {229.0, 220.0, 200.0},
- {300.0, 300.0, 300.0},
- {350.0, 300.0, 300.0},
- {350.0, 300.0, 400.0},
- {305.0, 300.0, 400.0},
- {300.0, 300.0, 295.0},
- };
- std::vector<Vector3f> test_path_complete {
- {0.0, 0.0, 0.0}, // 0
- {10.0, 0.0, 0.0},
- {10.0, 3.0, 0.0},
- {13.0, 3.0, 0.0},
- {13.0, 6.0, 0.0},
- {16.0, 6.0, 0.0},
- {16.0, 8.0, 1.0},
- {18.0, 8.0, 0.0},
- {20.0, 10.0, 0.0},
- {20.0, 10.0, 10.0},
- {23.0, 10.0, 10.0}, // 10
- {23.0, 13.0, 10.0},
- {26.0, 13.0, 10.0},
- {26.0, 16.0, 10.0},
- {29.0, 16.0, 10.0},
- {29.0, 19.0, 10.0},
- {32.0, 19.0, 10.0},
- {32.0, 22.0, 10.0},
- {35.0, 22.0, 10.0},
- {35.0, 25.0, 10.0},
- {38.0, 25.0, 10.0}, // 20
- {38.0, 28.0, 10.0},
- {41.0, 28.0, 10.0},
- {41.0, 31.0, 10.0},
- {44.0, 31.0, 10.0},
- {44.0, 34.0, 10.0},
- {47.0, 34.0, 10.0},
- {47.0, 37.0, 10.0},
- {51.0, 37.0, 10.0},
- {51.0, 41.0, 10.0},
- {54.0, 41.0, 10.0}, // 30
- {54.0, 44.0, 10.0},
- {57.0, 44.0, 10.0},
- {57.0, 47.0, 10.0},
- {60.0, 47.0, 10.0},
- {60.0, 40.0, 10.0},
- {63.0, 40.0, 10.0},
- {63.0, 43.0, 10.0},
- {66.0, 43.0, 10.0},
- {66.0, 46.0, 10.0},
- {69.0, 46.0, 10.0}, // 40
- {69.0, 49.0, 10.0},
- {72.0, 49.0, 10.0},
- {72.0, 52.0, 10.0},
- {75.0, 52.0, 10.0},
- {75.0, 55.0, 10.0},
- {100.0, 100.0, 100.0},
- {103.0, 100.0, 100.0},
- {103.0, 100.0, 100.0},
- {200.0, 200.0, 200.0},
- {203.0, 200.0, 200.0}, // 50
- {203.0, 203.0, 200.0},
- {206.0, 203.0, 200.0},
- {206.0, 206.0, 200.0},
- {209.0, 206.0, 200.0},
- {209.0, 209.0, 200.0},
- {212.0, 209.0, 200.0},
- {212.0, 212.0, 200.0},
- {220.0, 220.0, 200.0},
- {223.0, 220.0, 200.0},
- {223.2368474, 220.0789542, 199.5263052}, // 60
- {229.0, 220.0, 200.0},
- {300.1223662, 300.0, 300.0696305},
- {300.0, 300.0, 295.0},
- };
|