Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions include/steering_functions/utilities/utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@

using namespace std;

#define PI 3.1415926535897932384
#define HALF_PI 1.5707963267948966192
#define TWO_PI 6.2831853071795864770
#define SQRT_PI 1.7724538509055160273
#define SQRT_PI_INV 0.56418958354775628695
#define SQRT_TWO_PI_INV 0.39894228040143267794
constexpr double STEERING_PI = 3.1415926535897932384;
constexpr double STEERING_HALF_PI = 1.5707963267948966192;
constexpr double STEERING_TWO_PI = 6.2831853071795864770;
constexpr double STEERING_SQRT_PI = 1.7724538509055160273;
constexpr double STEERING_SQRT_PI_INV = 0.56418958354775628695;
constexpr double STEERING_SQRT_TWO_PI_INV = 0.39894228040143267794;

const double epsilon = 1e-4;

Expand Down
4 changes: 2 additions & 2 deletions src/dubins_state_space/dubins_state_space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Dubins_State_Space::Dubins_Path dubinsRLR(double d, double alpha, double beta)
double tmp = .125 * (6. - d * d + 2. * (ca * cb + sa * sb + d * (sa - sb)));
if (fabs(tmp) < 1.)
{
double p = TWO_PI - acos(tmp);
double p = STEERING_TWO_PI - acos(tmp);
double theta = atan2(ca - cb, d - sa + sb);
double t = twopify(alpha - theta + .5 * p);
double q = twopify(alpha - beta - t + p);
Expand All @@ -160,7 +160,7 @@ Dubins_State_Space::Dubins_Path dubinsLRL(double d, double alpha, double beta)
double tmp = .125 * (6. - d * d + 2. * (ca * cb + sa * sb - d * (sa - sb)));
if (fabs(tmp) < 1.)
{
double p = TWO_PI - acos(tmp);
double p = STEERING_TWO_PI - acos(tmp);
double theta = atan2(-ca + cb, d + sa - sb);
double t = twopify(-alpha + theta + .5 * p);
double q = twopify(beta - alpha - t + p);
Expand Down
16 changes: 8 additions & 8 deletions src/filter/ekf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ void EKF::get_motion_jacobi(const State &state, const Control &control, double i
double abs_sigma = fabs(control.sigma);
double sqrt_sigma_inv = 1 / sqrt(abs_sigma);
double k1 = state.theta - 0.5 * d * state.kappa * state.kappa / control.sigma;
double k2 = SQRT_PI_INV * sqrt_sigma_inv * (abs_sigma * integration_step + sgn_sigma * state.kappa);
double k3 = SQRT_PI_INV * sqrt_sigma_inv * sgn_sigma * state.kappa;
double k4 = k1 + d * sgn_sigma * HALF_PI * k2 * k2;
double k5 = k1 + d * sgn_sigma * HALF_PI * k3 * k3;
double k2 = STEERING_SQRT_PI_INV * sqrt_sigma_inv * (abs_sigma * integration_step + sgn_sigma * state.kappa);
double k3 = STEERING_SQRT_PI_INV * sqrt_sigma_inv * sgn_sigma * state.kappa;
double k4 = k1 + d * sgn_sigma * STEERING_HALF_PI * k2 * k2;
double k5 = k1 + d * sgn_sigma * STEERING_HALF_PI * k3 * k3;
double cos_k1 = cos(k1);
double sin_k1 = sin(k1);
double cos_k4 = cos(k4);
Expand All @@ -86,9 +86,9 @@ void EKF::get_motion_jacobi(const State &state, const Control &control, double i
F_x(0, 0) = 1.0;
F_x(1, 1) = 1.0;

F_x(0, 2) = SQRT_PI * sqrt_sigma_inv *
F_x(0, 2) = STEERING_SQRT_PI* sqrt_sigma_inv *
(-d * sin_k1 * (fresnel_c_k2 - fresnel_c_k3) - sgn_sigma * cos_k1 * (fresnel_s_k2 - fresnel_s_k3));
F_x(1, 2) = SQRT_PI * sqrt_sigma_inv *
F_x(1, 2) = STEERING_SQRT_PI* sqrt_sigma_inv *
(d * cos_k1 * (fresnel_c_k2 - fresnel_c_k3) - sgn_sigma * sin_k1 * (fresnel_s_k2 - fresnel_s_k3));
F_x(2, 2) = 1.0;

Expand All @@ -97,11 +97,11 @@ void EKF::get_motion_jacobi(const State &state, const Control &control, double i
F_u(1, 0) = sin_k4;
F_u(2, 0) = state.kappa + control.sigma * integration_step;

F_u(0, 1) = SQRT_PI * sqrt_sigma_inv * state.kappa *
F_u(0, 1) = STEERING_SQRT_PI* sqrt_sigma_inv * state.kappa *
(sgn_sigma * sin_k1 * (fresnel_c_k2 - fresnel_c_k3) + d * cos_k1 * (fresnel_s_k2 - fresnel_s_k3)) /
abs_sigma +
d * (cos_k4 - cos_k5) / control.sigma;
F_u(1, 1) = SQRT_PI * sqrt_sigma_inv * state.kappa *
F_u(1, 1) = STEERING_SQRT_PI* sqrt_sigma_inv * state.kappa *
(-sgn_sigma * cos_k1 * (fresnel_c_k2 - fresnel_c_k3) + d * sin_k1 * (fresnel_s_k2 - fresnel_s_k3)) /
abs_sigma +
d * (sin_k4 - sin_k5) / control.sigma;
Expand Down
24 changes: 12 additions & 12 deletions src/hc_cc_state_space/cc00_dubins_state_space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ class CC00_Dubins_State_Space::CC00_Dubins
{
if (c1.forward)
{
theta = angle + HALF_PI - c1.mu;
theta = angle + STEERING_HALF_PI - c1.mu;
}
else
{
theta = angle + HALF_PI + c1.mu;
theta = angle + STEERING_HALF_PI + c1.mu;
}
}
else
{
if (c1.forward)
{
theta = angle - HALF_PI + c1.mu;
theta = angle - STEERING_HALF_PI + c1.mu;
}
else
{
theta = angle - HALF_PI - c1.mu;
theta = angle - STEERING_HALF_PI - c1.mu;
}
}
*q = new Configuration(x, y, theta, 0);
Expand Down Expand Up @@ -145,9 +145,9 @@ class CC00_Dubins_State_Space::CC00_Dubins
{
theta = angle - alpha;
global_frame_change(c1.xc, c1.yc, theta, delta_x, delta_y, &x, &y);
*q1 = new Configuration(x, y, theta + PI, 0);
*q1 = new Configuration(x, y, theta + STEERING_PI, 0);
global_frame_change(c2.xc, c2.yc, theta, -delta_x, -delta_y, &x, &y);
*q2 = new Configuration(x, y, theta + PI, 0);
*q2 = new Configuration(x, y, theta + STEERING_PI, 0);
}
if (!c1.left && c1.forward)
{
Expand All @@ -161,9 +161,9 @@ class CC00_Dubins_State_Space::CC00_Dubins
{
theta = angle + alpha;
global_frame_change(c1.xc, c1.yc, theta, delta_x, -delta_y, &x, &y);
*q1 = new Configuration(x, y, theta + PI, 0);
*q1 = new Configuration(x, y, theta + STEERING_PI, 0);
global_frame_change(c2.xc, c2.yc, theta, -delta_x, delta_y, &x, &y);
*q2 = new Configuration(x, y, theta + PI, 0);
*q2 = new Configuration(x, y, theta + STEERING_PI, 0);
}
}

Expand All @@ -184,9 +184,9 @@ class CC00_Dubins_State_Space::CC00_Dubins
if (c1.left && !c1.forward)
{
global_frame_change(c1.xc, c1.yc, theta, delta_x, delta_y, &x, &y);
*q1 = new Configuration(x, y, theta + PI, 0);
*q1 = new Configuration(x, y, theta + STEERING_PI, 0);
global_frame_change(c2.xc, c2.yc, theta, -delta_x, delta_y, &x, &y);
*q2 = new Configuration(x, y, theta + PI, 0);
*q2 = new Configuration(x, y, theta + STEERING_PI, 0);
}
if (!c1.left && c1.forward)
{
Expand All @@ -198,9 +198,9 @@ class CC00_Dubins_State_Space::CC00_Dubins
if (!c1.left && !c1.forward)
{
global_frame_change(c1.xc, c1.yc, theta, delta_x, -delta_y, &x, &y);
*q1 = new Configuration(x, y, theta + PI, 0);
*q1 = new Configuration(x, y, theta + STEERING_PI, 0);
global_frame_change(c2.xc, c2.yc, theta, -delta_x, -delta_y, &x, &y);
*q2 = new Configuration(x, y, theta + PI, 0);
*q2 = new Configuration(x, y, theta + STEERING_PI, 0);
}
}

Expand Down
Loading