From 05616f8fca7e284c163f95721579c23a847ac1a5 Mon Sep 17 00:00:00 2001 From: duongtd Date: Thu, 6 Nov 2025 17:01:17 +0700 Subject: [PATCH] them file geometry_msgs --- geometry_msgs/include/geometry_msgs/Accel.h | 28 +++++++++++++ .../include/geometry_msgs/AccelStamped.h | 24 +++++++++++ .../geometry_msgs/AccelWithCovariance.h | 31 ++++++++++++++ .../AccelWithCovarianceStamped.h | 24 +++++++++++ geometry_msgs/include/geometry_msgs/Inertia.h | 40 +++++++++++++++++++ .../include/geometry_msgs/InertiaStamped.h | 23 +++++++++++ geometry_msgs/include/geometry_msgs/Pose2D.h | 31 ++++++++++++++ .../include/geometry_msgs/PoseArray.h | 28 +++++++++++++ .../include/geometry_msgs/PoseStamped.h | 25 ++++++++++++ .../geometry_msgs/PoseWithCovariance.h | 31 ++++++++++++++ .../geometry_msgs/PoseWithCovarianceStamped.h | 27 +++++++++++++ .../include/geometry_msgs/QuaternionStamped.h | 25 ++++++++++++ geometry_msgs/include/geometry_msgs/Twist.h | 28 +++++++++++++ .../include/geometry_msgs/TwistStamped.h | 24 +++++++++++ .../geometry_msgs/TwistWithCovariance.h | 31 ++++++++++++++ .../TwistWithCovarianceStamped.h | 26 ++++++++++++ .../include/geometry_msgs/Vector3Stamped.h | 24 +++++++++++ .../include/geometry_msgs/Vector3Stamped.msg | 3 -- geometry_msgs/include/geometry_msgs/Wrench.h | 24 +++++++++++ .../include/geometry_msgs/WrenchStamped.h | 24 +++++++++++ sensor_msgs/include/sensor_msgs/CameraInfo.h | 29 +------------- .../include/sensor_msgs/CompressedImage.h | 2 +- .../include/sensor_msgs/FluidPressure.h | 2 +- sensor_msgs/include/sensor_msgs/Illuminance.h | 2 +- sensor_msgs/include/sensor_msgs/Image.h | 2 +- sensor_msgs/include/sensor_msgs/Imu.h | 2 +- sensor_msgs/include/sensor_msgs/JointState.h | 2 +- sensor_msgs/include/sensor_msgs/Joy.h | 2 +- .../include/sensor_msgs/MultiEchoLaserScan.h | 4 +- sensor_msgs/include/sensor_msgs/Range.h | 2 +- .../include/sensor_msgs/RelativeHumidity.h | 2 +- sensor_msgs/include/sensor_msgs/Temperature.h | 2 +- .../include/sensor_msgs/TimeReference.h | 2 +- sensor_msgs/test/main.cpp | 38 +++++++++--------- std_msgs/CMakeLists.txt | 8 +++- std_msgs/include/std_msgs/Header.h | 7 ++-- 36 files changed, 562 insertions(+), 67 deletions(-) create mode 100644 geometry_msgs/include/geometry_msgs/Accel.h create mode 100644 geometry_msgs/include/geometry_msgs/AccelStamped.h create mode 100644 geometry_msgs/include/geometry_msgs/AccelWithCovariance.h create mode 100644 geometry_msgs/include/geometry_msgs/AccelWithCovarianceStamped.h create mode 100644 geometry_msgs/include/geometry_msgs/Inertia.h create mode 100644 geometry_msgs/include/geometry_msgs/InertiaStamped.h create mode 100644 geometry_msgs/include/geometry_msgs/Pose2D.h create mode 100644 geometry_msgs/include/geometry_msgs/PoseArray.h create mode 100644 geometry_msgs/include/geometry_msgs/PoseStamped.h create mode 100644 geometry_msgs/include/geometry_msgs/PoseWithCovariance.h create mode 100644 geometry_msgs/include/geometry_msgs/PoseWithCovarianceStamped.h create mode 100644 geometry_msgs/include/geometry_msgs/QuaternionStamped.h create mode 100644 geometry_msgs/include/geometry_msgs/Twist.h create mode 100644 geometry_msgs/include/geometry_msgs/TwistStamped.h create mode 100644 geometry_msgs/include/geometry_msgs/TwistWithCovariance.h create mode 100644 geometry_msgs/include/geometry_msgs/TwistWithCovarianceStamped.h create mode 100644 geometry_msgs/include/geometry_msgs/Vector3Stamped.h delete mode 100644 geometry_msgs/include/geometry_msgs/Vector3Stamped.msg create mode 100644 geometry_msgs/include/geometry_msgs/Wrench.h create mode 100644 geometry_msgs/include/geometry_msgs/WrenchStamped.h diff --git a/geometry_msgs/include/geometry_msgs/Accel.h b/geometry_msgs/include/geometry_msgs/Accel.h new file mode 100644 index 0000000..14242ce --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/Accel.h @@ -0,0 +1,28 @@ +// # This expresses acceleration in free space broken into its linear and angular parts. +// Vector3 linear +// Vector3 angular + +#ifndef ACCEL_H +#define ACCEL_H + +#include + +namespace geometry_msgs +{ + +struct Accel +{ + Vector3 linear; + Vector3 angular; + + // Constructor mặc định + Accel() : linear(), angular() {} + + // Constructor khởi tạo nhanh + Accel(const Vector3& linear_, const Vector3& angular_) + : linear(linear_), angular(angular_) {} +}; + +} // namespace geometry_msgs + +#endif // ACCEL_H diff --git a/geometry_msgs/include/geometry_msgs/AccelStamped.h b/geometry_msgs/include/geometry_msgs/AccelStamped.h new file mode 100644 index 0000000..9668177 --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/AccelStamped.h @@ -0,0 +1,24 @@ +// # An accel with reference coordinate frame and timestamp +// Header header +// Accel accel + +#ifndef ACCEL_STAMPED_H +#define ACCEL_STAMPED_H + +#include +#include + +namespace geometry_msgs +{ + +struct AccelStamped +{ + std_msgs::Header header; + Accel accel; + // Constructor mặc định + AccelStamped() = default; +}; + +} // namespace geometry_msgs + +#endif // ACCEL_STAMPED_H diff --git a/geometry_msgs/include/geometry_msgs/AccelWithCovariance.h b/geometry_msgs/include/geometry_msgs/AccelWithCovariance.h new file mode 100644 index 0000000..430a503 --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/AccelWithCovariance.h @@ -0,0 +1,31 @@ +// # This expresses acceleration in free space with uncertainty. + +// Accel accel + +// # Row-major representation of the 6x6 covariance matrix +// # The orientation parameters use a fixed-axis representation. +// # In order, the parameters are: +// # (x, y, z, rotation about X axis, rotation about Y axis, rotation about Z axis) +// float64[36] covariance + +#ifndef ACCEL_WITH_COVARIANCE_H +#define ACCEL_WITH_COVARIANCE_H + +#include +#include + +namespace geometry_msgs +{ + +struct AccelWithCovariance +{ + Accel accel; + std::array covariance; + // Constructor mặc định + AccelWithCovariance() = default; +}; + +} // namespace geometry_msgs + +#endif // ACCEL_WITH_COVARIANCE_H + diff --git a/geometry_msgs/include/geometry_msgs/AccelWithCovarianceStamped.h b/geometry_msgs/include/geometry_msgs/AccelWithCovarianceStamped.h new file mode 100644 index 0000000..f966234 --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/AccelWithCovarianceStamped.h @@ -0,0 +1,24 @@ +// # This represents an estimated accel with reference coordinate frame and timestamp. +// Header header +// AccelWithCovariance accel + +#ifndef ACCEL_WITH_COVARIANCE_STAMPED_H +#define ACCEL_WITH_COVARIANCE_STAMPED_H + +#include +#include + +namespace geometry_msgs +{ + +struct AccelWithCovarianceStamped +{ + std_msgs::Header header; + AccelWithCovariance accel; + // Constructor mặc định + AccelWithCovarianceStamped() = default; +}; + +} // namespace geometry_msgs + +#endif // ACCEL_WITH_COVARIANCE_STAMPED_H diff --git a/geometry_msgs/include/geometry_msgs/Inertia.h b/geometry_msgs/include/geometry_msgs/Inertia.h new file mode 100644 index 0000000..942f595 --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/Inertia.h @@ -0,0 +1,40 @@ +// # Mass [kg] +// float64 m + +// # Center of mass [m] +// geometry_msgs/Vector3 com + +// # Inertia Tensor [kg-m^2] +// # | ixx ixy ixz | +// # I = | ixy iyy iyz | +// # | ixz iyz izz | +// float64 ixx +// float64 ixy +// float64 ixz +// float64 iyy +// float64 iyz +// float64 izz + +#ifndef INERTIA_H +#define INERTIA_H + +#include + +namespace geometry_msgs +{ + +struct Inertia +{ + double m; + Vector3 com; + double ixx; + double ixy; + double ixz; + double iyy; + double iyz; + double izz; +}; + +} // namespace geometry_msgs + +#endif // INERTIA_H diff --git a/geometry_msgs/include/geometry_msgs/InertiaStamped.h b/geometry_msgs/include/geometry_msgs/InertiaStamped.h new file mode 100644 index 0000000..bd92fe0 --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/InertiaStamped.h @@ -0,0 +1,23 @@ +// Header header +// Inertia inertia + +#ifndef INERTIA_STAMPED_H +#define INERTIA_STAMPED_H + +#include +#include + +namespace geometry_msgs +{ + +struct InertiaStamped +{ + std_msgs::Header header; + Inertia inertia; + // Constructor mặc định + InertiaStamped() = default; +}; + +} // namespace geometry_msgs + +#endif // INERTIA_STAMPED_H \ No newline at end of file diff --git a/geometry_msgs/include/geometry_msgs/Pose2D.h b/geometry_msgs/include/geometry_msgs/Pose2D.h new file mode 100644 index 0000000..df79b90 --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/Pose2D.h @@ -0,0 +1,31 @@ +// # Deprecated +// # Please use the full 3D pose. + +// # In general our recommendation is to use a full 3D representation of everything and for 2D specific applications make the appropriate projections into the plane for their calculations but optimally will preserve the 3D information during processing. + +// # If we have parallel copies of 2D datatypes every UI and other pipeline will end up needing to have dual interfaces to plot everything. And you will end up with not being able to use 3D tools for 2D use cases even if they're completely valid, as you'd have to reimplement it with different inputs and outputs. It's not particularly hard to plot the 2D pose or compute the yaw error for the Pose message and there are already tools and libraries that can do this for you. + + +// # This expresses a position and orientation on a 2D manifold. + +// float64 x +// float64 y +// float64 theta + +#ifndef POSE2D_H +#define POSE2D_H + +namespace geometry_msgs +{ + +struct Pose2D +{ + double x; + double y; + double theta; +}; + +} // namespace geometry_msgs + +#endif // POSE2D_H + diff --git a/geometry_msgs/include/geometry_msgs/PoseArray.h b/geometry_msgs/include/geometry_msgs/PoseArray.h new file mode 100644 index 0000000..0058ce8 --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/PoseArray.h @@ -0,0 +1,28 @@ +// # An array of poses with a header for global reference. + +// Header header + +// Pose[] poses +#ifndef POSE_ARRAY_H +#define POSE_ARRAY_H + +#include +#include +#include + + + +namespace geometry_msgs +{ + +struct PoseArray +{ + std_msgs::Header header; + std::vector poses; + + PoseArray() = default; +}; + +} // namespace geometry_msgs + +#endif // POSE_ARRAY_H \ No newline at end of file diff --git a/geometry_msgs/include/geometry_msgs/PoseStamped.h b/geometry_msgs/include/geometry_msgs/PoseStamped.h new file mode 100644 index 0000000..ec781d2 --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/PoseStamped.h @@ -0,0 +1,25 @@ +// # A Pose with reference coordinate frame and timestamp +// Header header +// Pose pose +#ifndef POSE_STAMPED_H +#define POSE_STAMPED_H + +#include +#include + + + +namespace geometry_msgs +{ + +struct PoseStamped +{ + std_msgs::Header header; + Pose pose; + + PoseStamped() = default; +}; + +} // namespace geometry_msgs + +#endif // POSE_STAMPED_H \ No newline at end of file diff --git a/geometry_msgs/include/geometry_msgs/PoseWithCovariance.h b/geometry_msgs/include/geometry_msgs/PoseWithCovariance.h new file mode 100644 index 0000000..4fe3f06 --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/PoseWithCovariance.h @@ -0,0 +1,31 @@ +// # This represents a pose in free space with uncertainty. + +// Pose pose + +// # Row-major representation of the 6x6 covariance matrix +// # The orientation parameters use a fixed-axis representation. +// # In order, the parameters are: +// # (x, y, z, rotation about X axis, rotation about Y axis, rotation about Z axis) +// float64[36] covariance + +#ifndef POSE_WITH_COVARIANCE_H +#define POSE_WITH_COVARIANCE_H + +#include +#include + + +namespace geometry_msgs +{ + +struct PoseWithCovariance +{ + Pose pose; + std::array covariance; + + PoseWithCovariance() = default; +}; + +} // namespace geometry_msgs + +#endif // POSE_WITH_COVARIANCE_H \ No newline at end of file diff --git a/geometry_msgs/include/geometry_msgs/PoseWithCovarianceStamped.h b/geometry_msgs/include/geometry_msgs/PoseWithCovarianceStamped.h new file mode 100644 index 0000000..ee20a14 --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/PoseWithCovarianceStamped.h @@ -0,0 +1,27 @@ +// # This expresses an estimated pose with a reference coordinate frame and timestamp + +// Header header +// PoseWithCovariance pose + +#ifndef POSE_WITH_COVARIANCE_STAMPED_H +#define POSE_WITH_COVARIANCE_STAMPED_H + +#include +#include + + + +namespace geometry_msgs +{ + +struct PoseWithCovarianceStamped +{ + std_msgs::Header header; + PoseWithCovariance pose; + + PoseWithCovarianceStamped() = default; +}; + +} // namespace geometry_msgs + +#endif // POSE_WITH_COVARIANCE_STAMPED_H diff --git a/geometry_msgs/include/geometry_msgs/QuaternionStamped.h b/geometry_msgs/include/geometry_msgs/QuaternionStamped.h new file mode 100644 index 0000000..4f9228f --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/QuaternionStamped.h @@ -0,0 +1,25 @@ +// # This represents an orientation with reference coordinate frame and timestamp. + +// Header header +// Quaternion quaternion + +#ifndef QUATERNION_STAMPED_H +#define QUATERNION_STAMPED_H + +#include +#include + +namespace geometry_msgs +{ + +struct QuaternionStamped +{ + std_msgs::Header header; + Quaternion quaternion; + // Constructor mặc định + QuaternionStamped() = default; +}; + +} // namespace geometry_msgs + +#endif // QUATERNION_STAMPED_H diff --git a/geometry_msgs/include/geometry_msgs/Twist.h b/geometry_msgs/include/geometry_msgs/Twist.h new file mode 100644 index 0000000..358a85e --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/Twist.h @@ -0,0 +1,28 @@ +// # This expresses velocity in free space broken into its linear and angular parts. +// Vector3 linear +// Vector3 angular + +#ifndef TWIST_H +#define TWIST_H + +#include + +namespace geometry_msgs +{ + +struct Twist +{ + Vector3 linear; + Vector3 angular; + + // Constructor mặc định + Twist() : linear(), angular() {} + + // Constructor khởi tạo nhanh + Twist(const Vector3& linear_, const Vector3& angular_) + : linear(linear_), angular(angular_) {} +}; + +} // namespace geometry_msgs + +#endif // ACCEL_H \ No newline at end of file diff --git a/geometry_msgs/include/geometry_msgs/TwistStamped.h b/geometry_msgs/include/geometry_msgs/TwistStamped.h new file mode 100644 index 0000000..94f0019 --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/TwistStamped.h @@ -0,0 +1,24 @@ +// # A twist with reference coordinate frame and timestamp +// Header header +// Twist twist + +#ifndef TWIST_STAMPED_H +#define TWIST_STAMPED_H + +#include +#include + +namespace geometry_msgs +{ + +struct TwistStamped +{ + std_msgs::Header header; + Twist twist; + // Constructor mặc định + TwistStamped() = default; +}; + +} // namespace geometry_msgs + +#endif // TWIST_STAMPED_H diff --git a/geometry_msgs/include/geometry_msgs/TwistWithCovariance.h b/geometry_msgs/include/geometry_msgs/TwistWithCovariance.h new file mode 100644 index 0000000..ea52ac1 --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/TwistWithCovariance.h @@ -0,0 +1,31 @@ +// # This expresses velocity in free space with uncertainty. + +// Twist twist + +// # Row-major representation of the 6x6 covariance matrix +// # The orientation parameters use a fixed-axis representation. +// # In order, the parameters are: +// # (x, y, z, rotation about X axis, rotation about Y axis, rotation about Z axis) +// float64[36] covariance + +#ifndef TWIST_WITH_COVARIANCE_H +#define TWIST_WITH_COVARIANCE_H + +#include +#include + + +namespace geometry_msgs +{ + +struct TwistWithCovariance +{ + Twist twist; + std::array covariance; + + TwistWithCovariance() = default; +}; + +} // namespace geometry_msgs + +#endif // TWIST_WITH_COVARIANCE_H diff --git a/geometry_msgs/include/geometry_msgs/TwistWithCovarianceStamped.h b/geometry_msgs/include/geometry_msgs/TwistWithCovarianceStamped.h new file mode 100644 index 0000000..608fbbb --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/TwistWithCovarianceStamped.h @@ -0,0 +1,26 @@ +// # This represents an estimated twist with reference coordinate frame and timestamp. +// Header header +// TwistWithCovariance twist + +#ifndef TWIST_WITH_COVARIANCE_STAMPED_H +#define TWIST_WITH_COVARIANCE_STAMPED_H + +#include +#include + + + +namespace geometry_msgs +{ + +struct TwistWithCovarianceStamped +{ + std_msgs::Header header; + TwistWithCovariance twist; + + TwistWithCovarianceStamped() = default; +}; + +} // namespace geometry_msgs + +#endif // TWIST_WITH_COVARIANCE_STAMPED_H \ No newline at end of file diff --git a/geometry_msgs/include/geometry_msgs/Vector3Stamped.h b/geometry_msgs/include/geometry_msgs/Vector3Stamped.h new file mode 100644 index 0000000..2a8f819 --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/Vector3Stamped.h @@ -0,0 +1,24 @@ +// # This represents a Vector3 with reference coordinate frame and timestamp +// Header header +// Vector3 vector + +#ifndef VECTOR_3_STAMPED_H +#define VECTOR_3_STAMPED_H + +#include +#include + +namespace geometry_msgs +{ + +struct Vector3Stamped +{ + std_msgs::Header header; + Vector3 vector; + // Constructor mặc định + Vector3Stamped() = default; +}; + +} // namespace geometry_msgs + +#endif // VECTOR_3_STAMPED_H diff --git a/geometry_msgs/include/geometry_msgs/Vector3Stamped.msg b/geometry_msgs/include/geometry_msgs/Vector3Stamped.msg deleted file mode 100644 index e68eb06..0000000 --- a/geometry_msgs/include/geometry_msgs/Vector3Stamped.msg +++ /dev/null @@ -1,3 +0,0 @@ -# This represents a Vector3 with reference coordinate frame and timestamp -Header header -Vector3 vector diff --git a/geometry_msgs/include/geometry_msgs/Wrench.h b/geometry_msgs/include/geometry_msgs/Wrench.h new file mode 100644 index 0000000..62ea6cd --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/Wrench.h @@ -0,0 +1,24 @@ +// # This represents force in free space, separated into +// # its linear and angular parts. +// Vector3 force +// Vector3 torque + +#ifndef WRENCH_H +#define WRENCH_H + +#include + +namespace geometry_msgs +{ + +struct Wrench +{ + Vector3 force; + Vector3 torque; + // Constructor mặc định + Wrench() = default; +}; + +} // namespace geometry_msgs + +#endif // WRENCH_H diff --git a/geometry_msgs/include/geometry_msgs/WrenchStamped.h b/geometry_msgs/include/geometry_msgs/WrenchStamped.h new file mode 100644 index 0000000..bd9eb27 --- /dev/null +++ b/geometry_msgs/include/geometry_msgs/WrenchStamped.h @@ -0,0 +1,24 @@ +// # A wrench with reference coordinate frame and timestamp +// Header header +// Wrench wrench + +#ifndef WRENCH_STAMPED_H +#define WRENCH_STAMPED_H + +#include +#include + +namespace geometry_msgs +{ + +struct WrenchStamped +{ + std_msgs::Header header; + Wrench wrench; + // Constructor mặc định + WrenchStamped() = default; +}; + +} // namespace geometry_msgs + +#endif // WRENCH_STAMPED_H diff --git a/sensor_msgs/include/sensor_msgs/CameraInfo.h b/sensor_msgs/include/sensor_msgs/CameraInfo.h index 0146477..5d3094b 100644 --- a/sensor_msgs/include/sensor_msgs/CameraInfo.h +++ b/sensor_msgs/include/sensor_msgs/CameraInfo.h @@ -1,33 +1,8 @@ - - -# Time of image acquisition, camera coordinate frame ID -Header header # Header timestamp should be acquisition time of image - - -uint32 height -uint32 width - -string distortion_model - -float64[] D - -float64[9] K # 3x3 row-major matrix - - -float64[9] R # 3x3 row-major matrix - -float64[12] P # 3x4 row-major matrix - -uint32 binning_x -uint32 binning_y - -RegionOfInterest roi - #pragma once #include #include -#include "msg/Header.h" -#include "msg/RegionOfInterest.h" +#include "std_msgs/Header.h" +#include "sensor_msgs/RegionOfInterest.h" namespace sensor_msgs { diff --git a/sensor_msgs/include/sensor_msgs/CompressedImage.h b/sensor_msgs/include/sensor_msgs/CompressedImage.h index 923bd22..32b8ab3 100644 --- a/sensor_msgs/include/sensor_msgs/CompressedImage.h +++ b/sensor_msgs/include/sensor_msgs/CompressedImage.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include "msg/Header.h" +#include "std_msgs/Header.h" namespace sensor_msgs { diff --git a/sensor_msgs/include/sensor_msgs/FluidPressure.h b/sensor_msgs/include/sensor_msgs/FluidPressure.h index 1b3296c..8af271c 100644 --- a/sensor_msgs/include/sensor_msgs/FluidPressure.h +++ b/sensor_msgs/include/sensor_msgs/FluidPressure.h @@ -1,5 +1,5 @@ #pragma once -#include "msg/Header.h" +#include "std_msgs/Header.h" namespace sensor_msgs { diff --git a/sensor_msgs/include/sensor_msgs/Illuminance.h b/sensor_msgs/include/sensor_msgs/Illuminance.h index 9b40761..a072d79 100644 --- a/sensor_msgs/include/sensor_msgs/Illuminance.h +++ b/sensor_msgs/include/sensor_msgs/Illuminance.h @@ -1,5 +1,5 @@ #pragma once -#include "msg/Header.h" +#include "std_msgs/Header.h" namespace sensor_msgs { diff --git a/sensor_msgs/include/sensor_msgs/Image.h b/sensor_msgs/include/sensor_msgs/Image.h index d5bba9c..9cc2b61 100644 --- a/sensor_msgs/include/sensor_msgs/Image.h +++ b/sensor_msgs/include/sensor_msgs/Image.h @@ -2,7 +2,7 @@ #include #include #include -#include "msg/Header.h" +#include "std_msgs/Header.h" namespace sensor_msgs { diff --git a/sensor_msgs/include/sensor_msgs/Imu.h b/sensor_msgs/include/sensor_msgs/Imu.h index c92dd81..e684c2a 100644 --- a/sensor_msgs/include/sensor_msgs/Imu.h +++ b/sensor_msgs/include/sensor_msgs/Imu.h @@ -1,6 +1,6 @@ #pragma once #include -#include "msg/Header.h" +#include "std_msgs/Header.h" #include "geometry_msgs/Quaternion.h" #include "geometry_msgs/Vector3.h" diff --git a/sensor_msgs/include/sensor_msgs/JointState.h b/sensor_msgs/include/sensor_msgs/JointState.h index c1df5cf..a08c0f5 100644 --- a/sensor_msgs/include/sensor_msgs/JointState.h +++ b/sensor_msgs/include/sensor_msgs/JointState.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include "msg/Header.h" +#include "std_msgs/Header.h" namespace sensor_msgs { diff --git a/sensor_msgs/include/sensor_msgs/Joy.h b/sensor_msgs/include/sensor_msgs/Joy.h index e26c632..773ca60 100644 --- a/sensor_msgs/include/sensor_msgs/Joy.h +++ b/sensor_msgs/include/sensor_msgs/Joy.h @@ -1,6 +1,6 @@ #pragma once #include -#include "msg/Header.h" +#include "std_msgs/Header.h" namespace sensor_msgs { diff --git a/sensor_msgs/include/sensor_msgs/MultiEchoLaserScan.h b/sensor_msgs/include/sensor_msgs/MultiEchoLaserScan.h index 8a25151..7b1046b 100644 --- a/sensor_msgs/include/sensor_msgs/MultiEchoLaserScan.h +++ b/sensor_msgs/include/sensor_msgs/MultiEchoLaserScan.h @@ -2,8 +2,8 @@ #define MULTI_ECHO_LASER_SCAN_H #include -#include "msg/Header.h" -#include "msg/LaserEcho.h" // Định nghĩa struct LaserEcho (float32[] echoes) +#include "std_msgs/Header.h" +#include "sensor_msgs/LaserEcho.h" // Định nghĩa struct LaserEcho (float32[] echoes) namespace sensor_msgs { diff --git a/sensor_msgs/include/sensor_msgs/Range.h b/sensor_msgs/include/sensor_msgs/Range.h index e539556..39e0beb 100644 --- a/sensor_msgs/include/sensor_msgs/Range.h +++ b/sensor_msgs/include/sensor_msgs/Range.h @@ -2,7 +2,7 @@ #define RANGE_H #include -#include "Header.h" // Header tương tự std_msgs/Header +#include "std_msgs/Header.h" // Header tương tự std_msgs/Header namespace sensor_msgs { diff --git a/sensor_msgs/include/sensor_msgs/RelativeHumidity.h b/sensor_msgs/include/sensor_msgs/RelativeHumidity.h index f2e1392..dbfb419 100644 --- a/sensor_msgs/include/sensor_msgs/RelativeHumidity.h +++ b/sensor_msgs/include/sensor_msgs/RelativeHumidity.h @@ -2,7 +2,7 @@ #define RELATIVE_HUMIDITY_H #include -#include "msg/Header.h" // Giả định bạn đã có struct Header tương tự ROS std_msgs/Header +#include "std_msgs/Header.h" // Giả định bạn đã có struct Header tương tự ROS std_msgs/Header namespace sensor_msgs { diff --git a/sensor_msgs/include/sensor_msgs/Temperature.h b/sensor_msgs/include/sensor_msgs/Temperature.h index 59e4ba6..e470e50 100644 --- a/sensor_msgs/include/sensor_msgs/Temperature.h +++ b/sensor_msgs/include/sensor_msgs/Temperature.h @@ -2,7 +2,7 @@ #define TEMPERATURE_H #include -#include "msg/Header.h" // Định nghĩa struct Header tương tự std_msgs/Header +#include "std_msgs/Header.h" // Định nghĩa struct Header tương tự std_msgs/Header namespace sensor_msgs { diff --git a/sensor_msgs/include/sensor_msgs/TimeReference.h b/sensor_msgs/include/sensor_msgs/TimeReference.h index 6890a73..28b9fe7 100644 --- a/sensor_msgs/include/sensor_msgs/TimeReference.h +++ b/sensor_msgs/include/sensor_msgs/TimeReference.h @@ -2,7 +2,7 @@ #define TIMEREFERENCE_H #include -#include "msg/Header.h" // Định nghĩa struct Header tương tự std_msgs/Header +#include "std_msgs/Header.h" // Định nghĩa struct Header tương tự std_msgs/Header namespace sensor_msgs { diff --git a/sensor_msgs/test/main.cpp b/sensor_msgs/test/main.cpp index b2ee40f..f5cb101 100644 --- a/sensor_msgs/test/main.cpp +++ b/sensor_msgs/test/main.cpp @@ -40,20 +40,20 @@ int main() getParams(); sensor_msgs::BatteryState battery; - battery.header = std_msgs::Header::now("battery_frame"); - battery.voltage = 12.5f; - battery.current = -1.2f; - battery.percentage = 0.85f; - battery.power_supply_status = sensor_msgs::BatteryState::POWER_SUPPLY_STATUS_DISCHARGING; +// battery.header = std_msgs::Header::now("battery_frame"); +// battery.voltage = 12.5f; +// battery.current = -1.2f; +// battery.percentage = 0.85f; +// battery.power_supply_status = sensor_msgs::BatteryState::POWER_SUPPLY_STATUS_DISCHARGING; - battery.cell_voltage = {4.15f, 4.18f, 4.12f}; - battery.location = "slot_1"; - battery.serial_number = "SN12345"; +// battery.cell_voltage = {4.15f, 4.18f, 4.12f}; +// battery.location = "slot_1"; +// battery.serial_number = "SN12345"; - std::cout << "Battery header timestamp: " << battery.header.stamp << "\n"; - std::cout << "Battery voltage: " << battery.voltage << " V\n"; - std::cout << "Status: " << static_cast(battery.power_supply_status) << "\n"; - std::cout << "Serial Number: " << battery.serial_number << "\n"; +// std::cout << "Battery header timestamp: " << battery.header.stamp << "\n"; +// std::cout << "Battery voltage: " << battery.voltage << " V\n"; +// std::cout << "Status: " << static_cast(battery.power_supply_status) << "\n"; +// std::cout << "Serial Number: " << battery.serial_number << "\n"; sensor_msgs::JoyFeedbackArray feedback_array; feedback_array.array.push_back(sensor_msgs::JoyFeedback{sensor_msgs::JoyFeedback::TYPE_BUZZER, 0, 5000.0f}); @@ -62,14 +62,14 @@ int main() std::cout << "First feedback intensity: " << feedback_array.array[0].intensity << "\n"; sensor_msgs::PointCloud2 cloud; - cloud.header = std_msgs::Header::now("pointcloud_frame"); - cloud.width = 100; - cloud.height = 1; +// cloud.header = std_msgs::Header::now("pointcloud_frame"); +// cloud.width = 100; +// cloud.height = 1; - std::cout << "PointCloud2 header frame_id: " << cloud.header.frame_id << "\n"; - std::cout << "PointCloud2 header timestamp: " << cloud.header.stamp << "\n"; - std::cout << "PointCloud2 width: " << cloud.width << "\n"; - std::cout << "PointCloud2 height: " << cloud.height << "\n"; +// std::cout << "PointCloud2 header frame_id: " << cloud.header.frame_id << "\n"; +// std::cout << "PointCloud2 header timestamp: " << cloud.header.stamp << "\n"; +// std::cout << "PointCloud2 width: " << cloud.width << "\n"; +// std::cout << "PointCloud2 height: " << cloud.height << "\n"; return 0; } diff --git a/std_msgs/CMakeLists.txt b/std_msgs/CMakeLists.txt index 4438738..2171236 100644 --- a/std_msgs/CMakeLists.txt +++ b/std_msgs/CMakeLists.txt @@ -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) diff --git a/std_msgs/include/std_msgs/Header.h b/std_msgs/include/std_msgs/Header.h index c276a41..378e6bb 100644 --- a/std_msgs/include/std_msgs/Header.h +++ b/std_msgs/include/std_msgs/Header.h @@ -2,15 +2,15 @@ #define STD_MSGS_HEADER_H #include -#include #include +#include 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>(system_clock::now().time_since_epoch()).count(); + robot::Time time_now = robot::Time::now(); Header h; h.seq = 0; h.stamp = time_now;