当前位置:网站首页>ros(26):ros::Time::now(),ros::Duration,toSec(),toNSec();计算程序执行时间
ros(26):ros::Time::now(),ros::Duration,toSec(),toNSec();计算程序执行时间
2022-07-17 16:16:00 【biter0088】
1. ros时间格式说明
时间有时刻和持续时间,其中持续时间可以是负数,格式如下,分为秒和纳秒,换算关系:1nsec=1e-9sec。
int32 sec
int32 nsec2. ros::Time::now()
检索当前时间,是时刻时间。
如果正在使用 ROS 时钟时间,则根据 ROS 时钟返回时间。否则返回当前挂钟时间,挂钟理解为在一个房间/环境里面挂的钟,没有人去管他/改变它,挂钟时间我理解为系统时间。
3. ros::Duration
代表持续的一段时间,可以是负数
4. toSec()
我在ros namespace里面没有找到,应该是c++的函数,意思是将“1 ros时间格式说明”中所示的格式转为秒

5. toNSec()
将时间或时间戳转换为纳秒
6. 使用示例
计算程序执行时间
#include <iostream>
#include "ros/ros.h"
double begin_time = ros::Time::now().toSec();
double end_time = ros::Time::now().toSec();
std::cout << "一次查找耗时:" << (end_time - begin_time) << std::endl;参考链接:
ros::Duration rostime: ros::Duration Class Reference
ros::Time rostime: ros::Time Class Reference
ros与c++入门教程--时间 ROS与C++入门教程-Time(时间) - 创客智造
边栏推荐
- LeetCode_ 77_ combination
- [vulnhub range] prime:1 record of shooting process
- QT learning diary 17 - QT database
- The concept of binary tree and three traversal methods (C language)
- Energy saving resource allocation strategy based on time-varying graph in satellite networks
- Tidb memory control document
- SQL盲注详解
- 人大、微软等提出InclusiveFL:异构设备上的包容性联邦学习
- Leetcode 239. 滑动窗口最大值
- zabbix-snmp监控
猜你喜欢

Leetcode 150. 逆波兰表达式求值

2022-07-07:Spire. Office 7.7.2 for net debuted

李宏毅《机器学习》|1. Introduction of this course(机器学习介绍)

Enabling cities to "plan, build, operate, manage and serve" -- MAPGIS CIM platform explores "cim+" multi scenario applications

QT learning diary 17 - QT database

Nintendo patent shows that the follow-up products of fitness ring accessories may be under development

说说 Redis 缓存穿透场景与相应的解决方法

字符串相关函数(二)

PyTorch版:集成注意力和MobileNet的YOLOv4

01 knapsack interview questions series (I)
随机推荐
Tikv thread pool performance tuning
[wechat applet] use a thousand hand float - rollback
Conversion between Swift binary data and hexadecimal string
C语言绘图示例-调色板
编辑技巧篇
项目建设,谋事在人,成事亦在人!
[original] magisk+shamiko has been tested by app root
C language drawing example - palette
2022.07.13 summer training personal qualifying (VIII)
The adaptation of go language under windows10:vscode
HCIP(5)
阿趣的思考
Research and implementation of 5g network Slicing Based on AI intelligent correlation technology
Test whether the time-consuming of vector, list and set calling empty and size is constant
PPPoE拨号上网
Tiflash performance tuning
Leetcode 150. Evaluation of inverse Polish expression
C语言绘画示例-进度条
MATLAB(4)函数及文件
我最喜欢的10个机器学习公众号