26#include <geometry_msgs/msg/pose_stamped.hpp>
27#include <geometry_msgs/msg/pose_with_covariance_stamped.hpp>
29#include <rclcpp/rclcpp.hpp>
30#include <rclcpp/logging.hpp>
37 using namespace std::chrono_literals;
38template <
typename TSource,
typename TObject>
41 geometry_msgs::msg::PoseWithCovarianceStamped
location;
44template <
typename TSource,
typename TObject>
56 std::optional<geometry_msgs::msg::PoseWithCovarianceStamped>
lastPose_;
57 std::optional<geometry_msgs::msg::PoseStamped>
lastGoal_;
64 template <
typename TOrthogonal,
typename TSourceObject>
67 this->postEvAutoLocalized_ = [
this](
const geometry_msgs::msg::PoseWithCovarianceStamped & msg)
74 this->postEvGoalReached_ = [
this]()
76 this->postEvent<EvGoalReached<TSourceObject, TOrthogonal>>();
93 this->getComponent<smacc2::components::CpTopicPublisher<geometry_msgs::msg::PoseWithCovarianceStamped>>(
94 "initialPoseEstimation");
97 this->getComponent<smacc2::components::CpTopicPublisher<geometry_msgs::msg::PoseStamped>>(
115 auto & pos = this->lastPose_->pose.pose.position;
116 auto & goalpos = this->lastGoal_->pose.position;
118 double dx = pos.x - goalpos.x;
119 double dy = pos.y - goalpos.y;
120 double dz = pos.z - goalpos.z;
122 double dist = sqrt(dx * dx + dy * dy + dz * dz);
124 RCLCPP_INFO_STREAM_THROTTLE(
getLogger(), *(
getNode()->get_clock()),2000,
"[" <<
getName() <<
"] goal linear error: " << dist);
149 this->cpppubGoalPose_->
publish(msg);
154 this->cppubLocation_->
publish(msg);
smacc2::components::CpTopicPublisher< geometry_msgs::msg::PoseWithCovarianceStamped > * cppubLocation_
void publishGoalPose(const geometry_msgs::msg::PoseStamped &msg)
smacc2::components::CpTopicPublisher< geometry_msgs::msg::PoseStamped > * cpppubGoalPose_
void onInitialize() override
void onOrthogonalAllocation()
std::optional< geometry_msgs::msg::PoseStamped > lastGoal_
std::function< void(const geometry_msgs::msg::PoseWithCovarianceStamped &)> postEvAutoLocalized_
std::optional< geometry_msgs::msg::PoseWithCovarianceStamped > lastPose_
std::function< void()> postEvGoalReached_
double goalToleranceMeters_
void onNdtPoseReceived(const geometry_msgs::msg::PoseWithCovarianceStamped &msg)
void publishInitialPoseEstimation(const geometry_msgs::msg::PoseWithCovarianceStamped &msg)
rclcpp::Node::SharedPtr getNode()
virtual std::string getName() const
rclcpp::Logger getLogger()
TComponent * getComponent()
void publish(const MessageType &msg)
boost::signals2::connection onMessageReceived(void(T::*callback)(const MessageType &), T *object)
geometry_msgs::msg::PoseWithCovarianceStamped location