Skip to content

Commit

Permalink
Add path segment messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaeyoung-Lim committed Feb 25, 2024
1 parent 6f96ed1 commit aeb1adc
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions planner_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ add_message_files(
FILES
NavigationStatus.msg
TerrainInfo.msg
Path.msg
PathSegment.msg
)

add_service_files(
Expand Down
6 changes: 6 additions & 0 deletions planner_msgs/msg/Path.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Terrain Planner status
#

std_msgs/Header header

PathSegment[] segments
10 changes: 10 additions & 0 deletions planner_msgs/msg/PathSegment.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Terrain Planner status
#

std_msgs/Header header

bool reached
geometry_msgs/Vector3 segment_start
geometry_msgs/Vector3 segment_tangent
std_msgs/Float64 curvature

Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class TerrainPlanner {
void publishPathSegments(ros::Publisher &pub, Path &trajectory);
void publishGoal(const ros::Publisher &pub, const Eigen::Vector3d &position, const double radius,
Eigen::Vector3d color = Eigen::Vector3d(1.0, 1.0, 0.0), std::string name_space = "goal");
void publishPath(const ros::Publisher &pub, Path &path);
void publishRallyPoints(const ros::Publisher &pub, const std::vector<Eigen::Vector3d> &positions, const double radius,
Eigen::Vector3d color = Eigen::Vector3d(1.0, 1.0, 0.0),
std::string name_space = "rallypoints");
Expand Down
16 changes: 16 additions & 0 deletions terrain_navigation_ros/src/terrain_planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <mavros_msgs/PositionTarget.h>
#include <mavros_msgs/Trajectory.h>
#include <planner_msgs/NavigationStatus.h>
#include <planner_msgs/Path.h>
#include <tf2/LinearMath/Quaternion.h>
#include <tf2_eigen/tf2_eigen.h>
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
Expand Down Expand Up @@ -1160,3 +1161,18 @@ PathSegment TerrainPlanner::generateArcTrajectory(Eigen::Vector3d rate, const do
}
return trajectory;
}

void publishPath(const ros::Publisher &pub, Path &path) {
planner_msgs::Path path_msg;
for (const auto &path_segment : path.segments) {
planner_msgs::PathSegment segment_msg;
segment_msg.reached = path_segment.reached;
segment_msg.segment_start = toVector3(path_segment.states.front().position);
Eigen::Vector3d start_velocity = path_segment.states.front().velocity;
segment_msg.segment_tangent = toVector3(start_velocity.normalized());
segment_msg.curvature = double(path_segment.curvature);
path_msg.segments.push_back(segment_msg);
}
pub.publish(path_msg);
return;
}

0 comments on commit aeb1adc

Please sign in to comment.