Skip to content

Commit

Permalink
fix diag time stamp
Browse files Browse the repository at this point in the history
Signed-off-by: Yamato Ando <yamato.ando@tier4.jp>
  • Loading branch information
YamatoAndo committed May 31, 2024
1 parent dd1423b commit 756359b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class DiagnosticsModule
template <typename T>
void addKeyValue(const std::string & key, const T & value);
void updateLevelAndMessage(const int8_t level, const std::string & message);
void publish();
void publish(const rclcpp::Time & publish_time_stamp);

private:
diagnostic_msgs::msg::DiagnosticArray createDiagnosticsArray() const;
diagnostic_msgs::msg::DiagnosticArray createDiagnosticsArray(const rclcpp::Time & publish_time_stamp) const;

rclcpp::Clock::SharedPtr clock_;
rclcpp::Publisher<diagnostic_msgs::msg::DiagnosticArray>::SharedPtr diagnostics_pub_;
Expand Down
8 changes: 4 additions & 4 deletions localization/gyro_odometer/src/diagnostics_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ void DiagnosticsModule::updateLevelAndMessage(const int8_t level, const std::str
}
}

void DiagnosticsModule::publish()
void DiagnosticsModule::publish(const rclcpp::Time & publish_time_stamp)
{
diagnostics_pub_->publish(createDiagnosticsArray());
diagnostics_pub_->publish(createDiagnosticsArray(publish_time_stamp));
}

diagnostic_msgs::msg::DiagnosticArray DiagnosticsModule::createDiagnosticsArray() const
diagnostic_msgs::msg::DiagnosticArray DiagnosticsModule::createDiagnosticsArray(const rclcpp::Time & publish_time_stamp) const
{
diagnostic_msgs::msg::DiagnosticArray diagnostics_msg;
diagnostics_msg.header.stamp = clock_->now();
diagnostics_msg.header.stamp = publish_time_stamp;
diagnostics_msg.status.push_back(diagnostics_status_msg_);

if (diagnostics_msg.status.at(0).level == diagnostic_msgs::msg::DiagnosticStatus::OK) {
Expand Down
4 changes: 2 additions & 2 deletions localization/gyro_odometer/src/gyro_odometer_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void GyroOdometerNode::callbackVehicleTwist(
vehicle_twist_queue_.push_back(*vehicle_twist_ptr);
concatGyroAndOdometer();

diagnostics_->publish();
diagnostics_->publish(vehicle_twist_ptr->header.stamp);

Check warning on line 94 in localization/gyro_odometer/src/gyro_odometer_core.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Code Duplication

The module contains 2 functions with similar structure: GyroOdometerNode::callbackImu,GyroOdometerNode::callbackVehicleTwist. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.
}


Expand All @@ -105,7 +105,7 @@ void GyroOdometerNode::callbackImu(const sensor_msgs::msg::Imu::ConstSharedPtr i
gyro_queue_.push_back(*imu_msg_ptr);
concatGyroAndOdometer();

diagnostics_->publish();
diagnostics_->publish(imu_msg_ptr->header.stamp);
}


Expand Down

0 comments on commit 756359b

Please sign in to comment.