8: Node(
"point_cloud_processor")
12 subscription_ = this->create_subscription<sensor_msgs::msg::PointCloud2>(
16 publisher_ = this->create_publisher<sensor_msgs::msg::PointCloud2>(
19 RCLCPP_INFO(this->get_logger(),
"PointCloudProcessor node initialized.");
29 this->declare_parameter<float>(
"update_rate",
kUpdateRate);
38 RCLCPP_INFO(this->get_logger(),
"Loading Parameters...");
39 RCLCPP_INFO(this->get_logger(),
"Filter parameters:");
40 RCLCPP_INFO(this->get_logger(),
" Red threshold: %d",
red_threshold_);
42 RCLCPP_INFO(this->get_logger(),
" Blue threshold: %d",
blue_threshold_);
45 this->get_logger(),
"Publishing filtered point cloud on: %s",
47 RCLCPP_INFO(this->get_logger(),
"Update Rate: %f Hz",
update_rate_);
53 pcl::PointCloud<pcl::PointXYZRGB>::Ptr pcl_cloud(
new pcl::PointCloud<pcl::PointXYZRGB>());
54 pcl::fromROSMsg(*msg, *pcl_cloud);
56 pcl::PointCloud<pcl::PointXYZRGB>::Ptr filtered_cloud(
new pcl::PointCloud<pcl::PointXYZRGB>());
57 for (
const auto & point : *pcl_cloud) {
59 filtered_cloud->push_back(point);
72int main(
int argc,
char ** argv)
74 rclcpp::init(argc, argv);
75 rclcpp::spin(std::make_shared<pointcloud_motion_capture::PointCloudProcessor>());
const std::string kPointCloudTopicFiltered
ROS topic that publishes the filtered point cloud.
std::string point_cloud_topic_raw_
ROS topic for receiving the raw point cloud data.
std::string point_cloud_topic_filtered_
ROS topic for publishing the filtered point cloud data.
const int kBlueThresholdDefault
Default value for the blue color threshold.
const int kGreenThresholdDefault
Default value for the green color threshold.
void load_parameters()
Loads parameters from the ROS2 parameter server.
float update_rate_
Update rate for processing the point cloud data.
const float kUpdateRate
Default update rate (in Hz).
rclcpp::Publisher< sensor_msgs::msg::PointCloud2 >::SharedPtr publisher_
ROS2 publisher to publish filtered PointCloud2 messages.
int red_threshold_
Threshold value for red color filtering.
int green_threshold_
Threshold value for green color filtering.
rclcpp::Subscription< sensor_msgs::msg::PointCloud2 >::SharedPtr subscription_
ROS2 subscription to receive PointCloud2 messages.
void pointCloudCallback(const sensor_msgs::msg::PointCloud2::SharedPtr msg)
Callback function for processing incoming point cloud data.
std::string frame_id_
Frame ID used for the point cloud data.
int blue_threshold_
Threshold value for blue color filtering.
const int kRedThresholdDefault
Default value for the red color threshold.
sensor_msgs::msg::PointCloud2 filtered_msg_
Holds the filtered PointCloud2 message.
const std::string kPointCloudTopicRaw
ROS topic that receives the raw (unfiltered) point cloud.
int main(int argc, char **argv)