Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpTime Namespace Reference

Functions

VISP_EXPORT std::string getDateTime (const std::string &format="%Y/%m/%d %H:%M:%S")
 
VISP_EXPORT double getMinTimeForUsleepCall ()
 
VISP_EXPORT double measureTimeSecond ()
 
VISP_EXPORT double measureTimeMs ()
 
VISP_EXPORT double measureTimeMicros ()
 
VISP_EXPORT void sleepMs (double t)
 
VISP_EXPORT int wait (double t0, double t)
 
VISP_EXPORT void wait (double t)
 

Detailed Description

Time management and measurement.

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

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

Function Documentation

VISP_EXPORT std::string vpTime::getDateTime ( const std::string &  format)

Return a string containing date and time.

Parameters
[in]format: The string format supported by strftime() function that represents the time. The default format is the following "%Y/%m/%d %H:%M:%S". This string contains any combination of special format specifiers given in the next table:
specifier Replaced by Example
%a Abbreviated weekday name * Thu
%A Full weekday name * Thursday
%b Abbreviated month name * Aug
%B Full month name * August
%c Date and time representation * Thu Aug 23 14:55:02 2001
%C Year divided by 100 and truncated to integer (00-99) 20
%d Day of the month, zero-padded (01-31) 23
%D Short MM/DD/YY date, equivalent to m/d/y 08/23/01
%e Day of the month, space-padded ( 1-31) 23
%F Short YYYY-MM-DD date, equivalent to Y-m-d 2001-08-23
%g Week-based year, last two digits (00-99) 01
%G Week-based year 2001
%h Abbreviated month name * (same as b) Aug
%H Hour in 24h format (00-23) 14
%I Hour in 12h format (01-12) 02
%j Day of the year (001-366) 235
%m Month as a decimal number (01-12) 08
%M Minute (00-59) 55
%n New-line character ('\n')
%p AM or PM designation PM
%r 12-hour clock time * 02:55:02 pm
%R 24-hour HH:MM time, equivalent to H:M 14:55
%S Second (00-61) 02
%t Horizontal-tab character ('\t')
%T ISO 8601 time format (HH:MM:SS), equivalent to H:M:S 14:55:02
%u ISO 8601 weekday as number with Monday as 1 (1-7) 4
%U Week number with the first Sunday as the first day of week one (00-53) 33
%V ISO 8601 week number (00-53) 34
%w Weekday as a decimal number with Sunday as 0 (0-6) 4
%W Week number with the first Monday as the first day of week one (00-53) 34
%x Date representation * 08/23/01
%X Time representation * 14:55:02
%y Year, last two digits (00-99) 01
%Y Year 2001
%z ISO 8601 offset from UTC in timezone (1 minute=1, 1 hour=100)
If timezone cannot be determined, no characters
+100
%Z Timezone name or abbreviation *
If timezone cannot be determined, no characters
CDT
%% A % sign %
The specifiers marked with an asterisk (*) are locale-dependent.
Returns
A formated date and time string. When default format is used, the returned string contains "YYYY/MM/DD hh:mm:ss".

The following example shows how to use this function:

#include <visp3/core/vpTime.h>
int main()
{
std::cout << "%Y/%m/%d %H:%M:%S (default): " << vpTime::getDateTime() << std::endl;
std::cout << "%Y-%m-%d_%H.%M.%S format : " << vpTime::getDateTime("%Y-%m-%d_%H.%M.%S") << std::endl;
std::cout << "%F format : " << vpTime::getDateTime("%F") << std::endl;
std::cout << "%X format : " << vpTime::getDateTime("%X") << std::endl;
return 0;
}

It produces the following output:

%Y/%m/%d %H:%M:%S (default): 2016/10/05 19:42:44
%Y-%m-%d_%H.%M.%S format : 2016-10-05_19.42.44
%F format : 2016-10-05
%X format : 19:42:44
Examples:
grabV4l2MultiCpp11Thread.cpp.

Definition at line 351 of file vpTime.cpp.

VISP_EXPORT double vpTime::getMinTimeForUsleepCall ( )
Returns
The time during which a while loop is used to handle the time wainting functions. When the time to wait is greater than that value, we use non blocking functions like usleep() instead.

Definition at line 82 of file vpTime.cpp.

Referenced by vpRobotWireFrameSimulator::setSamplingTime(), vpSimulatorAfma6::updateArticularPosition(), and vpSimulatorViper850::updateArticularPosition().

VISP_EXPORT double vpTime::measureTimeMicros ( )

Return the time in microseconds since January 1st 1970.

See Also
measureTimeMs(), measureTimeSecond()

Definition at line 121 of file vpTime.cpp.

References vpException::fatalError.

vpTime::measureTimeMs ( )

Return the time in milliseconds since January 1st 1970.

See Also
measureTimeMicros(), measureTimeSecond()
Examples:
AROgre.cpp, displaySequence.cpp, fernClassifier.cpp, grab1394CMU.cpp, grab1394Two.cpp, grabDirectShow.cpp, grabDirectShowMulti.cpp, grabDisk.cpp, grabRealSense.cpp, grabV4l2.cpp, grabV4l2MultiCpp11Thread.cpp, manServo4PointsDisplay.cpp, manServoMomentsSimple.cpp, manSimu4Dots.cpp, manSimu4Points.cpp, movePioneer.cpp, planarObjectDetector.cpp, servoAfma4Point2DCamVelocityKalman.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, testColVector.cpp, testComedi.cpp, testConversion.cpp, testFeatureSegment.cpp, testForceTorqueAti.cpp, testHistogram.cpp, testImageAddSub.cpp, testImageBinarise.cpp, testImageFilter.cpp, testImageMorphology.cpp, testImageResize.cpp, testKeyPoint-6.cpp, testMatrixInverse.cpp, testMouseEvent.cpp, testPerformanceLUT.cpp, testPoseRansac2.cpp, testRealSense.cpp, testRobotViper650-frames.cpp, testRobotViper850-frames.cpp, testSvd.cpp, testTime.cpp, testUndistortImage.cpp, trackDot.cpp, trackDot2.cpp, trackKltOpencv.cpp, tutorial-face-detector-live.cpp, and tutorial-video-reader.cpp.

Definition at line 93 of file vpTime.cpp.

References vpException::fatalError.

Referenced by vpKeyPoint::computePose(), vpKeyPoint::detect(), vpKeyPoint::extract(), vpKeyPoint::match(), measureTimeSecond(), vpSimulatorAfma6::setPosition(), vpSimulatorAfma6::updateArticularPosition(), vpSimulatorViper850::updateArticularPosition(), vpSimulatorAfma6::vpSimulatorAfma6(), vpSimulatorViper850::vpSimulatorViper850(), and wait().

VISP_EXPORT void vpTime::sleepMs ( double  t)
VISP_EXPORT int vpTime::wait ( double  t0,
double  t 
)

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, mbtEdgeKltTracking.cpp, mbtEdgeMultiTracking.cpp, mbtKltMultiTracking.cpp, moveBiclops.cpp, movePioneer.cpp, ringLight.cpp, servoBiclopsPoint2DArtVelocity.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, testComedi.cpp, testFeatureSegment.cpp, testForceTorqueAti.cpp, testMouseEvent.cpp, testThread.cpp, testTime.cpp, testVirtuoseAfma6.cpp, trackMeNurbs.cpp, tutorial-blob-auto-tracker.cpp, tutorial-face-detector-live-threaded.cpp, tutorial-grabber-opencv-threaded.cpp, tutorial-grabber-v4l2-threaded.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-klt-tracker-live-v4l2.cpp, tutorial-klt-tracker.cpp, tutorial-pioneer-robot.cpp, tutorial-pose-from-points-image.cpp, tutorial-pose-from-qrcode-image.cpp, and tutorial-video-reader.cpp.

Definition at line 157 of file vpTime.cpp.

References vpException::functionNotImplementedError, and measureTimeMs().

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

VISP_EXPORT void vpTime::wait ( double  t)

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 208 of file vpTime.cpp.

References vpException::functionNotImplementedError, and measureTimeMs().