32 double interp(
double t,
double ta,
double a,
double tb,
double b)
34 return a + (b-a)*(t-ta)/(tb-ta);
64 if(
size()==0)
return 0.0;
65 return buffer_.rbegin()->getTime();
73 if(
buffer_.size()==0)
return false;
74 if(t<
buffer_.begin()->getTime())
return false;
75 if(t>
buffer_.rbegin()->getTime())
77 std::cout<<
"vehiclemotionstatebuffer: retrieving latest with dt="<<(t-
buffer_.rbegin()->getTime())<<std::endl;
89 if(
buffer_.size()==0)
return false;
101 double ta = a->getTime();
102 double tb = b->getTime();
116 result.
setX(
interp(t,ta,a->getX(),tb,b->getX()));
117 result.
setY(
interp(t,ta,a->getY(),tb,b->getY()));
118 result.
setZ(
interp(t,ta,a->getZ(),tb,b->getZ()));
119 const double ca =
std::cos(a->getPSI());
120 const double sa =
std::sin(a->getPSI());
121 const double cb =
std::cos(b->getPSI());
122 const double sb =
std::sin(b->getPSI());
123 const double dpsi =
std::atan2(-sa*cb+ca*sb,ca*cb+sa*sb);
125 result.
setvx(
interp(t,ta,a->getvx(),tb,b->getvx()));
126 result.
setvy(
interp(t,ta,a->getvy(),tb,b->getvy()));
128 result.
setAx(
interp(t,ta,a->getAx(),tb,b->getAx()));
Buffers and interpolates vehicle positions.
Definition: vehiclemotionstatebuffer.h:28
double getTmax()
Definition: vehiclemotionstatebuffer.h:62
std::list< VehicleMotionState9d > buffer_
Definition: vehiclemotionstatebuffer.h:31
adore::fun::AFactory::TMotionStateFeed * feed_
Definition: vehiclemotionstatebuffer.h:30
~VehicleMotionStateBuffer()
Definition: vehiclemotionstatebuffer.h:40
void update()
call update to check for new data
Definition: vehiclemotionstatebuffer.h:44
VehicleMotionStateBuffer(adore::fun::AFactory::TMotionStateFeed *feed, double dt_max=1.0)
Definition: vehiclemotionstatebuffer.h:38
bool interpolate(double t, VehicleMotionState9d &result)
interpolate a value for time t, if t is in buffered time range
Definition: vehiclemotionstatebuffer.h:87
bool interpolate_or_latest(double t, VehicleMotionState9d &result)
get the latest, if
Definition: vehiclemotionstatebuffer.h:71
double size()
Definition: vehiclemotionstatebuffer.h:58
double interp(double t, double ta, double a, double tb, double b)
Definition: vehiclemotionstatebuffer.h:32
double dt_max_
Definition: vehiclemotionstatebuffer.h:36
Definition: com_patterns.h:29
virtual void getNext(T &value)=0
virtual bool hasNext() const =0
interval< T > atan2(interval< T > y, interval< T > x)
Definition: intervalarithmetic.h:234
interval< T > cos(interval< T > x)
Definition: intervalarithmetic.h:225
interval< T > sin(interval< T > x)
Definition: intervalarithmetic.h:204
x
Definition: adore_set_goal.py:30
Definition: areaofeffectconverter.h:20
This struct holds the motion state of the vehicle in 9d.
Definition: vehiclemotionstate9d.h:39
void setZ(double value)
Set the z-coordinate.
Definition: vehiclemotionstate9d.h:127
void setY(double value)
Set the y-coordinate.
Definition: vehiclemotionstate9d.h:121
void setAx(double value)
Set the longitudinal acceleration.
Definition: vehiclemotionstate9d.h:157
void setvx(double value)
set the longitudinal velocity
Definition: vehiclemotionstate9d.h:139
void setOmega(double value)
Set the yaw rate.
Definition: vehiclemotionstate9d.h:151
void setX(double value)
Set the x-coordinate.
Definition: vehiclemotionstate9d.h:115
void setPSI(double value)
set the heading
Definition: vehiclemotionstate9d.h:133
void setvy(double value)
set the lateral velocity
Definition: vehiclemotionstate9d.h:145
void setDelta(double value)
Set the steering angle.
Definition: vehiclemotionstate9d.h:163
void setTime(double value)
Set the time.
Definition: vehiclemotionstate9d.h:109