-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRate.h
More file actions
40 lines (32 loc) · 771 Bytes
/
Rate.h
File metadata and controls
40 lines (32 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
#include <chrono>
#include<thread>
#include <iostream>
#include"trans.h"
using namespace std;
namespace ros {
class Rate {
private:
public:
Rate(const double& frequency) {
}
~Rate() {};
void sleep() {
}
//Ó﷨ʾÀý
void example() {
struct timespec req = { 0 };
struct timespec rem = { 0 };
time_t sec = 0;
req.tv_sec = sec;
req.tv_nsec = 8 * 1000000;
chrono::high_resolution_clock::time_point t0, t;
for (int i = 0; i < 100; i++) {
t0 = chrono::high_resolution_clock::now();
std::this_thread::sleep_for(std::chrono::milliseconds((int)((0.008 * m2mm))));
t = chrono::high_resolution_clock::now();
cout << chrono::duration_cast<std::chrono::duration<double>>(t - t0).count() << endl;
}
}
};
};