them file geometry_msgs
This commit is contained in:
@@ -3,5 +3,11 @@ project(std_msgs)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
if (NOT TARGET robot_time)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/../robot_time ${CMAKE_BINARY_DIR}/robot_time_build)
|
||||
endif()
|
||||
|
||||
add_library(std_msgs INTERFACE)
|
||||
target_include_directories(std_msgs INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
target_include_directories(std_msgs INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/../robot_time/include)
|
||||
target_link_libraries(std_msgs INTERFACE robot_time)
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
#define STD_MSGS_HEADER_H
|
||||
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <robot/time.h>
|
||||
|
||||
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)
|
||||
robot::Time stamp = robot::Time(0); // thời gian theo giây (Unix time)
|
||||
std::string frame_id;
|
||||
|
||||
Header() = default;
|
||||
@@ -18,8 +18,7 @@ struct Header
|
||||
// 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();
|
||||
robot::Time time_now = robot::Time::now();
|
||||
Header h;
|
||||
h.seq = 0;
|
||||
h.stamp = time_now;
|
||||
|
||||
Reference in New Issue
Block a user