Skip to content

Commit

Permalink
merged master->ros2
Browse files Browse the repository at this point in the history
  • Loading branch information
matlabbe committed Sep 4, 2024
2 parents c6ba204 + 76f1c50 commit 9a584bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 7 additions & 0 deletions rtabmap_odom/include/rtabmap_odom/OdometryROS.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ class OdometryROS : public rclcpp::Node, public UThread
rtabmap::SensorData dataToProcess_;
std_msgs::msg::Header dataHeaderToProcess_;

// Safe-threading
UMutex imuMutex_;
UMutex dataMutex_;
USemaphore dataReady_;
rtabmap::SensorData dataToProcess_;
std_msgs::Header dataHeaderToProcess_;

bool paused_;
int resetCountdown_;
int resetCurrentCount_;
Expand Down
12 changes: 7 additions & 5 deletions rtabmap_odom/src/OdometryROS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,12 @@ void OdometryROS::processData(SensorData & data, const std_msgs::msg::Header & h
}
else
{
RCLCPP_DEBUG(get_logger(), "Dropping image");
RCLCPP_DEBUG(get_logger(), "Dropping image/scan data");
}
}

void OdometryROS::mainLoopKill()
{
RCLCPP_WARN(this->get_logger(), "OdometryROS::mainLoopKill()");
// in case we were waiting, unblock thread
dataReady_.release();
}
Expand Down Expand Up @@ -1055,20 +1054,21 @@ void OdometryROS::mainLoop()
odomSensorDataCompressedPub_->publish(msg);
}

double delay = (now()-header.stamp).seconds();
if(visParams_)
{
if(icpParams_)
{
RCLCPP_INFO(this->get_logger(), "Odom: quality=%d, ratio=%f, std dev=%fm|%frad, update time=%fs delay=%fs", info.reg.inliers, info.reg.icpInliersRatio, pose.isNull()?0.0f:std::sqrt(info.reg.covariance.at<double>(0,0)), pose.isNull()?0.0f:std::sqrt(info.reg.covariance.at<double>(5,5)), (now()-timeStart).seconds(), (now()-header.stamp).seconds());
RCLCPP_INFO(this->get_logger(), "Odom: quality=%d, ratio=%f, std dev=%fm|%frad, update time=%fs delay=%fs", info.reg.inliers, info.reg.icpInliersRatio, pose.isNull()?0.0f:std::sqrt(info.reg.covariance.at<double>(0,0)), pose.isNull()?0.0f:std::sqrt(info.reg.covariance.at<double>(5,5)), (now()-timeStart).seconds(), delay);
}
else
{
RCLCPP_INFO(this->get_logger(), "Odom: quality=%d, std dev=%fm|%frad, update time=%fs delay=%fs", info.reg.inliers, pose.isNull()?0.0f:std::sqrt(info.reg.covariance.at<double>(0,0)), pose.isNull()?0.0f:std::sqrt(info.reg.covariance.at<double>(5,5)), (now()-timeStart).seconds(), (now()-header.stamp).seconds());
RCLCPP_INFO(this->get_logger(), "Odom: quality=%d, std dev=%fm|%frad, update time=%fs delay=%fs", info.reg.inliers, pose.isNull()?0.0f:std::sqrt(info.reg.covariance.at<double>(0,0)), pose.isNull()?0.0f:std::sqrt(info.reg.covariance.at<double>(5,5)), (now()-timeStart).seconds(), delay);
}
}
else // if(icpParams_)
{
RCLCPP_INFO(this->get_logger(), "Odom: ratio=%f, std dev=%fm|%frad, update time=%fs delay=%fs", info.reg.icpInliersRatio, pose.isNull()?0.0f:std::sqrt(info.reg.covariance.at<double>(0,0)), pose.isNull()?0.0f:std::sqrt(info.reg.covariance.at<double>(5,5)), (now()-timeStart).seconds(), (now()-header.stamp).seconds());
RCLCPP_INFO(this->get_logger(), "Odom: ratio=%f, std dev=%fm|%frad, update time=%fs delay=%fs", info.reg.icpInliersRatio, pose.isNull()?0.0f:std::sqrt(info.reg.covariance.at<double>(0,0)), pose.isNull()?0.0f:std::sqrt(info.reg.covariance.at<double>(5,5)), (now()-timeStart).seconds(), delay);
}

statusDiagnostic_.setStatus(pose.isNull());
Expand Down Expand Up @@ -1112,6 +1112,8 @@ void OdometryROS::reset(const Transform & pose)
previousStamp_ = 0.0;
resetCurrentCount_ = resetCountdown_;
imuProcessed_ = false;
dataToProcess_ = SensorData();
dataHeaderToProcess_ = std_msgs::Header();
imuMutex_.lock();
imus_.clear();
imuMutex_.unlock();
Expand Down

0 comments on commit 9a584bc

Please sign in to comment.