2 * Copyright (c) 2008-2018, Andrew Walker
3 * SPDX-FileCopyrightText: 2008-2018 Andrew Walker
5 * SPDX-License-Identifier: MIT
27 /* the initial configuration */
29 /* the lengths of the three segments */
31 /* model forward velocity / model angular velocity */
33 /* the path type described */
37 #define EDUBOK (0) /* No error */
38 #define EDUBCOCONFIGS (1) /* Colocated configurations */
39 #define EDUBPARAM (2) /* Path parameterisitation error */
40 #define EDUBBADRHO (3) /* the rho value is invalid */
41 #define EDUBNOPATH (4) /* no connection between configurations with this word */
44 * Callback function for path sampling
46 * @note the q parameter is a configuration
47 * @note the t parameter is the distance along the path
48 * @note the user_data parameter is forwarded from the caller
49 * @note return non-zero to denote sampling should be stopped
51 typedef int (*DubinsPathSamplingCallback)(double q[3], double t, void* user_data);
54 * Generate a path from an initial configuration to
55 * a target configuration, with a specified maximum turning
58 * A configuration is (x, y, theta), where theta is in radians, with zero
59 * along the line x = 0, and counter-clockwise is positive
61 * @param path - the resultant path
62 * @param q0 - a configuration specified as an array of x, y, theta
63 * @param q1 - a configuration specified as an array of x, y, theta
64 * @param rho - turning radius of the vehicle (forward velocity divided by maximum angular velocity)
65 * @return - non-zero on error
67 int dubins_shortest_path(DubinsPath* path, double q0[3], double q1[3], double rho);
70 * Generate a path with a specified word from an initial configuration to
71 * a target configuration, with a specified turning radius
73 * @param path - the resultant path
74 * @param q0 - a configuration specified as an array of x, y, theta
75 * @param q1 - a configuration specified as an array of x, y, theta
76 * @param rho - turning radius of the vehicle (forward velocity divided by maximum angular velocity)
77 * @param pathType - the specific path type to use
78 * @return - non-zero on error
80 int dubins_path(DubinsPath* path, double q0[3], double q1[3], double rho, DubinsPathType pathType);
83 * Calculate the length of an initialised path
85 * @param path - the path to find the length of
87 double dubins_path_length(DubinsPath* path);
90 * Return the length of a specific segment in an initialized path
92 * @param path - the path to find the length of
93 * @param i - the segment you to get the length of (0-2)
95 double dubins_segment_length(DubinsPath* path, int i);
98 * Return the normalized length of a specific segment in an initialized path
100 * @param path - the path to find the length of
101 * @param i - the segment you to get the length of (0-2)
103 double dubins_segment_length_normalized( DubinsPath* path, int i );
106 * Extract an integer that represents which path type was used
108 * @param path - an initialised path
109 * @return - one of LSL, LSR, RSL, RSR, RLR or LRL
111 DubinsPathType dubins_path_type(DubinsPath* path);
114 * Calculate the configuration along the path, using the parameter t
116 * @param path - an initialised path
117 * @param t - a length measure, where 0 <= t < dubins_path_length(path)
118 * @param q - the configuration result
119 * @returns - non-zero if 't' is not in the correct range
121 int dubins_path_sample(DubinsPath* path, double t, double q[3]);
124 * Walk along the path at a fixed sampling interval, calling the
125 * callback function at each interval
127 * The sampling process continues until the whole path is sampled, or the callback returns a non-zero value
129 * @param path - the path to sample
130 * @param stepSize - the distance along the path for subsequent samples
131 * @param cb - the callback function to call for each sample
132 * @param user_data - optional information to pass on to the callback
134 * @returns - zero on successful completion, or the result of the callback
136 int dubins_path_sample_many(DubinsPath* path,
138 DubinsPathSamplingCallback cb,
142 * Convenience function to identify the endpoint of a path
144 * @param path - an initialised path
145 * @param q - the configuration result
147 int dubins_path_endpoint(DubinsPath* path, double q[3]);
150 * Convenience function to extract a subset of a path
152 * @param path - an initialised path
153 * @param t - a length measure, where 0 < t < dubins_path_length(path)
154 * @param newpath - the resultant path
156 int dubins_extract_subpath(DubinsPath* path, double t, DubinsPath* newpath);
162 #endif /* DUBINS_H */