We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0a08d87 commit f0d76adCopy full SHA for f0d76ad
1 file changed
src/sensor_trigger.cpp
@@ -162,7 +162,7 @@ void SensorTrigger::run()
162
bool to_high = gpio_handler_.set_gpio_pin_state(GPIO_HIGH);
163
rclcpp::sleep_for(std::chrono::nanoseconds(pulse_width));
164
rclcpp::Time now = rclcpp::Clock{RCL_SYSTEM_TIME}.now();
165
- int64_t now_sec = now.nanoseconds() / 1e9;
+ int64_t now_sec = (now.nanoseconds() - pulse_width) / 1e9; // subtract pulse width to correct timestamp
166
trigger_time_msg.sec = (int32_t)now_sec;
167
trigger_time_msg.nanosec = (uint32_t)now_nsec;
168
trigger_time_publisher_->publish(trigger_time_msg);
0 commit comments