Skip to content

Commit

Permalink
Merge pull request #2166 from doronhi/ros2-beta-add-profile-description
Browse files Browse the repository at this point in the history
ROS2-beta-add profile description with available options.
  • Loading branch information
doronhi authored Nov 17, 2021
2 parents a4d29de + 0201fda commit 6bec96e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion realsense2_camera/src/profile_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,26 @@ void VideoProfilesManager::registerProfileParameters(std::vector<stream_profile>
}
}

std::string get_profiles_descriptions(const std::vector<rs2::stream_profile>& all_profiles)
{
std::set<std::string> profiles_str;
for (auto& profile : all_profiles)
{
auto video_profile = profile.as<rs2::video_stream_profile>();
std::stringstream crnt_profile_str;
crnt_profile_str << video_profile.width() << "x" << video_profile.height() << "x" << video_profile.fps();
profiles_str.insert(crnt_profile_str.str());
}
std::stringstream descriptors_strm;
for (auto& profile_str : profiles_str)
{
descriptors_strm << profile_str << "\n";
}
std::string descriptors(descriptors_strm.str());
descriptors.pop_back();
return descriptors;
}

void VideoProfilesManager::registerVideoSensorParams()
{
// Set default values:
Expand All @@ -252,7 +272,7 @@ void VideoProfilesManager::registerVideoSensorParams()
// Register ROS parameter:
std::string param_name(_module_name + ".profile");
rcl_interfaces::msg::ParameterDescriptor crnt_descriptor;
crnt_descriptor.description = "Available options are: DORON\n";
crnt_descriptor.description = "Available options are:\n" + get_profiles_descriptions(_all_profiles);
std::stringstream crnt_profile_str;
crnt_profile_str << _width << "x" << _height << "x" << _fps;
rclcpp::ParameterValue aa = _params.getParameters()->setParam(param_name, rclcpp::ParameterValue(crnt_profile_str.str()), [this](const rclcpp::Parameter& parameter)
Expand Down

0 comments on commit 6bec96e

Please sign in to comment.