first commit
This commit is contained in:
33
std_msgs/include/std_msgs/Header.h
Normal file
33
std_msgs/include/std_msgs/Header.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef STD_MSGS_HEADER_H
|
||||
#define STD_MSGS_HEADER_H
|
||||
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
|
||||
namespace std_msgs {
|
||||
|
||||
struct Header
|
||||
{
|
||||
uint32_t seq = 0; // số thứ tự message
|
||||
double stamp = 0.0; // thời gian theo giây (Unix time)
|
||||
std::string frame_id;
|
||||
|
||||
Header() = default;
|
||||
|
||||
// Hàm tạo nhanh header với timestamp hiện tại
|
||||
static Header now(const std::string& frame = "")
|
||||
{
|
||||
using namespace std::chrono;
|
||||
double time_now = duration_cast<duration<double>>(system_clock::now().time_since_epoch()).count();
|
||||
Header h;
|
||||
h.seq = 0;
|
||||
h.stamp = time_now;
|
||||
h.frame_id = frame;
|
||||
return h;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace std_msgs
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user