Skip to content
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
3 changes: 3 additions & 0 deletions cfg/Zed.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ from dynamic_reconfigure.parameter_generator_catkin import *
gen = ParameterGenerator()

gen.add("confidence", int_t, 0, "Confidence threshold, the lower the better", 80, 1, 100)
gen.add("exposure", int_t, 1, "Exposure value when manual controlled", 100, 0, 100);
gen.add("gain", int_t, 2, "Gain value when manual controlled", 50, 0, 100);
gen.add("auto_exposure", bool_t, 3, "Enable/Disable auto control of exposure and gain", True);

exit(gen.generate(PACKAGE, "zed_wrapper", "Zed"))
3 changes: 3 additions & 0 deletions launch/zed_camera.launch
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<param name="openni_depth_mode" value="0" />
<param name="gpu_id" value="$(arg gpu_id)" />
<param name="confidence" value="100" />
<param name="gain" value="100" />
<param name="exposure" value="100" />
<param name="auto_exposure" value="true" />
<param name="depth_stabilization" value="1" />

<!-- ROS topic names -->
Expand Down
51 changes: 47 additions & 4 deletions src/zed_wrapper_nodelet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ namespace zed_wrapper {

// flags
int confidence;
int exposure;
int gain;
bool autoExposure;
bool triggerAutoExposure;
bool computeDepth;
bool grabbing = false;
int openniDepthMode = 0; // 16 bit UC data in mm else 32F in m, for more info http://www.ros.org/reps/rep-0118.html
Expand Down Expand Up @@ -483,8 +487,26 @@ namespace zed_wrapper {
}

void callback(zed_wrapper::ZedConfig &config, uint32_t level) {
NODELET_INFO("Reconfigure confidence : %d", config.confidence);
confidence = config.confidence;
switch (level) {
case 0:
NODELET_INFO("Reconfigure confidence : %d", config.confidence);
confidence = config.confidence;
break;
case 1:
NODELET_INFO("Reconfigure exposure : %d", config.exposure);
exposure = config.exposure;
break;
case 2:
NODELET_INFO("Reconfigure gain : %d", config.gain);
gain = config.gain;
break;
case 3:
NODELET_INFO("Reconfigure auto control of exposure and gain : %s", config.auto_exposure ? "Enable" : "Disable");
autoExposure = config.auto_exposure;
if (autoExposure)
triggerAutoExposure = true;
break;
}
}

void device_poll() {
Expand Down Expand Up @@ -608,6 +630,23 @@ namespace zed_wrapper {

old_t = ros::Time::now();

if (autoExposure) {
// getCameraSettings() can't check status of auto exposure
// triggerAutoExposure is used to execute setCameraSettings() only once
if (triggerAutoExposure) {
zed.setCameraSettings(sl::CAMERA_SETTINGS_EXPOSURE, 0, true);
triggerAutoExposure = false;
}
} else {
int actual_exposure = zed.getCameraSettings(sl::CAMERA_SETTINGS_EXPOSURE);
if (actual_exposure != exposure)
zed.setCameraSettings(sl::CAMERA_SETTINGS_EXPOSURE, exposure);

int actual_gain = zed.getCameraSettings(sl::CAMERA_SETTINGS_GAIN);
if (actual_gain != gain)
zed.setCameraSettings(sl::CAMERA_SETTINGS_GAIN, gain);
}

// Publish the left == rgb image if someone has subscribed to
if (left_SubNumber > 0 || rgb_SubNumber > 0) {
// Retrieve RGBA Left image
Expand Down Expand Up @@ -891,14 +930,18 @@ namespace zed_wrapper {

serial_number = zed.getCameraInformation().serial_number;

//Reconfigure confidence
//Reconfigure parameters
server = boost::make_shared<dynamic_reconfigure::Server < zed_wrapper::ZedConfig >> ();
dynamic_reconfigure::Server<zed_wrapper::ZedConfig>::CallbackType f;
f = boost::bind(&ZEDWrapperNodelet::callback, this, _1, _2);
server->setCallback(f);

nh_ns.getParam("confidence", confidence);

nh_ns.getParam("exposure", exposure);
nh_ns.getParam("gain", gain);
nh_ns.getParam("auto_exposure", autoExposure);
if (autoExposure)
triggerAutoExposure = true;

// Create all the publishers
// Image publishers
Expand Down