38#include <ompl/base/spaces/SE2StateSpace.h>
40#include "../../base/PlannerSettings.h"
45namespace ob = ompl::base;
136 space_ = std::make_shared<ompl::base::SE2StateSpace>();
137 result_ = (
double *)malloc(
sizeof(
double) * 5);
138 intRes_ = (
double *)malloc(
sizeof(
double) * 5);
139 ind_ = (
int *)malloc(
sizeof(
int) * 1);
193 "POSQ settings: Kalpha %f, Kbeta %f, Krho %f, RhoEndCondition %f, Kv %f, Vmax "
200 this->intRes_[0] = r[0];
201 this->intRes_[1] = r[1];
202 this->intRes_[2] = r[2];
203 this->intRes_[3] = r[3];
204 this->intRes_[4] = r[4];
216 while (ap >= (minap + M_PI * 2)) {
239 double y_end,
double t_end,
double ct,
double b,
240 int dir,
int &eot)
const {
248 static double oldBeta;
266 std::cerr <<
"K_alpha + K_phi - K_rho K_v = "
269 std::cerr <<
"K_alpha + 2 K_phi - 2/pi K_rho K_v = "
272 if (ct == 0) oldBeta = 0;
274 double dx, dy, rho, fRho, alpha, phi, beta, v, w, vl, vr;
280 rho = sqrt(dx * dx + dy * dy);
286 alpha = atan2(dy, dx) - t_c;
291 if (alpha > (M_PI / 2)) {
293 alpha = alpha - M_PI;
294 }
else if (alpha <= -M_PI / 2) {
296 alpha = alpha + M_PI;
298 }
else if (dir == -1) {
300 alpha = alpha + M_PI;
303 alpha = alpha - 2 * M_PI;
312 if ((abs(oldBeta - beta) > M_PI)) beta = oldBeta;
317 v =
Krho * tanh(
Kv * fRho);
326 if (abs(vl) >
Vmax) {
334 if (abs(vr) >
Vmax) {
358 double sl, sr, oldSl, oldSr, t, dSl, dSr, dSm, dSd, vl, vr, enc_l, enc_r,
374 double x_fin, y_fin, th_fin;
376 x = from->as<ob::SE2StateSpace::StateType>()->getX();
377 y = from->as<ob::SE2StateSpace::StateType>()->getY();
378 th = from->as<ob::SE2StateSpace::StateType>()->getYaw();
380 x_fin = to->as<ob::SE2StateSpace::StateType>()->getX();
381 y_fin = to->as<ob::SE2StateSpace::StateType>()->getY();
382 th_fin = to->as<ob::SE2StateSpace::StateType>()->getYaw();
388 std::vector<UnicycleControl> controls;
389 std::vector<UnicycleState> states;
399 dSm = (dSl + dSr) / 2;
400 dSd = (dSr - dSl) /
B;
401 x = x + dSm * cos(th + dSd / 2);
402 y = y + dSm * sin(th + dSd / 2);
420 enc_l = enc_l +
DT * vl;
421 enc_r = enc_r +
DT * vr;
430 double xf, yf, yawf, vf, wf;
436 dSm = (dSl + dSr) / 2;
437 dSd = (dSr - dSl) /
B;
438 double dx = dSm * cos(th + dSd / 2);
439 double dy = dSm * sin(th + dSd / 2);
443 distance += sqrt(dx * dx + dy * dy);
457 controls.push_back(c);
474 std::vector<UnicycleState> states,
const double t) {
476 int n_states = states.size();
477 int index_state_at_t_time = int(
double(n_states) * t);
478 return states[index_state_at_t_time];
ob::SE2StateSpace::StateType State
Definition: Primitives.h:12
POSQ class that implements the POSQ steering function.
Definition: POSQ.hpp:109
void setRes(const double *r) const
Set the current result of the integration.
Definition: POSQ.hpp:199
double RhoEndCondition
Definition: POSQ.hpp:131
double Kv
Definition: POSQ.hpp:131
UnicycleState interpolate(const ompl::base::State *from, std::vector< UnicycleState > states, const double t)
Return state at time t.
Definition: POSQ.hpp:473
double B
length of the wheels axis
Definition: POSQ.hpp:112
POSQ()
Definition: POSQ.hpp:135
ompl::base::StateSpacePtr space_
Definition: POSQ.hpp:133
std::vector< UnicycleState > steer(const ob::State *from, const ob::State *to, double &distance) const
Propagate the model of the system forward, starting at a given state, with a given control,...
Definition: POSQ.hpp:356
double * intRes_
Definition: POSQ.hpp:126
double Kalpha
Definition: POSQ.hpp:131
const int MAX_SIZE
Max Size of the Control (HacK: in this case equal to the dimension)
Definition: POSQ.hpp:119
double * result_
Internal Results of the integration.
Definition: POSQ.hpp:125
double DT
Integration Time Step
Definition: POSQ.hpp:115
const double END_CONTROLS
Value used to mark the end of the vector, no used at the moment.
Definition: POSQ.hpp:122
double Vmax
Definition: POSQ.hpp:131
double distance(const ompl::base::State *state1, const ompl::base::State *state2)
Compute the distance between two states.
Definition: POSQ.hpp:465
double Krho
Definition: POSQ.hpp:131
double * posControlStep(double x_c, double y_c, double t_c, double x_end, double y_end, double t_end, double ct, double b, int dir, int &eot) const
Single step of the Steer Function.
Definition: POSQ.hpp:238
double Kbeta
Definition: POSQ.hpp:131
int * ind_
Internal Counter to access the current control to propagate.
Definition: POSQ.hpp:129
double normAngle(double a, double mina) const
Normalize the angle a rispect to the minimum angle mina.
Definition: POSQ.hpp:211
double std(const std::vector< double > &values)
Definition: PathStatistics.hpp:85
Property< double > v
Definition: PlannerSettings.h:516
Property< double > rho
Definition: PlannerSettings.h:514
Property< double > dt
Integration time step.
Definition: PlannerSettings.h:527
Property< double > v_max
Definition: PlannerSettings.h:517
Property< double > axis_length
Length of the wheel axis.
Definition: PlannerSettings.h:522
Property< double > phi
Definition: PlannerSettings.h:513
Property< double > alpha
Definition: PlannerSettings.h:512
Property< double > rho_end_condition
Definition: PlannerSettings.h:515
PlannerSettings::GlobalSettings::SteerSettings::PosqSettings posq
PlannerSettings::GlobalSettings::SteerSettings steer
Internal definition of the Unicycle control type.
Definition: POSQ.hpp:85
UnicycleControl(double vv=0, double ww=0)
Definition: POSQ.hpp:91
UnicycleControl(const UnicycleControl ©)
Definition: POSQ.hpp:100
virtual ~UnicycleControl()=default
UnicycleControl(const double *p)
Definition: POSQ.hpp:93
double v_
Definition: POSQ.hpp:87
UnicycleControl & operator=(UnicycleControl const ©)=default
double w_
Definition: POSQ.hpp:89
Definition of the namespaces.
Definition: POSQ.hpp:48
UnicycleState & operator=(UnicycleState const ©)
Definition: POSQ.hpp:68
double yaw_
Definition: POSQ.hpp:52
~UnicycleState(void)
Definition: POSQ.hpp:81
UnicycleState(double xx, double yy, double zz)
Definition: POSQ.hpp:60
UnicycleState()
Definition: POSQ.hpp:54
UnicycleState(double *p)
Definition: POSQ.hpp:62
double y_
Definition: POSQ.hpp:51
double x_
Definition: POSQ.hpp:50
UnicycleState(const UnicycleState ©)
Definition: POSQ.hpp:75
static PlannerSettings::GlobalSettings settings
Definition: PlannerSettings.h:699