Skip to content

Commit

Permalink
Resolved comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgenfj committed Mar 3, 2024
1 parent b512be4 commit 203891a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 47 deletions.
2 changes: 1 addition & 1 deletion asv_setup/launch/tf.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def generate_launch_description():
'--pitch' , '0',
'--yaw' , '0',
'--frame-id' , 'base_link',
'--child-frame-id' , 'seapath_frame_pose'],
'--child-frame-id' , 'seapath_frame'],
)

return LaunchDescription([
Expand Down
4 changes: 2 additions & 2 deletions mission/landmark_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <rclcpp/rclcpp.hpp>
#include <rclcpp_action/rclcpp_action.hpp>
#include <thread>
#include <sstream>

#include <geometry_msgs/msg/pose_array.hpp>
#include <vortex_msgs/action/filtered_landmarks.hpp>
Expand Down Expand Up @@ -137,15 +138,6 @@ class LandmarkServerNode : public rclcpp::Node {
vortex_msgs::action::FilteredLandmarks>>
goal_handle);

/**
* Calculates the distance between the landmark and the drone.
*
* @param pose The pose of the landmark.
* @param target_frame The frame to which data should be transformed.
* @param source_frame The frame where the data originated
* @return The distance between the landmark and the drone.
*/

/**
* @brief Logs messages based on request.
*
Expand Down
2 changes: 1 addition & 1 deletion mission/landmark_server/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<name>landmark_server</name>
<version>0.0.1</version>
<description>ROS2 action server that handles the storage of landmarks and publishing based on the action request</description>
<maintainer email="[email protected]">jorgen Fjermedal</maintainer>
<maintainer email="[email protected]">Jorgen Fjermedal</maintainer>
<license>MIT</license>

<buildtool_depend>ament_cmake</buildtool_depend>
Expand Down
65 changes: 31 additions & 34 deletions mission/landmark_server/src/landmark_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void LandmarkServerNode::landmarksRecievedCallback(
"Received empty landmark array");
return;
}
const auto &pose = msg->landmarks[0].odom.pose.pose;

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

Expand All @@ -63,7 +63,7 @@ void LandmarkServerNode::landmarksRecievedCallback(
}),
storedLandmarks_->landmarks.end());
} else if (landmark.action == 1) {
// Find if the landmark already exists
// Find the landmark if it already exists
auto it = std::find_if(
storedLandmarks_->landmarks.begin(),
storedLandmarks_->landmarks.end(), [&](const auto &storedLandmark) {
Expand Down Expand Up @@ -225,38 +225,35 @@ vortex_msgs::msg::OdometryArray LandmarkServerNode::filterLandmarks(
return filteredLandmarksOdoms;
}

void LandmarkServerNode::requestLogger(
const std::shared_ptr<
rclcpp_action::ServerGoalHandle<vortex_msgs::action::FilteredLandmarks>>
goal_handle) {
const auto goal = goal_handle->get_goal();
double distance = goal->distance;

if (distance == 0.0 && goal->landmark_types.empty()) {
RCLCPP_INFO(this->get_logger(), "Received request to return all landmarks");
} else if (goal->landmark_types.empty()) {
RCLCPP_INFO(this->get_logger(),
"Received request to return all landmarks within distance %f",
distance);
} else {
// Log the request to return landmarks by type filter
std::string types_log =
"Received request to return landmarks by type filter: [";

for (const auto &type : goal->landmark_types) {
types_log += type + ", ";
}

// Remove the trailing comma and space
if (!goal->landmark_types.empty()) {
types_log = types_log.substr(0, types_log.size() - 2);
}

types_log += "]";

RCLCPP_INFO(this->get_logger(), types_log.c_str());
}
}
void LandmarkServerNode::requestLogger(
const std::shared_ptr<
rclcpp_action::ServerGoalHandle<vortex_msgs::action::FilteredLandmarks>>
goal_handle) {
const auto goal = goal_handle->get_goal();
double distance = goal->distance;

if (distance == 0.0 && goal->landmark_types.empty()) {
RCLCPP_INFO_STREAM(this->get_logger(), "Received request to return all landmarks.");
return;
}

if (goal->landmark_types.empty()) {
RCLCPP_INFO_STREAM(this->get_logger(),
"Received request to return all landmarks within distance " << distance << ".");
return;
}

std::stringstream types_log;
types_log << "Received request to return landmarks by type filter: [";
for (auto it = goal->landmark_types.begin(); it != goal->landmark_types.end(); it++) {
types_log << *it;
if (std::next(it) != goal->landmark_types.end()) {
types_log << ", ";
}
}
types_log << "].";
RCLCPP_INFO_STREAM(this->get_logger(), types_log.str());
}

double
LandmarkServerNode::calculateDistance(const geometry_msgs::msg::Point &point,
Expand Down

0 comments on commit 203891a

Please sign in to comment.