Skip to content

Commit

Permalink
Added global path publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermogilg99 committed Oct 3, 2024
1 parent 1a1832b commit 11407e8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ if(BUILD_ROS_SUPPORT)
################################################
catkin_python_setup()

## Add message files
add_message_files(
FILES
Vec3i.msg
CoordinateList.msg
)

## Generate services in the 'srv' folder
add_service_files(
FILES
Expand Down
1 change: 1 addition & 0 deletions msg/CoordinateList.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Vec3i[] coordinates
3 changes: 3 additions & 0 deletions msg/Vec3i.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int32 x
int32 y
int32 z
18 changes: 17 additions & 1 deletion src/ROS/planner_ros_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include <heuristic_planners/GetPath.h>
#include <heuristic_planners/SetAlgorithm.h>
#include <heuristic_planners/ShareWeights.h>
#include <heuristic_planners/Vec3i.h>
#include <heuristic_planners/CoordinateList.h>

#define USING_PRETRAINED_MODELS 1
#define EXAMPLE_PATH 2
Expand Down Expand Up @@ -83,6 +85,7 @@ class HeuristicPlannerROS

line_markers_pub_ = lnh_.advertise<visualization_msgs::Marker>("path_line_markers", 1);
point_markers_pub_ = lnh_.advertise<visualization_msgs::Marker>("path_points_markers", 1);
global_path_pub_ = lnh_.advertise<heuristic_planners::CoordinateList>("global_path", 1);

}

Expand Down Expand Up @@ -638,6 +641,19 @@ class HeuristicPlannerROS
}
path = std::get<Planners::utils::CoordinateList>(path_data["path"]);

// Send a message through the global_path topic
heuristic_planners::CoordinateList coord_msg;
for (const auto& vec3 : path) {
heuristic_planners::Vec3i vec_msg;
vec_msg.x = vec3.x;
vec_msg.y = vec3.y;
vec_msg.z = vec3.z;

coord_msg.coordinates.push_back(vec_msg);
}
global_path_pub_.publish(coord_msg);


}catch(std::bad_variant_access const& ex){
std::cerr << "Bad variant error: " << ex.what() << std::endl;
}
Expand Down Expand Up @@ -929,7 +945,7 @@ class HeuristicPlannerROS
ros::ServiceServer request_path_server_, change_planner_server_;
ros::Subscriber pointcloud_sub_, occupancy_grid_sub_, sdf_sub_;
//TODO Fix point markers
ros::Publisher line_markers_pub_, point_markers_pub_;
ros::Publisher line_markers_pub_, point_markers_pub_, global_path_pub_;

std::unique_ptr<Grid3d> m_grid3d_;

Expand Down

0 comments on commit 11407e8

Please sign in to comment.