-
Notifications
You must be signed in to change notification settings - Fork 261
feat: Add an option to use still output in RGB node #783
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
base: jazzy
Are you sure you want to change the base?
Changes from 5 commits
1b78691
4ce950e
83ca622
15fb9e8
cae627b
6229dcf
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 |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ depthai | |
| depthai_bridge | ||
| rclcpp | ||
| std_msgs | ||
| std_srvs | ||
| sensor_msgs | ||
| image_transport) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ void RGB::setNames() { | |
| ispQName = getName() + "_isp"; | ||
| previewQName = getName() + "_preview"; | ||
| controlQName = getName() + "_control"; | ||
| stillQName = getName() + "_still"; | ||
| } | ||
|
|
||
| void RGB::setXinXout(std::shared_ptr<dai::Pipeline> pipeline) { | ||
|
|
@@ -59,6 +60,9 @@ void RGB::setXinXout(std::shared_ptr<dai::Pipeline> pipeline) { | |
| if(ph->getParam<bool>("i_enable_preview")) { | ||
| previewPub = setupOutput(pipeline, previewQName, [&](auto input) { colorCamNode->preview.link(input); }); | ||
| } | ||
| if(ph->getParam<bool>("i_enable_still")) { | ||
| stillPub = setupOutput(pipeline, stillQName, [&](auto input) { colorCamNode->still.link(input); }); | ||
| } | ||
| xinControl = pipeline->create<dai::node::XLinkIn>(); | ||
| xinControl->setStreamName(controlQName); | ||
| xinControl->out.link(colorCamNode->inputControl); | ||
|
|
@@ -119,6 +123,31 @@ void RGB::setupQueues(std::shared_ptr<dai::Device> device) { | |
| previewPub->setup(device, convConfig, pubConfig); | ||
| }; | ||
| controlQ = device->getInputQueue(controlQName); | ||
| if(ph->getParam<bool>("i_enable_still")) { | ||
| auto tfPrefix = getOpticalTFPrefix(getSocketName(static_cast<dai::CameraBoardSocket>(ph->getParam<int>("i_board_socket_id")))); | ||
| utils::ImgConverterConfig convConfig; | ||
| convConfig.tfPrefix = tfPrefix; | ||
| convConfig.getBaseDeviceTimestamp = ph->getParam<bool>("i_get_base_device_timestamp"); | ||
| convConfig.updateROSBaseTimeOnRosMsg = ph->getParam<bool>("i_update_ros_base_time_on_ros_msg"); | ||
|
|
||
| utils::ImgPublisherConfig pubConfig; | ||
| pubConfig.daiNodeName = getName(); | ||
| pubConfig.topicName = "~/" + getName(); | ||
| pubConfig.lazyPub = ph->getParam<bool>("i_enable_lazy_publisher"); | ||
| pubConfig.socket = static_cast<dai::CameraBoardSocket>(ph->getParam<int>("i_board_socket_id")); | ||
| pubConfig.calibrationFile = ph->getParam<std::string>("i_calibration_file"); | ||
| pubConfig.rectified = false; | ||
| pubConfig.width = ph->getParam<int>("i_still_width"); | ||
| pubConfig.height = ph->getParam<int>("i_still_height"); | ||
| pubConfig.maxQSize = ph->getParam<int>("i_max_q_size"); | ||
| pubConfig.topicSuffix = "/still/image_raw"; | ||
| pubConfig.flipImage = ph->getParam<bool>("i_flip_published_image"); | ||
|
Comment on lines
+142
to
+146
Author
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. I'm not sure about that. Adding this option would make it so that enabling compression for video output would also enable lossy compression for still output which is often not wanted. |
||
|
|
||
| stillPub->setup(device, convConfig, pubConfig); | ||
|
|
||
| triggerStillService = getROSNode()->create_service<std_srvs::srv::Trigger>( | ||
| "~/" + getName() + "/trigger_still", std::bind(&RGB::triggerStillCB, this, std::placeholders::_1, std::placeholders::_2)); | ||
| }; | ||
| } | ||
|
|
||
| void RGB::closeQueues() { | ||
|
|
@@ -128,6 +157,10 @@ void RGB::closeQueues() { | |
| previewPub->closeQueue(); | ||
| } | ||
| } | ||
| if(ph->getParam<bool>("i_enable_still")) { | ||
| triggerStillService.reset(); | ||
| stillPub->closeQueue(); | ||
| } | ||
| controlQ->close(); | ||
| } | ||
|
|
||
|
|
@@ -156,5 +189,13 @@ void RGB::updateParams(const std::vector<rclcpp::Parameter>& params) { | |
| controlQ->send(ctrl); | ||
| } | ||
|
|
||
| void RGB::triggerStillCB(std_srvs::srv::Trigger::Request::ConstSharedPtr /*req*/, std_srvs::srv::Trigger::Response::SharedPtr res) { | ||
| dai::CameraControl ctrl; | ||
| ctrl.setCaptureStill(true); | ||
| controlQ->send(ctrl); | ||
| res->success = true; | ||
| res->message = "Still capture request sent"; | ||
| } | ||
|
|
||
| } // namespace dai_nodes | ||
| } // namespace depthai_ros_driver | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,6 +125,7 @@ void SensorParamHandler::declareParams(std::shared_ptr<dai::node::ColorCamera> c | |
| colorCam->setBoardSocket(socketID); | ||
| declareAndLogParam<bool>("i_output_isp", true); | ||
| declareAndLogParam<bool>("i_enable_preview", false); | ||
| declareAndLogParam<bool>("i_enable_still", false); | ||
| declareAndLogParam<bool>("i_flip_published_image", false); | ||
| colorCam->setFps(declareAndLogParam<double>("i_fps", 30.0)); | ||
| int preview_size = declareAndLogParam<int>("i_preview_size", 300); | ||
|
|
@@ -175,6 +176,9 @@ void SensorParamHandler::declareParams(std::shared_ptr<dai::node::ColorCamera> c | |
| RCLCPP_ERROR(getROSNode()->get_logger(), "%s", err_stream.str().c_str()); | ||
| } | ||
| } | ||
| int stillWidth = declareAndLogParam<int>("i_still_width", width); | ||
| int stillHeight = declareAndLogParam<int>("i_still_height", height); | ||
| colorCam->setStillSize(stillWidth, stillHeight); | ||
|
Comment on lines
+179
to
+181
Contributor
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. Agreed, still should use the sensor size by default
Author
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. Still resolution cannot be larger than |
||
| int maxVideoWidth = 3840; | ||
| int maxVideoHeight = 2160; | ||
| int videoWidth = declareAndLogParam<int>("i_width", width); | ||
|
|
||
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.
The encoding option has only effect when
i_low_bandwidthis enabled which I purposefully omitted for still output. For raw frames, Image converter always outputs it in BGR color order.