-
Notifications
You must be signed in to change notification settings - Fork 33
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
AfWindows #14
AfWindows #14
Changes from all commits
6601ad9
6b1d368
17d361f
c98c5d8
91ac144
014dbb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument, LogInfo | ||
from launch.substitutions import LaunchConfiguration | ||
from launch_ros.actions import Node | ||
|
||
|
||
def generate_launch_description(): | ||
return LaunchDescription( | ||
[ | ||
DeclareLaunchArgument("width", default_value="640", description="Camera image width"), | ||
DeclareLaunchArgument("height", default_value="320", description="Camera image height"), | ||
DeclareLaunchArgument("log_level", default_value="debug", description="Log level (e.g., debug)"), | ||
# You can add other launch arguments as needed. | ||
# Run the camera_node with the specified parameters. | ||
Node( | ||
package="camera_ros", | ||
executable="camera_node", | ||
name="camera", | ||
output="screen", # Adjust the output as needed. | ||
parameters=[ | ||
{"width": LaunchConfiguration("width")}, | ||
{"height": LaunchConfiguration("height")}, | ||
{"mode_width": 2304}, | ||
{"mode_height": 1296}, | ||
{"qos_overrides./camera/image_raw.publisher.reliability": "best_effort"}, | ||
{"qos_overrides./camera/image_raw/compressed.publisher.reliability": "best_effort"}, | ||
# {"qos_overrides./camera/camera_info.publisher.reliability": "best_effort"}, | ||
], | ||
remappings=[], # Add remappings if necessary. | ||
arguments=["--log-level", LaunchConfiguration("log_level")], | ||
), | ||
# You can add additional nodes or actions here as needed. | ||
] | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
#include <libcamera/base/signal.h> | ||
#include <libcamera/base/span.h> | ||
#include <libcamera/camera.h> | ||
#include <libcamera/formats.h> | ||
#include <libcamera/camera_manager.h> | ||
#include <libcamera/controls.h> | ||
#include <libcamera/framebuffer.h> | ||
|
@@ -161,14 +162,26 @@ CameraNode::CameraNode(const rclcpp::NodeOptions &options) : Node("camera", opti | |
declare_parameter<int64_t>("width", {}, param_descr_ro); | ||
declare_parameter<int64_t>("height", {}, param_descr_ro); | ||
|
||
declare_parameter<int64_t>("mode_width", {}, param_descr_ro); | ||
declare_parameter<int64_t>("mode_height", {}, param_descr_ro); | ||
|
||
// camera ID | ||
declare_parameter("camera", rclcpp::ParameterValue {}, param_descr_ro.set__dynamic_typing(true)); | ||
|
||
auto qos_override_options = rclcpp::QosOverridingOptions({ | ||
rclcpp::QosPolicyKind::Depth, | ||
rclcpp::QosPolicyKind::History, | ||
rclcpp::QosPolicyKind::Reliability, | ||
rclcpp::QosPolicyKind::Durability, | ||
}); | ||
|
||
rclcpp::PublisherOptions pub_options; | ||
pub_options.qos_overriding_options = qos_override_options; | ||
// publisher for raw and compressed image | ||
pub_image = this->create_publisher<sensor_msgs::msg::Image>("~/image_raw", 1); | ||
pub_image = this->create_publisher<sensor_msgs::msg::Image>("~/image_raw", 1, pub_options); | ||
pub_image_compressed = | ||
this->create_publisher<sensor_msgs::msg::CompressedImage>("~/image_raw/compressed", 1); | ||
pub_ci = this->create_publisher<sensor_msgs::msg::CameraInfo>("~/camera_info", 1); | ||
this->create_publisher<sensor_msgs::msg::CompressedImage>("~/image_raw/compressed", 1, pub_options); | ||
pub_ci = this->create_publisher<sensor_msgs::msg::CameraInfo>("~/camera_info", 1, pub_options); | ||
Comment on lines
+171
to
+184
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you changing the default QoS settings? If you need to change the QoS settings, you can also do this via parameters. See |
||
|
||
// start camera manager and check for cameras | ||
camera_manager.start(); | ||
|
@@ -216,9 +229,18 @@ CameraNode::CameraNode(const rclcpp::NodeOptions &options) : Node("camera", opti | |
if (camera->acquire()) | ||
throw std::runtime_error("failed to acquire camera"); | ||
|
||
std::vector<libcamera::StreamRole> roles; | ||
|
||
roles.push_back(get_role(get_parameter("role").as_string())); | ||
const libcamera::Size mode_size(get_parameter("mode_width").as_int(), get_parameter("mode_height").as_int()); | ||
|
||
if(!mode_size.isNull()) { | ||
roles.push_back(libcamera::StreamRole::Raw); | ||
} | ||
|
||
// configure camera stream | ||
std::unique_ptr<libcamera::CameraConfiguration> cfg = | ||
camera->generateConfiguration({get_role(get_parameter("role").as_string())}); | ||
camera->generateConfiguration({roles}); | ||
|
||
if (!cfg) | ||
throw std::runtime_error("failed to generate configuration"); | ||
|
@@ -266,6 +288,7 @@ CameraNode::CameraNode(const rclcpp::NodeOptions &options) : Node("camera", opti | |
} | ||
|
||
const libcamera::Size size(get_parameter("width").as_int(), get_parameter("height").as_int()); | ||
|
||
if (size.isNull()) { | ||
RCLCPP_INFO_STREAM(get_logger(), scfg); | ||
scfg.size = scfg.formats().sizes(scfg.pixelFormat).back(); | ||
|
@@ -276,6 +299,20 @@ CameraNode::CameraNode(const rclcpp::NodeOptions &options) : Node("camera", opti | |
scfg.size = size; | ||
} | ||
|
||
if(!mode_size.isNull()) { | ||
RCLCPP_INFO_STREAM(get_logger(), mode_size); | ||
libcamera::StreamConfiguration &modecfg = cfg->at(1); | ||
modecfg.size = mode_size; | ||
|
||
modecfg.pixelFormat = libcamera::formats::SBGGR12_CSI2P; | ||
|
||
RCLCPP_INFO_STREAM(get_logger(), "modecfg "); | ||
RCLCPP_INFO_STREAM(get_logger(), modecfg); | ||
|
||
set_parameter(rclcpp::Parameter("mode_width", int64_t(modecfg.size.width))); | ||
set_parameter(rclcpp::Parameter("mode_height", int64_t(modecfg.size.height))); | ||
} | ||
|
||
// store selected stream configuration | ||
const libcamera::StreamConfiguration selected_scfg = scfg; | ||
|
||
|
@@ -394,6 +431,8 @@ CameraNode::declareParameters() | |
// dynamic camera configuration | ||
ParameterMap parameters_init; | ||
for (const auto &[id, info] : camera->controls()) { | ||
if (id->name() == "AfWindows") | ||
continue; | ||
Comment on lines
+434
to
+435
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You cannot just ignore a parameter. What about other users that want to make use of it? And the commit message does not describe what you change and why. |
||
// store control id with name | ||
parameter_ids[id->name()] = id; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer not to add a launch file in this repo since the node already uses sensible defaults provided by libcamera.