[Barrierfunctions]

39 views
Skip to first unread message

graf

unread,
Aug 3, 2017, 11:49:18 AM8/3/17
to 'Sameer Agarwal' via Ceres Solver
Hi Sameer,

its me again. Like i already mentioned i try to optimise a 2D curve
(trajectory planning for an autonomous vehicle). The curve consists of
xy points with temporal spacing

between these points. To calculate the acceleration (which is part of
the trajectory and thus to optimise) i use finite differences:

ddx = (x_i+1 - 2*x_i + 2*x_i-1)/(h^2)

ddy = (y_i+1 - 2*y_i + 2*y_i-1)/(h^2)

acc_i = sqrt(ddx^2 + ddy^2).


For example:


template <typename T>
bool AccelerationCostsFunctor::operator ()(const T* x0,
const T* y0,
const T* x1,
const T* y1,
const T* x2,
const T* y2,
T* value) const
{

T TemporalSpacing = 0.2;
T TemporalSpacingsquared = TemporalSpacing * TemporalSpacing;

T ax = (x0[0] + x2[0] - x1[0] - x1[0]) / (TemporalSpacingsquared);
T ay = (y0[0] + y2[0] - y1[0] - y1[0]) / (TemporalSpacingsquared);

value[0] = ax;
value[1] = ay;


return true;
}


Now i want to put constraints on the acceleration, such as a<= a_max for
all points. I tried implement a class for it

//////////////////////////////////////////////////////////////////////////////////////////////////

//the following class inherited from loss_function class

/////////////////////////////////////////////////////////////////////////////////////////////////

void Barrierfunction::Evaluate(double sq_norm,
double* out) const
{

double sq_Threshold = (*m_PtrThreshold)*(*m_PtrThreshold);
double BoundToOperate = sq_Threshold * 0.8;

if (sq_norm > BoundToOperate)
{

out[0] = (sq_norm - BoundToOperate)*(sq_norm - BoundToOperate)
* (*m_PtrWeight);
out[1] =2* (sq_norm -
BoundToOperate)* (*m_PtrWeight);
out[2] = 2* (*m_PtrWeight);
}
else
{
out[0] = 0.0;
out[1] = 0.0;
out[2] = 0.0;
}

}


but this doesnt work... the optimiser converges, but the bounds are
broken.... what am i doing wrong?

kind regards and thanks for your answer in advance! It would be really
really nice from you if you could help me with that :/!

Sameer Agarwal

unread,
Aug 3, 2017, 11:52:00 AM8/3/17
to 'Sameer Agarwal' via Ceres Solver
don't hack the loss function.
instead in the functor

value[0] = ax;
value[1] = ay;
if (bound is not satisfied) return false;
return true;

--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/398da181-54d0-afa8-ac43-5353d5811840%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages