当前位置:网站首页>ros(26):ros::Time::now(),ros::Duration,toSec(),toNSec(); Calculate program execution time
ros(26):ros::Time::now(),ros::Duration,toSec(),toNSec(); Calculate program execution time
2022-07-19 12:21:00 【biter0088】
1. ros Time format description
Time has moments and durations , The duration can be negative , The format is as follows , Divided into seconds and nanoseconds , Conversion relation :1nsec=1e-9sec.
int32 sec
int32 nsec2. ros::Time::now()
Retrieve the current time , It's time .
If in use ROS Clock time , According to ROS Clock return time . Otherwise, return to the current wall clock time , The wall clock is understood as being in a room / The clock hanging in the environment , No one cares about him / Change it , I understand wall clock time as system time .
3. ros::Duration
Represents a period of time , It could be negative
4. toSec()
I am here ros namespace There was no , Should be c++ Function of , It means that “1 ros Time format description ” The format shown in is converted to seconds

5. toNSec()
Convert time or timestamp to nanoseconds
6. Examples of use
Calculate program execution time
#include <iostream>
#include "ros/ros.h"
double begin_time = ros::Time::now().toSec();
double end_time = ros::Time::now().toSec();
std::cout << " One search takes time :" << (end_time - begin_time) << std::endl;Reference link :
ros::Duration rostime: ros::Duration Class Reference
ros::Time rostime: ros::Time Class Reference
ros And c++ Introductory tutorial -- Time ROS And C++ Introductory tutorial -Time( Time ) - Maker is intelligent
边栏推荐
- C # from introduction to mastery Part 1: C # overview and introduction
- Softmax和Cross-entropy是什么关系?
- Microcomputer principle and technology Interface Experiment four subroutines and interrupt experiment
- Test whether the time-consuming of vector, list and set calling empty and size is constant
- Application of semi supervised learning in malware traffic detection
- psd.js 解析PSD文件
- Solution: code error: error reported by error could not resolve
- QT implementation traverses folders
- 解决:code ERESOLVE:ERESOLVE could not resolve 的报错问题
- 机器学习作业1
猜你喜欢
随机推荐
Mysql学习笔记-分页-表的创建-数据类型
Configuring OSPF experiment in mGRE environment
Mysql-1366 - Incorrect string value: ‘\xE5\xBC\xA0\xE4\xB8\x89‘ for column ‘userName‘ at row 1
李宏毅《机器学习》|1. Introduction of this course(机器学习介绍)
对Rapidly-exploring Random Trees(RRT)路径规划方法的理解
Chinese garbled code problem in reading binary files
String correlation function (II)
Es install IK word breaker
阿趣的思考
解决:code ERESOLVE:ERESOLVE could not resolve 的报错问题
Energy saving resource allocation strategy based on time-varying graph in satellite networks
C语言绘图示例-分色调图20例
如何运行.sh脚本文件
STL string input / output overload 1
HarmonyoS快速入门:Hello world
MAPGIS igserver Kyushu - expand service development under the control of localization environment
HCIP(6)
hcip第四天笔记
C# . Net Yunnan rural credit national secret signature (SM2) brief analysis
C语言绘画示例-进度条









