Skip to content

Commit

Permalink
Helped jorgen
Browse files Browse the repository at this point in the history
  • Loading branch information
etfroeland committed Mar 3, 2024
1 parent 55ae778 commit 4619992
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mission/landmark_server/src/landmark_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ LandmarkServerNode::LandmarkServerNode(const rclcpp::NodeOptions &options)
tf2_listener_ = std::make_shared<tf2_ros::TransformListener>(*tf2_buffer_);

declare_parameter<std::string>("target_frame", "base_link");
declare_parameter<std::string>("world_frame", "world_frame");

// Create the act.
action_server_ = rclcpp_action::create_server<Action>(
Expand All @@ -49,7 +50,6 @@ void LandmarkServerNode::landmarksRecievedCallback(
}

for (const auto &landmark : msg->landmarks) {
// RCLCPP_INFO(this->get_logger(), "Landmarks received");

if (landmark.action == 0) {
// Remove landmarks with matching id and landmark_type
Expand Down Expand Up @@ -91,7 +91,13 @@ geometry_msgs::msg::PoseArray LandmarkServerNode::poseArrayCreater(

geometry_msgs::msg::PoseArray poseArray;
// sets the header for the array to equal the header of the first landmark
poseArray.header.frame_id = landmarks.landmarks[0].odom.header.frame_id;
if (!landmarks.landmarks.empty()) {
poseArray.header.frame_id = landmarks.landmarks.at(0).odom.header.frame_id;
}
else {
poseArray.header.frame_id = get_parameter("world_frame").as_string();
poseArray.header.stamp = rclcpp::Clock().now();
}
// Timestamps for stored landmarks may vary so use current time for
// visualization
poseArray.header.stamp = rclcpp::Clock().now();
Expand Down

0 comments on commit 4619992

Please sign in to comment.