ViSP  2.8.0
vpTime Class Reference

#include <vpTime.h>

Static Public Member Functions

static double measureTimeSecond ()
 
static double measureTimeMs ()
 
static double measureTimeMicros ()
 
static void sleepMs (double t)
 
static int wait (double t0, double t)
 
static void wait (double t)
 

Static Public Attributes

static double minTimeForUsleepCall = 4
 

Detailed Description

Time management and measurement.

The example below shows how to synchronize a loop to a given framerate.

#include <visp/vpTime.h>
int main()
{
double t;
for ( ; ; ) {
...
vpTime::wait(t, 40); // Loop time is set to 40 ms, ie 25 Hz
}
}

Definition at line 78 of file vpTime.h.

Member Function Documentation

double vpTime::measureTimeMicros ( )
static

Return the time in microseconds.

See also
measureTimeMs(), measureTimeSecond()

Definition at line 112 of file vpTime.cpp.

double vpTime::measureTimeMs ( )
static

This time is in milli-seconds. Threshold to activate usleep() in waiting methods (see wait()). This threshold is needed, because usleep() is not accurate on many machines. Call sleep() functions during the time to wait minus vpTime::minTimeForUsleepCall. The rest of the time to wait is managed by a while loop.

Return the time in milliseconds.

See also
measureTimeMicros(), measureTimeSecond()
Examples:
AROgre.cpp, displaySequence.cpp, fernClassifier.cpp, grab1394CMU.cpp, grab1394Two.cpp, grabDirectShow.cpp, grabDirectShowMulti.cpp, grabDisk.cpp, grabOpenCV.cpp, grabV4l2.cpp, manServo4PointsDisplay.cpp, manServoMomentsSimple.cpp, manSimu4Dots.cpp, manSimu4Points.cpp, movePioneer.cpp, planarObjectDetector.cpp, servoAfma4Point2DCamVelocityKalman.cpp, servoCycab.cpp, servoMomentImage.cpp, servoMomentPolygon.cpp, servoSimu4Points.cpp, servoSimuAfma6FourPoints2DCamVelocity.cpp, servoSimuCylinder.cpp, servoSimuSphere.cpp, servoSimuViper850FourPoints2DCamVelocity.cpp, servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp, servoViper850Point2DCamVelocityKalman.cpp, SickLDMRS-Acq.cpp, SickLDMRS-Process.cpp, simulateCircle2DCamVelocity.cpp, simulateFourPoints2DCartesianCamVelocity.cpp, simulateFourPoints2DPolarCamVelocity.cpp, sonarPioneerReader.cpp, testConversion.cpp, testFeatureSegment.cpp, testMatrixInverse.cpp, testMouseEvent.cpp, testSvd.cpp, testTime.cpp, testUndistortImage.cpp, trackDot.cpp, trackDot2.cpp, trackKltOpencv.cpp, and tutorial-grabber-video.cpp.

Definition at line 86 of file vpTime.cpp.

Referenced by measureTimeSecond(), vpPose::ransac(), vpSimulatorAfma6::setPosition(), vpSimulatorAfma6::updateArticularPosition(), vpSimulatorViper850::updateArticularPosition(), vpSimulatorAfma6::vpSimulatorAfma6(), vpSimulatorViper850::vpSimulatorViper850(), and wait().

double vpTime::measureTimeSecond ( )
static

Return the measured time in seconds.

See also
measureTimeMs()
Examples:
SickLDMRS-Process.cpp.

Definition at line 225 of file vpTime.cpp.

References measureTimeMs().

void vpTime::sleepMs ( double  t)
static

Sleep t miliseconds from now.

Parameters
t: Time to sleep in ms.
Examples:
servoPioneerPoint2DDepth.cpp, and servoPioneerPoint2DDepthWithoutVpServo.cpp.

Definition at line 236 of file vpTime.cpp.

int vpTime::wait ( double  t0,
double  t 
)
static

Wait t miliseconds after t0 (in ms).

The waiting is done by a call to usleep() if the time to wait is greater than vpTime::minTimeForUsleepCall.

Parameters
t0: reference time (in ms)
t: time to wait (in ms)
Returns
0 : The function did wait.
1 : The time was already over, no need to wait.
Examples:
AROgre.cpp, AROgreBasic.cpp, displaySequence.cpp, grab1394Two.cpp, grabDisk.cpp, manServo4PointsDisplay.cpp, manServoMomentsSimple.cpp, manSimu4Dots.cpp, manSimu4Points.cpp, moveBiclops.cpp, movePioneer.cpp, ringLight.cpp, servoBiclopsPoint2DArtVelocity.cpp, servoCycab.cpp, servoMomentImage.cpp, servoMomentPolygon.cpp, servoSimu4Points.cpp, servoSimuAfma6FourPoints2DCamVelocity.cpp, servoSimuCylinder.cpp, servoSimuSphere.cpp, servoSimuViper850FourPoints2DCamVelocity.cpp, servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp, servoViper850Point2DCamVelocityKalman.cpp, simulateCircle2DCamVelocity.cpp, simulateFourPoints2DCartesianCamVelocity.cpp, simulateFourPoints2DPolarCamVelocity.cpp, sonarPioneerReader.cpp, testFeatureSegment.cpp, testMouseEvent.cpp, testTime.cpp, trackMeNurbs.cpp, tutorial-blob-auto-tracker.cpp, tutorial-grabber-video.cpp, tutorial-ibvs-4pts-display.cpp, tutorial-ibvs-4pts-image-tracking.cpp, tutorial-ibvs-4pts-ogre-tracking.cpp, tutorial-ibvs-4pts-ogre.cpp, tutorial-ibvs-4pts-wireframe-camera.cpp, tutorial-ibvs-4pts-wireframe-robot-afma6.cpp, tutorial-ibvs-4pts-wireframe-robot-viper.cpp, tutorial-mb-edge-tracker.cpp, tutorial-mb-hybrid-tracker.cpp, tutorial-mb-klt-tracker.cpp, tutorial-pioneer-robot.cpp, and tutorial-pose-from-points-image.cpp.

Definition at line 149 of file vpTime.cpp.

References measureTimeMs(), and minTimeForUsleepCall.

Referenced by vpRobotViper650::biasForceTorqueSensor(), vpRobotViper850::biasForceTorqueSensor(), vpDisplayGTK::getClick(), vpDisplayGTK::getClickUp(), vpRobotWireFrameSimulator::getInternalView(), vpDisplayGTK::getKeyboardEvent(), vpSimulatorAfma6::init(), vpSimulator::initMainApplication(), vpSimulator::mainLoop(), vpServolens::reset(), vp1394TwoGrabber::resetBus(), vpSimulatorAfma6::setPosition(), vpSimulatorAfma6::updateArticularPosition(), vpSimulatorViper850::updateArticularPosition(), and vpRobotBiclops::vpRobotBiclopsSpeedControlLoop().

void vpTime::wait ( double  t)
static

Wait t miliseconds from now.

The waiting is done by a call to usleep() if the time to wait is greater than vpTime::minTimeForUsleepCall.

Parameters
t: Time to wait in ms.

Definition at line 189 of file vpTime.cpp.

References measureTimeMs(), and minTimeForUsleepCall.

Member Data Documentation

double vpTime::minTimeForUsleepCall = 4
static