Skip to content

Commit

Permalink
Merge branch 'add_custom_res' into 'master'
Browse files Browse the repository at this point in the history
Add general.pub_downscale_factor param

See merge request sl/zed-ros2-wrapper!27
  • Loading branch information
Myzhar committed Aug 2, 2023
2 parents 8cc2c68 + 91dacb1 commit d4ac4a6
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 75 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
LATEST CHANGES
==============

2023-08-02
----------
- The parameter `general.pub_resolution` can now take only `NATIVE` and `CUSTOM` values. 'NATIVE' to use the same `general.grab_resolution` - `CUSTOM` to apply the `general.pub_downscale_factor` downscale factory to reduce bandwidth in transmission
- Add new parameter `general.pub_downscale_factor` to be used with the new option `CUSTOM` for the parameter `general.pub_resolution`
- `ULTRA` is the new default value for `depth.depth_mode` (better performance for odometry and positional tracking)
- Add resolution `HD1080` for ZED X

2023-07-31
----------
- Fix issue with Body Tracking start/stop by service call. Now Body Tracking can be restarted multiple times
Expand Down
10 changes: 2 additions & 8 deletions zed_components/src/zed_camera/include/sl_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,8 @@ typedef rclcpp::Service<robot_localization::srv::FromLL>::SharedPtr fromLLSrvPtr
*/
typedef enum
{
HD2K, //!< 2208x1242
HD1080, //!< 1920x1080
HD1200, //!< 1920x1200
HD720, //!< 1280x720
MEDIUM, //!< 896x512
SVGA, //!< 960x600
VGA, //!< 672x376
LOW //!< Half-MEDIUM 448x256
NATIVE, //!< Same camera grab resolution
CUSTOM //!< Custom Rescale Factor
} PubRes;
// <---- Typedefs to simplify declarations
} // namespace stereolabs
Expand Down
10 changes: 5 additions & 5 deletions zed_components/src/zed_camera/include/zed_camera_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,11 @@ class ZedCamera : public rclcpp::Node
bool mSvoRealtime = false;
int mVerbose = 1;
int mGpuId = -1;
sl::RESOLUTION mCamResol = sl::RESOLUTION::HD720; // Default resolution: RESOLUTION_HD720
PubRes mPubResolution = MEDIUM; // Use native DNN resolution for NEURAL depth to improve speed and quality.
sl::DEPTH_MODE mDepthMode = sl::DEPTH_MODE::PERFORMANCE; // Default depth mode: DEPTH_MODE_PERFORMANCE
bool mDepthDisabled =
false; // Indicates if depth calculation is not required (DEPTH_MODE::NONE se for )
sl::RESOLUTION mCamResol = sl::RESOLUTION::HD1080; // Default resolution: RESOLUTION_HD1080
PubRes mPubResolution = PubRes::NATIVE; // Use native grab resolution by default
double mCustomDownscaleFactor = 1.0; // Used to rescale data with user factor
sl::DEPTH_MODE mDepthMode = sl::DEPTH_MODE::ULTRA; // Default depth mode: ULTRA
bool mDepthDisabled = false; // Indicates if depth calculation is not required (DEPTH_MODE::NONE)
int mDepthStabilization = 1;
std::vector<std::vector<float>> mRoiParam;
int mCamTimeoutSec = 5;
Expand Down
78 changes: 22 additions & 56 deletions zed_components/src/zed_camera/src/zed_camera_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ using namespace std::placeholders;
// Used for simulation data input
#define ZED_SDK_PORT 30000

// Custom output resolution
#define MEDIUM_W 896
#define MEDIUM_H 512

namespace stereolabs
{
#ifndef DEG2RAD
Expand Down Expand Up @@ -630,14 +626,15 @@ void ZedCamera::getGeneralParams()

// TODO(walter) ADD SVO SAVE COMPRESSION PARAMETERS

std::string resol = "HD720";
std::string resol = "AUTO";
getParam("general.grab_resolution", resol, resol);
if (resol == "AUTO") {
mCamResol = sl::RESOLUTION::AUTO;
} else if (sl_tools::isZEDX(mCamUserModel)) {
// TODO(Walter) Add support for HD1080 when available
if (resol == "HD1200") {
mCamResol = sl::RESOLUTION::HD1200;
} else if (resol == "HD1080") {
mCamResol = sl::RESOLUTION::HD1080;
} else if (resol == "SVGA") {
mCamResol = sl::RESOLUTION::SVGA;
} else {
Expand Down Expand Up @@ -669,29 +666,27 @@ void ZedCamera::getGeneralParams()

std::string out_resol = "MEDIUM";
getParam("general.pub_resolution", out_resol, out_resol);
if (out_resol == "HD2K") {
mPubResolution = PubRes::HD2K;
} else if (out_resol == "HD1080") {
mPubResolution = PubRes::HD1080;
} else if (out_resol == "HD1200") {
mPubResolution = PubRes::HD1200;
} else if (out_resol == "HD720") {
mPubResolution = PubRes::HD720;
} else if (out_resol == "SVGA") {
mPubResolution = PubRes::SVGA;
} else if (out_resol == "VGA") {
mPubResolution = PubRes::VGA;
} else if (out_resol == "MEDIUM") {
mPubResolution = PubRes::MEDIUM;
} else if (out_resol == "LOW") {
mPubResolution = PubRes::LOW;
if (out_resol == "NATIVE") {
mPubResolution = PubRes::NATIVE;
} else if (out_resol == "CUSTOM") {
mPubResolution = PubRes::CUSTOM;
} else {
RCLCPP_INFO(get_logger(), "Not valid 'general.pub_resolution' value. Using default setting.");
out_resol = "MEDIUM";
mPubResolution = PubRes::MEDIUM;
RCLCPP_WARN(
get_logger(), "Not valid 'general.pub_resolution' value: '%s'. Using default setting instead.",
out_resol.c_str());
out_resol = "NATIVE";
mPubResolution = PubRes::NATIVE;
}
RCLCPP_INFO_STREAM(get_logger(), " * Publishing resolution: " << out_resol.c_str());

if (mPubResolution == PubRes::CUSTOM) {
getParam(
"general.pub_downscale_factor", mCustomDownscaleFactor, mCustomDownscaleFactor,
" * Publishing downscale factor: ");
} else {
mCustomDownscaleFactor = 1.0;
}

std::string parsed_str = getParam("general.region_of_interest", mRoiParam);
RCLCPP_INFO_STREAM(get_logger(), " * Region of interest: " << parsed_str.c_str());

Expand Down Expand Up @@ -3478,37 +3473,8 @@ bool ZedCamera::startCamera()
get_logger(), " * Camera grab frame size -> " << mCamWidth << "x" << mCamHeight);

int pub_w, pub_h;
switch (mPubResolution) {
case PubRes::HD2K:
pub_w = sl::getResolution(sl::RESOLUTION::HD2K).width;
pub_h = sl::getResolution(sl::RESOLUTION::HD2K).height;
break;

case PubRes::HD1080:
pub_w = sl::getResolution(sl::RESOLUTION::HD1080).width;
pub_h = sl::getResolution(sl::RESOLUTION::HD1080).height;
break;

case PubRes::HD720:
pub_w = sl::getResolution(sl::RESOLUTION::HD720).width;
pub_h = sl::getResolution(sl::RESOLUTION::HD720).height;
break;

case PubRes::MEDIUM:
pub_w = MEDIUM_W;
pub_h = MEDIUM_H;
break;

case PubRes::VGA:
pub_w = sl::getResolution(sl::RESOLUTION::VGA).width;
pub_h = sl::getResolution(sl::RESOLUTION::VGA).height;
break;

case PubRes::LOW:
pub_w = MEDIUM_W / 2;
pub_h = MEDIUM_H / 2;
break;
}
pub_w = static_cast<int>(std::round(mCamWidth / mCustomDownscaleFactor));
pub_h = static_cast<int>(std::round(mCamHeight / mCustomDownscaleFactor));

if (pub_w > mCamWidth || pub_h > mCamHeight) {
RCLCPP_WARN_STREAM(
Expand Down
5 changes: 3 additions & 2 deletions zed_wrapper/config/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
camera_flip: false
zed_id: 0 # IMPORTANT: to be used in simulation to distinguish individual cameras im multi-camera configurations - usually overwritten by launch file
serial_number: 0 # usually overwritten by launch file
pub_resolution: 'MEDIUM' # The resolution used for output. 'HD2K', 'HD1080', 'HD1200', 'HD720', 'MEDIUM', 'SVGA', 'VGA', 'LOW'
pub_resolution: 'CUSTOM' # The resolution used for output. 'NATIVE' to use the same `general.grab_resolution` - `CUSTOM` to apply the `general.pub_downscale_factor` downscale factory to reduce bandwidth in transmission
pub_downscale_factor: 2.0 # rescale factor used to rescale image before publishing when 'pub_resolution' is 'CUSTOM'
pub_frame_rate: 15.0 # [DYNAMIC] - frequency of publishing of visual images and depth images
gpu_id: -1
region_of_interest: '[]' # A polygon defining the ROI where the ZED SDK perform the processing ignoring the rest. Coordinates must be normalized to '1.0' to be resolution independent.
Expand All @@ -42,7 +43,7 @@
qos_durability: 2 # '1': TRANSIENT_LOCAL - '2': VOLATILE

depth:
depth_mode: 'NEURAL' # Matches the ZED SDK setting: 'NONE', 'PERFORMANCE', 'QUALITY', 'ULTRA', 'NEURAL' - Note: if 'NONE' all the modules that requires depth extraction are disabled by default (Pos. Tracking, Obj. Detection, Mapping, ...)
depth_mode: 'ULTRA' # Matches the ZED SDK setting: 'NONE', 'PERFORMANCE', 'QUALITY', 'ULTRA', 'NEURAL' - Note: if 'NONE' all the modules that requires depth extraction are disabled by default (Pos. Tracking, Obj. Detection, Mapping, ...)
depth_stabilization: 1 # Forces positional tracking to start if major than 0 - Range: [0,100]
openni_depth_mode: false # 'false': 32bit float [meters], 'true': 16bit unsigned int [millimeters]
point_cloud_freq: 10.0 # [DYNAMIC] - frequency of the pointcloud publishing (equal or less to `grab_frame_rate` value)
Expand Down
4 changes: 2 additions & 2 deletions zed_wrapper/config/zedx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
general:
camera_model: "zedx"
camera_name: "zedx" # usually overwritten by launch file
grab_resolution: 'HD1200' # The native camera grab resolution. 'HD1200', 'SVGA', 'AUTO'
grab_frame_rate: 30 # ZED SDK internal grabbing rate (HD1200: 60 or 30 - SVGA: 120 or 60)
grab_resolution: 'HD1200' # The native camera grab resolution. 'HD1200', 'HD1080', 'SVGA', 'AUTO'
grab_frame_rate: 30 # ZED SDK internal grabbing rate (HD1200/HD1080: 60, 30, 15 - SVGA: 120, 60, 30, 15)

video:
exposure_time: 16000 # Defines the real exposure time in microseconds. Recommended to control manual exposure (instead of `video.exposure` setting)
Expand Down
4 changes: 2 additions & 2 deletions zed_wrapper/config/zedxm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
general:
camera_model: "zedxm"
camera_name: "zedxm" # usually overwritten by launch file
grab_resolution: 'HD1200' # The native camera grab resolution. 'HD1200', 'SVGA', 'AUTO'
grab_frame_rate: 30 # ZED SDK internal grabbing rate (HD1200: 60 or 30 - SVGA: 120 or 60)
grab_resolution: 'HD1200' # The native camera grab resolution. 'HD1200', 'HD1080', 'SVGA', 'AUTO'
grab_frame_rate: 30 # ZED SDK internal grabbing rate (HD1200/HD1080: 60, 30, 15 - SVGA: 120, 60, 30, 15)

video:
exposure_time: 16666 # Defines the real exposure time in microseconds. Recommended to control manual exposure (instead of `video.exposure` setting)
Expand Down

0 comments on commit d4ac4a6

Please sign in to comment.