AURobotServers
4
|
#include <uposehist.h>
Public Member Functions | |
bool | addIfNeeded (UPoseTime pose, double velocity) |
void | addPoseHist (UPoseTime poseAtTime) |
void | addPoseHist (UPose pose, UTime atTime) |
void | clear () |
double | getHistHeading (double closeBy, double farAway, const UPoseTime *ref, double *histAge) |
double | getMinDist () |
double | getMinTheta () |
double | getMinTime () |
UPoseTime | getNewest (double *velocity) |
UPoseTime | getOldest () |
UTime | getOldestTime () |
UPoseTime | getPose (int index) |
UPose | getPoseAtTime (UTime) |
double | getPoseFitAtDistance (double closeBy, double farAway, const UPose *ref, UPoseTime *closeFitPose) |
bool | getPoseNearDistance (const double away, const UPose *ref, UPoseTime *closer, UPoseTime *moreDistant) |
bool | getPoseNearTime (UTime atTime, UPoseTime *justBefore, UPoseTime *justAfter) |
int | getPosesCnt () |
char * | getReplayFileName (char *fn, const int fnCnt) |
int | getReplayLogLine () |
const char * | getReplaySubdir () |
UTime | getReplayTimeNext () |
UTime | getReplayTimeNow () |
UTime | getTimeAtDistance (double away) |
bool | isReplay () |
bool | isReplayFileOpen () |
virtual const char * | print (const char *preString, char *buff, int buffCnt) |
bool | replayStep (int steps) |
bool | replayTime (UTime untilTime) |
void | saveToLog (FILE *logf) |
void | setMinDist (double value) |
void | setMinTheta (double value) |
void | setMinTime (double value) |
bool | setReplay (bool value) |
void | setReplaySubdir (const char *subdir) |
UPoseHistNotUsed () | |
~UPoseHistNotUsed () | |
Public Member Functions inherited from UResBase | |
void | createReplayVar (UVarPool *pool) |
virtual void | createResources () |
UCmdExe * | getCorePointer () |
char * | getLogFileName (char *fn, const int fnCnt) |
int | getResFuncIdx () |
const char * | getResID () |
int | getResVersion () |
virtual bool | gotAllResources (char *, int) |
bool | isA (const char *idStr) |
bool | isAlsoA (const char *id) |
virtual void | print (const char *preString) |
virtual void | saveSettings () |
void | setCorePointer (UCmdExe *serverCore) |
void | setResFuncIdx (int idx) |
virtual void | setResID (const char *id, const int version) |
virtual bool | setResource (UResBase *, bool) |
virtual void | stop (bool) |
virtual void | updateReplayStatus () |
UResBase () | |
virtual | ~UResBase () |
Public Member Functions inherited from UReplay | |
void | addChild (UReplay *child) |
virtual bool | decodeReplayLine (char *) |
char * | getLogFileName (char *fn, const int fnCnt) |
char * | getReplayFileName (char *fn, const int fnCnt) |
int | getReplayLogLine () |
bool | isReplay () |
bool | isReplayFileOpen () |
void | removeChild (UReplay *child) |
virtual void | replayAdvanceTime (UTime untilTime) |
void | replaySetBaseFileName (const char *name, const char *preName="") |
void | replaySetFileName (const char *name) |
int | replayStep (int steps) |
virtual bool | replayToTime (UTime untilTime) |
void | setParent (UReplay *parent) |
bool | setReplay (bool value) |
UReplay () | |
virtual | ~UReplay () |
Public Member Functions inherited from ULock | |
bool | lock () |
void | lockInit () |
void | post () |
bool | tryLock () |
bool | tryWait () |
ULock () | |
void | unlock () |
bool | wait () |
~ULock () | |
Static Public Member Functions | |
static const char * | getResID () |
static int | getResVersion () |
Protected Member Functions | |
bool | replayStep () |
Protected Member Functions inherited from UResBase | |
UResBase * | getStaticResource (const char *resName, bool mayCreate, bool staticOnly=true) |
get a pointer to a static resource. More... | |
Private Attributes | |
double | minDistChange |
double | minHeadingChange |
double | minTimeChange |
int | newest |
UPoseTime | poseNew |
UPoseTime | poses [MAX_HIST_POSES] |
int | posesCnt |
bool | replay |
FILE * | replayFile |
char | replayLine [MAX_LOG_LINE_LENGTH] |
int | replayLogLine |
char | replaySubPath [MAX_SUBPATH_LENGTH] |
UTime | replayTimeNext |
UTime | replayTimeNow |
double | speed |
Static Private Attributes | |
static const int | MAX_LOG_LINE_LENGTH = 200 |
static const int | MAX_SUBPATH_LENGTH = 100 |
Additional Inherited Members | |
Public Attributes inherited from UReplay | |
bool | replayTimeAdvancePending |
UTime | replayTimeNow |
Protected Attributes inherited from UResBase | |
int | resFuncIdx |
char | resID [MAX_RESOURCE_ID_LENGTH] |
char | resIsAlso [MAX_RESOURCE_ISALSO_LENGTH] |
int | resVersion |
Protected Attributes inherited from UReplay | |
bool | replay |
FILE * | replayFile |
char | replayFileName [REPLAY_FILE_NAME_LENGTH] |
replay filename More... | |
char | replayLine [MAX_LOG_LINE_LENGTH] |
int | replayLogLine |
UReplay * | replayParent |
UTime | replayTimeNext |
Static Protected Attributes inherited from UReplay | |
static const int | MAX_LOG_LINE_LENGTH = 10000 |
static const int | REPLAY_FILE_NAME_LENGTH = 264 |
max length of replay filename More... | |
Class to hold some 50 meter of pose history for drive calculations
UPoseHistNotUsed::UPoseHistNotUsed | ( | ) |
Constructor
References getResID(), getResVersion(), MAX_SUBPATH_LENGTH, minDistChange, minHeadingChange, minTimeChange, newest, posesCnt, replay, replayFile, replayLine, replayLogLine, replaySubPath, UResBase::resVersion, and UResBase::setResID().
UPoseHistNotUsed::~UPoseHistNotUsed | ( | ) |
Constructor
bool UPoseHistNotUsed::addIfNeeded | ( | UPoseTime | pose, |
double | velocity | ||
) |
Add this pose to the pose history - if needed, i.e. distance or heading change is above a limit. Returns true if position is added to history poses.
References absf(), addPoseHist(), UPose::getDistance(), UPose::getHeadingDiff(), getPose(), UTime::getSec(), minDistChange, minHeadingChange, minTimeChange, poseNew, posesCnt, speed, and UPoseTime::t.
Referenced by getResVersion(), and replayStep().
void UPoseHistNotUsed::addPoseHist | ( | UPoseTime | poseAtTime | ) |
Add a history pose (in cronological order)
References ULock::lock(), MAX_HIST_POSES, newest, poseNew, poses, posesCnt, and ULock::unlock().
Referenced by addIfNeeded(), addPoseHist(), and getResVersion().
Add a history pose (in cronological order)
References addPoseHist().
void UPoseHistNotUsed::clear | ( | void | ) |
Clear current pose history
References newest, and posesCnt.
Referenced by getResVersion(), and setReplay().
double UPoseHistNotUsed::getHistHeading | ( | double | closeBy, |
double | farAway, | ||
const UPoseTime * | ref, | ||
double * | histAge | ||
) |
Get heading over a distance in pose history from 'closeBy' to 'farAway' (in meters) relative to the 'ref' pose. Returns the general heading over this distance (in radians). If 'histAge' != NULL, then the age of the last
References UPose::h, ULock::lock(), newest, poses, posesCnt, UPoseTime::t, ULock::unlock(), UPose::x, and UPose::y.
Referenced by getPosesCnt().
|
inline |
Get minimum distance required to store a pose history pose
References minDistChange.
|
inline |
Get minimum distance required to store a pose history pose
References minHeadingChange.
|
inline |
Get minimum distance required to store a pose history pose
References minTimeChange.
|
inline |
Get newest stored position. If storage is empty time is zero.
References getOldestTime(), getPoseNearTime(), poseNew, and speed.
UPoseTime UPoseHistNotUsed::getOldest | ( | ) |
Get time of oldest data
References ULock::lock(), MAX_HIST_POSES, newest, poses, posesCnt, and ULock::unlock().
Referenced by getOldestTime(), and getResVersion().
UTime UPoseHistNotUsed::getOldestTime | ( | ) |
Get Oldest supportet time
References getOldest(), UTime::Now(), posesCnt, and UPoseTime::t.
Referenced by getNewest().
UPoseTime UPoseHistNotUsed::getPose | ( | int | index | ) |
Get a history pose by index from the newest and back - NB! unsafe (if not locked), as element at index may have changed - no lock using this function. (Relative safe for all the newer poses, but especially the older ones may be overwritten.)
References MAX_HIST_POSES, newest, and poses.
Referenced by addIfNeeded(), getPosesCnt(), and saveToLog().
Get the nearest pose at this time
References UPoseTime::getPose(), UPoseTime::getPoseAtTime(), getPoseNearTime(), and UPoseTime::t.
Referenced by getResVersion().
double UPoseHistNotUsed::getPoseFitAtDistance | ( | double | closeBy, |
double | farAway, | ||
const UPose * | ref, | ||
UPoseTime * | closeFitPose | ||
) |
Get Bet fit line from this distance interval. Return the fit variance, but negative (-1.0) if no result. Returns the close position, adjusted to the fittet line.
References U2Dline::fit(), U2Dline::getOnLine(), ULock::lock(), newest, poses, posesCnt, UPose::set(), ULock::unlock(), UPose::x, and UPose::y.
Referenced by getPosesCnt().
bool UPoseHistNotUsed::getPoseNearDistance | ( | const double | away, |
const UPose * | ref, | ||
UPoseTime * | closer, | ||
UPoseTime * | moreDistant | ||
) |
Get the two nearest poses this distance away from the reference position 'ref'.
References ULock::lock(), newest, poses, posesCnt, ULock::unlock(), UPose::x, and UPose::y.
Referenced by getPosesCnt(), and getTimeAtDistance().
bool UPoseHistNotUsed::getPoseNearTime | ( | UTime | atTime, |
UPoseTime * | justBefore, | ||
UPoseTime * | justAfter | ||
) |
Get the two nearst poses to time
References UTime::getMicrosec(), UTime::getSec(), ULock::lock(), newest, poseNew, poses, posesCnt, UPoseTime::t, and ULock::unlock().
Referenced by getNewest(), and getPoseAtTime().
|
inline |
Get number of poses in pose history
References getHistHeading(), getPose(), getPoseFitAtDistance(), getPoseNearDistance(), getTimeAtDistance(), posesCnt, print(), and saveToLog().
char * UPoseHistNotUsed::getReplayFileName | ( | char * | fn, |
const int | fnCnt | ||
) |
Get the full replay logfile name. Returns pointer fn[] string.
References imagePath, and replaySubPath.
Referenced by getReplayLogLine(), and setReplay().
|
inline |
Get current line number in replay logfile
References getReplayFileName(), replayLogLine, replayStep(), and replayTime().
|
inline |
Get pointer to replay subdir
References replaySubPath.
|
inline |
Get replat time next
References replayTimeNext.
|
inline |
Get replat time now
References replayTimeNow.
|
inlinestatic |
Fixed name of this resource type
Referenced by UPoseHistNotUsed().
|
inlinestatic |
Fixed varsion number for this resource type. Should follow release version, i.e. version 1.28 gives number 128. Should be incremented only when there is change to this class definition, i.e new or changed functions or variables.
References addIfNeeded(), addPoseHist(), clear(), getOldest(), and getPoseAtTime().
Referenced by UPoseHistNotUsed().
UTime UPoseHistNotUsed::getTimeAtDistance | ( | double | away | ) |
Get time, when robot were (at least) this distance from newest position. If a pose at this distance is not in buffer, then the returned tme is zero.
References getPoseNearDistance(), ULock::lock(), newest, poses, posesCnt, UTime::setTime(), UPoseTime::t, and ULock::unlock().
Referenced by getPosesCnt().
|
inline |
Get replay flag
References replay.
|
inline |
is replay file open
References replayFile.
|
virtual |
Print the (short) status of resource - to a string buffer
Reimplemented from UResBase.
References posesCnt.
Referenced by getPosesCnt().
bool UPoseHistNotUsed::replayStep | ( | int | steps | ) |
Replay N singles from the logfile. Returns true if N steps available.
References replayStep().
|
protectedvirtual |
Replay a single step from the logfile. Returns true if EOF not found.
Reimplemented from UReplay.
References addIfNeeded(), UPose::h, MAX_LOG_LINE_LENGTH, replay, replayFile, replayLine, replayLogLine, replayTimeNext, replayTimeNow, UTime::setTimeTod(), UPoseTime::t, UTime::valid, UPose::x, and UPose::y.
Referenced by getReplayLogLine(), replayStep(), and replayTime().
bool UPoseHistNotUsed::replayTime | ( | UTime | untilTime | ) |
Replay until just before this time
References replayStep(), and replayTimeNext.
Referenced by getReplayLogLine().
void UPoseHistNotUsed::saveToLog | ( | FILE * | logf | ) |
Save pose history to logfile
References UTime::getMicrosec(), getPose(), UTime::getSec(), UPose::h, poseNew, posesCnt, UPoseTime::t, UPose::x, and UPose::y.
Referenced by getPosesCnt().
|
inline |
Set minimum distance required to store a pose history pose
References minDistChange.
|
inline |
Set minimum distance required to store a pose history pose
References minHeadingChange.
|
inline |
Set minimum distance required to store a pose history pose
References minTimeChange, setReplay(), and setReplaySubdir().
bool UPoseHistNotUsed::setReplay | ( | bool | value | ) |
Set replay flag. If replay flag is changed to true, the logfile (odo.log) is attempted opened. If successfull, the current pose history is cleared and the first record read and implemented. If not successfull, the replay flag is set to true, and the pose history is cleared only. Returns true if replay file is opened
References clear(), getReplayFileName(), MAX_LOG_LINE_LENGTH, replay, replayFile, replayLine, replayLogLine, replayTimeNext, UTime::setTimeTod(), and UTime::valid.
Referenced by setMinTime().
void UPoseHistNotUsed::setReplaySubdir | ( | const char * | subdir | ) |
Set replay subdir. Sets the value to the subdir buffer, but nothing else is changed.
References MAX_PATH_LENGTH, and replaySubPath.
Referenced by setMinTime().
|
staticprivate |
Maximum length of a line in the logfile
Referenced by replayStep(), and setReplay().
|
staticprivate |
length of subpath
Referenced by UPoseHistNotUsed().
|
private |
Distance change before qualified to be saved
Referenced by addIfNeeded(), getMinDist(), setMinDist(), and UPoseHistNotUsed().
|
private |
Heading change before qualified to be saved
Referenced by addIfNeeded(), getMinTheta(), setMinTheta(), and UPoseHistNotUsed().
|
private |
Time change before qualified to be saved
Referenced by addIfNeeded(), getMinTime(), setMinTime(), and UPoseHistNotUsed().
|
private |
number of newest pose
Referenced by addPoseHist(), clear(), getHistHeading(), getOldest(), getPose(), getPoseFitAtDistance(), getPoseNearDistance(), getPoseNearTime(), getTimeAtDistance(), and UPoseHistNotUsed().
|
private |
Newest pose
Referenced by addIfNeeded(), addPoseHist(), getNewest(), getPoseNearTime(), and saveToLog().
|
private |
Cyclic buffer of history poses
Referenced by addPoseHist(), getHistHeading(), getOldest(), getPose(), getPoseFitAtDistance(), getPoseNearDistance(), getPoseNearTime(), and getTimeAtDistance().
|
private |
Used poses entries
Referenced by addIfNeeded(), addPoseHist(), clear(), getHistHeading(), getOldest(), getOldestTime(), getPoseFitAtDistance(), getPoseNearDistance(), getPoseNearTime(), getPosesCnt(), getTimeAtDistance(), print(), saveToLog(), and UPoseHistNotUsed().
|
private |
Replay flag - source of info for pose history a change in this flag clears the current pose history.
Referenced by isReplay(), replayStep(), setReplay(), and UPoseHistNotUsed().
|
private |
Replay file handle
Referenced by isReplayFileOpen(), replayStep(), setReplay(), and UPoseHistNotUsed().
|
private |
Buffer for latest line (but not used) line from logfile
Referenced by replayStep(), setReplay(), and UPoseHistNotUsed().
|
private |
Current line number in logfile
Referenced by getReplayLogLine(), replayStep(), setReplay(), and UPoseHistNotUsed().
|
private |
Replay file subdir - relative to imagePath
Referenced by getReplayFileName(), getReplaySubdir(), setReplaySubdir(), and UPoseHistNotUsed().
|
private |
Replay time of next data from in logfile (line buffer)
Referenced by getReplayTimeNext(), replayStep(), replayTime(), and setReplay().
|
private |
Replay time of last used data from logfile
Referenced by getReplayTimeNow(), and replayStep().
|
private |
Newest speed
Referenced by addIfNeeded(), and getNewest().