Skip to content

Commit

Permalink
Merge pull request #35 from Autumn60/hotfix/ros2
Browse files Browse the repository at this point in the history
Hotfix ros2 header time stamp
  • Loading branch information
Autumn60 authored Jul 25, 2023
2 parents 30bec3d + 7ff962c commit bf53d89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public void Init(string frame_id)
/// </summary>
public void Serialize(float time)
{
#if ROS2
int sec = (int)Math.Truncate(time);
#else
uint sec = (uint)Math.Truncate(time);
# endif
_header.stamp.sec = sec;
_header.stamp.nanosec = (uint)((time - sec) * 1e+9);
_header.seq++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ void Start()
void Update()
{
float time = Time.time;
#if ROS2
int sec = (int)Math.Truncate(time);
#else
uint sec = (uint)Math.Truncate(time);
# endif
uint nanosec = (uint)((time - sec) * 1e+9);
_message.clock.sec = sec;
_message.clock.nanosec = nanosec;
Expand Down

0 comments on commit bf53d89

Please sign in to comment.