-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR #3293 from remibettan: align_depth_to_infra2 enabled, pointcloud a…
…nd align_depth filters to own files
- Loading branch information
Showing
11 changed files
with
420 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
realsense2_camera/examples/pointcloud/rs_pointcloud_infra_launch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Copyright 2025 Intel Corporation. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# DESCRIPTION # | ||
# ----------- # | ||
# Use this launch file to launch a device and align depth to infrared 2. | ||
# The Parameters available for definition in the command line for the camera are described in rs_launch.configurable_parameters | ||
# command line example: | ||
# ros2 launch realsense2_camera rs_align_depth_to infra_launch.py | ||
|
||
"""Launch realsense2_camera node.""" | ||
from launch import LaunchDescription | ||
import launch_ros.actions | ||
from launch.actions import OpaqueFunction | ||
from launch.substitutions import LaunchConfiguration, ThisLaunchFileDir | ||
import sys | ||
import pathlib | ||
sys.path.append(str(pathlib.Path(__file__).parent.absolute())) | ||
import os | ||
from ament_index_python.packages import get_package_share_directory | ||
sys.path.append(os.path.join(get_package_share_directory('realsense2_camera'), 'launch')) | ||
import rs_launch | ||
|
||
local_parameters = [{'name': 'camera_name', 'default': 'camera', 'description': 'camera unique name'}, | ||
{'name': 'camera_namespace', 'default': 'camera', 'description': 'camera namespace'}, | ||
{'name': 'enable_color', 'default': 'false', 'description': 'enable color stream'}, | ||
{'name': 'enable_depth', 'default': 'true', 'description': 'enable depth stream'}, | ||
{'name': 'enable_infra2', 'default': 'true', 'description': 'enable depth stream'}, | ||
{'name': 'enable_sync', 'default': 'true', 'description': 'enable sync mode'}, | ||
{'name': 'pointcloud.enable', 'default': 'true', 'description': 'enable pointcloud'}, | ||
{'name': 'pointcloud.stream_filter', 'default': '3', 'description': 'pointcloud with infrared'}, | ||
] | ||
|
||
def set_configurable_parameters(local_params): | ||
return dict([(param['name'], LaunchConfiguration(param['name'])) for param in local_params]) | ||
|
||
|
||
def generate_launch_description(): | ||
params = rs_launch.configurable_parameters | ||
return LaunchDescription( | ||
rs_launch.declare_configurable_parameters(local_parameters) + | ||
rs_launch.declare_configurable_parameters(params) + | ||
[ | ||
OpaqueFunction(function=rs_launch.launch_setup, | ||
kwargs = {'params' : set_configurable_parameters(params)} | ||
) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2025 Intel Corporation. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include <memory> | ||
#include <librealsense2/rs.hpp> | ||
#include <sensor_params.h> | ||
#include <sensor_msgs/msg/point_cloud2.hpp> | ||
#include <ros_sensor.h> | ||
#include "named_filter.h" | ||
|
||
namespace realsense2_camera | ||
{ | ||
class AlignDepthFilter : public NamedFilter | ||
{ | ||
public: | ||
AlignDepthFilter(std::shared_ptr<rs2::filter> filter, std::function<void(const rclcpp::Parameter&)> update_align_depth_func, | ||
std::shared_ptr<Parameters> parameters, rclcpp::Logger logger, bool is_enabled = false); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2025 Intel Corporation. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include <memory> | ||
#include <librealsense2/rs.hpp> | ||
#include <sensor_params.h> | ||
#include <sensor_msgs/msg/point_cloud2.hpp> | ||
#include <ros_sensor.h> | ||
#include "named_filter.h" | ||
|
||
namespace realsense2_camera | ||
{ | ||
class PointcloudFilter : public NamedFilter | ||
{ | ||
public: | ||
PointcloudFilter(std::shared_ptr<rs2::filter> filter, rclcpp::Node& node, std::shared_ptr<Parameters> parameters, rclcpp::Logger logger, bool is_enabled=false); | ||
|
||
void setPublisher(); | ||
void Publish(rs2::points pc, const rclcpp::Time& t, const rs2::frameset& frameset, const std::string& frame_id); | ||
|
||
private: | ||
void setParameters(); | ||
|
||
private: | ||
bool _is_enabled_pc; | ||
rclcpp::Node& _node; | ||
bool _allow_no_texture_points; | ||
bool _ordered_pc; | ||
std::mutex _mutex_publisher; | ||
rclcpp::Publisher<sensor_msgs::msg::PointCloud2>::SharedPtr _pointcloud_publisher; | ||
std::string _pointcloud_qos; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2025 Intel Corporation. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <align_depth_filter.h> | ||
|
||
|
||
using namespace realsense2_camera; | ||
|
||
|
||
AlignDepthFilter::AlignDepthFilter(std::shared_ptr<rs2::filter> filter, | ||
std::function<void(const rclcpp::Parameter&)> update_align_depth_func, | ||
std::shared_ptr<Parameters> parameters, rclcpp::Logger logger, bool is_enabled): | ||
NamedFilter(filter, parameters, logger, is_enabled, false) | ||
{ | ||
_params.registerDynamicOptions(*(_filter.get()), "align_depth"); | ||
_params.getParameters()->setParamT("align_depth.enable", _is_enabled, update_align_depth_func); | ||
_parameters_names.push_back("align_depth.enable"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.