47 "mode_5",
"mode_14",
"mode_15", };
49 "source_3",
"source_software", };
56 else if(str ==
"mode_1")
58 else if(str ==
"mode_2")
60 else if(str ==
"mode_3")
62 else if(str ==
"mode_4")
64 else if(str ==
"mode_5")
66 else if(str ==
"mode_14")
68 else if(str ==
"mode_15")
72 triggerMode_ = (dc1394trigger_mode_t) DC1394_TRIGGER_MODE_NUM;
81 if (str ==
"source_0")
83 else if(str ==
"source_1")
85 else if(str ==
"source_2")
87 else if(str ==
"source_3")
89 else if(str ==
"source_software")
93 triggerSource_ = (dc1394trigger_source_t) DC1394_TRIGGER_SOURCE_NUM;
102 if(str ==
"active_low")
104 else if(str ==
"active_high")
130 dc1394error_t err = dc1394_external_trigger_get_supported_sources(camera, &sources);
131 if (err != DC1394_SUCCESS)
133 ROS_FATAL(
"enumTriggerSources() failed: %d", err);
137 std::ostringstream ss;
140 for(
size_t i = 0; i < sources.num - 1; i++)
161 dc1394trigger_polarity_t current_polarity;
163 dc1394bool_t has_polarity;
164 dc1394error_t err = dc1394_external_trigger_has_polarity(camera, &has_polarity);
165 if (err != DC1394_SUCCESS)
167 ROS_FATAL(
"getPolarity() failed: %d", err);
168 return (dc1394trigger_polarity_t) DC1394_TRIGGER_ACTIVE_NUM;
171 if (has_polarity == DC1394_TRUE)
173 err = dc1394_external_trigger_get_polarity(camera, ¤t_polarity);
174 if (err != DC1394_SUCCESS)
176 ROS_FATAL(
"getPolarity() failed: %d", err);
177 return (dc1394trigger_polarity_t) DC1394_TRIGGER_ACTIVE_NUM;
183 return (dc1394trigger_polarity_t) DC1394_TRIGGER_ACTIVE_NUM;
186 return current_polarity;
198 dc1394trigger_polarity_t current_polarity =
getPolarity(camera);
200 dc1394bool_t has_polarity;
201 dc1394error_t err = dc1394_external_trigger_has_polarity(camera, &has_polarity);
202 if (err != DC1394_SUCCESS)
204 ROS_FATAL(
"setPolarity() failed: %d", err);
208 if (has_polarity == DC1394_TRUE)
211 if(current_polarity == polarity)
return true;
213 err = dc1394_external_trigger_set_polarity(camera, polarity);
214 if (err != DC1394_SUCCESS)
216 polarity = current_polarity;
217 ROS_FATAL(
"setPolarity() failed: %d", err);
238 dc1394switch_t state;
240 dc1394error_t err = dc1394_external_trigger_get_power(camera, &state);
241 if (err != DC1394_SUCCESS)
243 ROS_FATAL(
"getExternalTriggerPowerState() failed: %d", err);
244 return (dc1394switch_t)-1;
262 if(current_state == state)
return true;
264 dc1394error_t err = dc1394_external_trigger_set_power(camera, state);
265 if (err != DC1394_SUCCESS)
267 state = current_state;
268 ROS_FATAL(
"setExternalTriggerPowerState() failed: %d", err);
272 ROS_DEBUG(
"setExternalTriggerPowerState(): %s", (state == DC1394_ON ?
"ON" :
"OFF"));
283 dc1394switch_t state;
285 dc1394error_t err = dc1394_software_trigger_get_power(camera, &state);
286 if (err != DC1394_SUCCESS)
288 ROS_FATAL(
"getSoftwareTriggerPowerState() failed: %d", err);
289 return (dc1394switch_t)-1;
306 if(current_state == state)
return true;
308 dc1394error_t err = dc1394_software_trigger_set_power(camera, state);
309 if (err != DC1394_SUCCESS)
311 state = current_state;
312 ROS_FATAL(
"setSoftwareTriggerPowerState() failed: %d", err);
315 ROS_DEBUG(
"setSoftwareTriggerPowerState(): %s", (state == DC1394_ON ?
"ON" :
"OFF"));
327 dc1394trigger_mode_t mode;
329 dc1394error_t err = dc1394_external_trigger_get_mode(camera, &mode);
330 if (err != DC1394_SUCCESS)
332 ROS_FATAL(
"getTriggerMode() failed: %d", err);
333 return (dc1394trigger_mode_t) DC1394_TRIGGER_MODE_NUM;
348 dc1394trigger_mode_t current_mode =
getMode(camera);
351 if(current_mode == mode)
return true;
353 dc1394error_t err = dc1394_external_trigger_set_mode(camera, mode);
354 if (err != DC1394_SUCCESS)
357 ROS_FATAL(
"setTriggerMode() failed: %d", err);
372 dc1394trigger_source_t source;
374 dc1394error_t err = dc1394_external_trigger_get_source(camera, &source);
375 if (err != DC1394_SUCCESS)
377 ROS_FATAL(
"getTriggerSource() failed: %d", err);
378 return (dc1394trigger_source_t) DC1394_TRIGGER_SOURCE_NUM;
393 dc1394trigger_source_t current_source =
getSource(camera);
396 if(current_source == source)
return true;
398 dc1394error_t err = dc1394_external_trigger_set_source(camera, source);
400 if (err != DC1394_SUCCESS)
402 source = current_source;
403 ROS_FATAL(
"setTriggerSource() failed: %d", err);
424 dc1394switch_t on_off = (dc1394switch_t) newconfig->external_trigger;
427 newconfig->external_trigger = on_off;
428 ROS_ERROR(
"Failed to set external trigger power");
432 on_off = (dc1394switch_t) newconfig->software_trigger;
435 newconfig->software_trigger = on_off;
436 ROS_ERROR(
"Failed to set software trigger power");
466 ROS_ERROR(
"Failed to set trigger source");
478 ROS_DEBUG(
"No triggering sources available");
488 ROS_ERROR(
"Failed to set trigger polarity");
494 ROS_ERROR_STREAM(
"Unknown trigger polarity: " << newconfig->trigger_polarity);
515 ROS_ERROR(
"Failed to enumerate trigger sources");
bool enumSources(dc1394camera_t *camera, dc1394trigger_sources_t &sources)
dc1394trigger_polarity_t triggerPolarity_
dc1394trigger_source_t triggerSource_
static const std::string trigger_source_names_[DC1394_TRIGGER_SOURCE_NUM]
driver parameter names, corresponding to DC1394 trigger sources
bool findTriggerSource(std::string str)
bool findTriggerPolarity(std::string str)
dc1394switch_t externalTriggerPowerState_
const std::string triggerPolarityName(dc1394trigger_polarity_t polarity)
static const std::string trigger_polarity_names_[DC1394_TRIGGER_ACTIVE_NUM]
driver parameter names, corresponding to DC1394 trigger sources
dc1394trigger_sources_t triggerSources_
bool setPolarity(dc1394camera_t *camera, dc1394trigger_polarity_t &polarity)
const std::string triggerModeName(dc1394trigger_mode_t mode)
dc1394switch_t getSoftwareTriggerPowerState(dc1394camera_t *camera)
const std::string triggerSourceName(dc1394trigger_source_t source)
dc1394trigger_polarity_t getPolarity(dc1394camera_t *camera)
dc1394switch_t getExternalTriggerPowerState(dc1394camera_t *camera)
bool setMode(dc1394camera_t *camera, dc1394trigger_mode_t &mode)
bool reconfigure(Config *newconfig)
dc1394trigger_mode_t triggerMode_
static const std::string trigger_mode_names_[DC1394_TRIGGER_MODE_NUM]
driver parameter names, corresponding to DC1394 trigger modes
libdc1394 triggering modes interface
bool initialize(Config *newconfig)
#define ROS_DEBUG_STREAM(args)
bool setExternalTriggerPowerState(dc1394camera_t *camera, dc1394switch_t &state)
bool checkTriggerSource(dc1394trigger_source_t source)
bool findTriggerMode(std::string str)
bool setSoftwareTriggerPowerState(dc1394camera_t *camera, dc1394switch_t &state)
camera1394::Camera1394Config Config
#define ROS_ERROR_STREAM(args)
bool setSource(dc1394camera_t *camera, dc1394trigger_source_t &source)
dc1394trigger_mode_t getMode(dc1394camera_t *camera)
dc1394trigger_source_t getSource(dc1394camera_t *camera)