Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling RGB8 Infrared stream #2806

Merged
merged 3 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion realsense2_camera/include/base_realsense_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ namespace realsense2_camera
bool _hold_back_imu_for_frames;

std::map<stream_index_pair, rs2_intrinsics> _stream_intrinsics;
std::map<rs2_stream, rs2_format> _format;
std::map<stream_index_pair, bool> _enable;
bool _publish_tf;
double _tf_publish_rate, _diagnostics_period;
Expand Down
2 changes: 1 addition & 1 deletion realsense2_camera/include/profile_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace realsense2_camera

private:
std::string _module_name;
std::map<rs2_stream, rs2_format> _allowed_formats;
std::map<stream_index_pair, rs2_format> _allowed_formats;
int _fps;
int _width, _height;
bool _is_profile_exist;
Expand Down
2 changes: 1 addition & 1 deletion realsense2_camera/launch/rs_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
{'name': 'rgb_camera.profile', 'default': '0,0,0', 'description': 'color image width'},
{'name': 'rgb_camera.enable_auto_exposure', 'default': 'true', 'description': 'enable/disable auto exposure for color image'},
{'name': 'enable_color', 'default': 'true', 'description': 'enable color stream'},
{'name': 'enable_infra', 'default': 'false', 'description': 'enable infra0 stream'},
{'name': 'enable_infra1', 'default': 'false', 'description': 'enable infra1 stream'},
{'name': 'enable_infra2', 'default': 'false', 'description': 'enable infra2 stream'},
{'name': 'infra_rgb', 'default': 'false', 'description': 'enable infra2 stream'},
Nir-Az marked this conversation as resolved.
Show resolved Hide resolved
{'name': 'enable_fisheye1', 'default': 'true', 'description': 'enable fisheye1 stream'},
{'name': 'enable_fisheye2', 'default': 'true', 'description': 'enable fisheye2 stream'},
{'name': 'enable_confidence', 'default': 'true', 'description': 'enable depth stream'},
Expand Down
3 changes: 0 additions & 3 deletions realsense2_camera/src/base_realsense_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ BaseRealSenseNode::BaseRealSenseNode(rclcpp::Node& node,
_encoding[1] = sensor_msgs::image_encodings::MONO8; // ROS message type
_encoding[2] = sensor_msgs::image_encodings::TYPE_16UC1; // ROS message type
_encoding[3] = sensor_msgs::image_encodings::RGB8; // ROS message type

// Infrared stream
_format[RS2_STREAM_INFRARED] = RS2_FORMAT_Y8;
Copy link
Contributor Author

@Arun-Prasad-V Arun-Prasad-V Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is not used anywhere.


_monitor_options = {RS2_OPTION_ASIC_TEMPERATURE, RS2_OPTION_PROJECTOR_TEMPERATURE};
}
Expand Down
17 changes: 13 additions & 4 deletions realsense2_camera/src/profile_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ void ProfilesManager::registerSensorUpdateParam(std::string template_name,
{
std::string param_name = applyTemplateName(template_name, sip);
if (params.find(sip) == params.end())
params[sip] = std::make_shared<T>(value);
Nir-Az marked this conversation as resolved.
Show resolved Hide resolved
{
if (sip == INFRA0)
// Disabling Infra 0 stream by default
params[sip] = std::make_shared<T>(false);
else
params[sip] = std::make_shared<T>(value);
}
std::shared_ptr<T> param = params[sip];
_params.getParameters()->setParam<T>(param_name, *(params[sip]), [param, update_sensor_func](const rclcpp::Parameter& parameter)
{
Expand Down Expand Up @@ -198,8 +204,10 @@ VideoProfilesManager::VideoProfilesManager(std::shared_ptr<Parameters> parameter
_module_name(module_name),
_force_image_default_qos(force_image_default_qos)
{
_allowed_formats[RS2_STREAM_DEPTH] = RS2_FORMAT_Z16;
_allowed_formats[RS2_STREAM_INFRARED] = RS2_FORMAT_Y8;
_allowed_formats[{RS2_STREAM_DEPTH, 0}] = RS2_FORMAT_Z16;
_allowed_formats[{RS2_STREAM_INFRARED, 0}] = RS2_FORMAT_RGB8;
Nir-Az marked this conversation as resolved.
Show resolved Hide resolved
_allowed_formats[{RS2_STREAM_INFRARED, 1}] = RS2_FORMAT_Y8;
_allowed_formats[{RS2_STREAM_INFRARED, 2}] = RS2_FORMAT_Y8;
}

bool VideoProfilesManager::isSameProfileValues(const rs2::stream_profile& profile, const int width, const int height, const int fps)
Expand All @@ -209,10 +217,11 @@ bool VideoProfilesManager::isSameProfileValues(const rs2::stream_profile& profil
auto video_profile = profile.as<rs2::video_stream_profile>();
ROS_DEBUG_STREAM("Sensor profile: " << profile_string(profile));

stream_index_pair sip = {video_profile.stream_type(), video_profile.stream_index()};
return ((video_profile.width() == width) &&
(video_profile.height() == height) &&
(video_profile.fps() == fps) &&
(_allowed_formats.find(video_profile.stream_type()) == _allowed_formats.end() || video_profile.format() == _allowed_formats[video_profile.stream_type()] ));
(_allowed_formats.find(sip) == _allowed_formats.end() || video_profile.format() == _allowed_formats[sip] ));
}

bool VideoProfilesManager::isWantedProfile(const rs2::stream_profile& profile)
Expand Down