AndrewWalker / Dubins-Curves

Path generation for the Dubin's car
MIT License
267 stars 86 forks source link

Sampling along Dubins path increases length to goal #15

Closed LeeYiyuan closed 5 years ago

LeeYiyuan commented 5 years ago

Sampling is done along the Dubins path between a start point (16.2953, 0.12524, 0.575959) and and endpoint (17.2329, 2.0764, 2.28307). As the samples get closer to the endpoint, the distance between the current sample to the endpoint jumps at some point. Below is the test code, followed by the test output.

#include "dubins.h"
#include <stdio.h>

double start[] = { 16.2953, 0.12524, 0.575959 };
double end[] = { 17.2329, 2.0764, 2.28307 };

int printConfiguration(double q[3], double x, void* user_data) {
    DubinsPath path;
    dubins_shortest_path(&path, q, end, 1.0);

    printf("%f, %f, %f, %f, %f\n", q[0], q[1], q[2], x, dubins_path_length(&path));
    return 0;
}

int main()
{
    DubinsPath path;
    dubins_shortest_path(&path, start, end, 1.0);

    printf("#x,y,theta,t\n");
    dubins_path_sample_many(&path,  0.1, printConfiguration, NULL);

    return 0;
}

Test output:

0: 16.295300, 0.125240, 0.575959, 0.000000, 2.565464
1: 16.379776, 0.178753, 0.563946, 0.100000, 2.465464
2: 16.464292, 0.232206, 0.563946, 0.200000, 2.365464
3: 16.548807, 0.285658, 0.563946, 0.300000, 2.265464
4: 16.633322, 0.339111, 0.563946, 0.400000, 2.165464
5: 16.717837, 0.392564, 0.563946, 0.500000, 2.065464
6: 16.802353, 0.446016, 0.563946, 0.600000, 1.965464
7: 16.886868, 0.499469, 0.563946, 0.700000, 1.865464
8: 16.971383, 0.552921, 0.563946, 0.800000, 1.765464
9: 17.055107, 0.607576, 0.617606, 0.900000, 7.569978
10: 17.133605, 0.669461, 0.717606, 1.000000, 7.848649
11: 17.205533, 0.738874, 0.817606, 1.100000, 7.748649
12: 17.270171, 0.815121, 0.917606, 1.200000, 7.648649
13: 17.326875, 0.897439, 1.017606, 1.300000, 7.548649
14: 17.375077, 0.985008, 1.117606, 1.400000, 7.448649
15: 17.414296, 1.076951, 1.217606, 1.500000, 7.348649
16: 17.444140, 1.172350, 1.317606, 1.600000, 7.248649
17: 17.464311, 1.270252, 1.417606, 1.700000, 7.148649
18: 17.474608, 1.369678, 1.517606, 1.800000, 7.048649
19: 17.474927, 1.469636, 1.617606, 1.900000, 6.948649
20: 17.465265, 1.569126, 1.717606, 2.000000, 6.848649
21: 17.445719, 1.667155, 1.817606, 2.100000, 6.748649
22: 17.416484, 1.762743, 1.917606, 2.200000, 6.648649
23: 17.377852, 1.854934, 2.017606, 2.300000, 6.548649
24: 17.330210, 1.942808, 2.117606, 2.400000, 6.448649
25: 17.274033, 2.025487, 2.217606, 2.500000, 6.348649

The distance spikes from sample 8 to 9, not sure if this can be considered expected behavior.

LeeYiyuan commented 5 years ago

Turns out the Dubins metric is discontinuous after all, sorry for the confusion.