Skip to content

Commit

Permalink
fix negative timestamp in cpp protobuf example (#984)
Browse files Browse the repository at this point in the history
### Public-Facing Changes

None

### Description

Example code generates negative nanosecond values in the timestamp.

Before:
![Screenshot from 2023-09-30
07-56-12](https://github.com/foxglove/mcap/assets/2640499/c980ddb2-6d15-4536-b409-7a95ed1142c2)

After:
![Screenshot from 2023-09-30
07-54-56](https://github.com/foxglove/mcap/assets/2640499/4095a85f-d7c5-4f16-8f6c-9a59acd30df5)
  • Loading branch information
wirthual authored Oct 4, 2023
1 parent b43e305 commit 569b8a3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cpp/examples/protobuf/writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ int main(int argc, char** argv) {

auto timestamp = pcl.mutable_timestamp();
timestamp->set_seconds(static_cast<int64_t>(cloudTime) / NS_PER_S);
timestamp->set_nanos(static_cast<int>(cloudTime) % NS_PER_S);
timestamp->set_nanos(static_cast<int>(cloudTime % NS_PER_S));

// write 1000 points into each pointcloud message.
size_t offset = 0;
Expand Down

0 comments on commit 569b8a3

Please sign in to comment.