Skip to content

Commit

Permalink
Merge pull request #5 from mitchellwills/fixedrate
Browse files Browse the repository at this point in the history
Added support for fixedrate mode
  • Loading branch information
ahendrix committed Mar 4, 2014
2 parents ff5b38d + cd3ccd7 commit 0e52dc8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion prosilica_camera/cfg/ProsilicaCamera.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ gen = ParameterGenerator()

mode_enum = gen.enum( [ gen.const("StreamingMode", str_t, "streaming", "Run at maximum frame rate"),
gen.const("PolledMode", str_t, "polled", "Capture frame in response to service call"),
#gen.const("FixedRateMode", str_t, "fixedrate", "Fixed Rate mode"),
gen.const("FixedRateMode", str_t, "fixedrate", "Fixed Rate mode"),
gen.const("External1Mode", str_t, "syncin1", "External trigger on SyncIn1 line"),
gen.const("External2Mode", str_t, "syncin2", "External trigger on SyncIn2 line") ],
"Enum to set the trigger mode")
Expand Down
1 change: 1 addition & 0 deletions prosilica_camera/include/prosilica/prosilica.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class Camera

//! Must be used before calling start() in a non-triggered mode.
void setFrameCallback(boost::function<void (tPvFrame*)> callback);
void setFrameRate(tPvFloat32 frame_rate);
//! Start capture.
void start(FrameStartTriggerMode = Freerun, AcquisitionMode = Continuous);
//! Stop capture.
Expand Down
10 changes: 8 additions & 2 deletions prosilica_camera/src/libprosilica/prosilica.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,22 @@ void Camera::setFrameCallback(boost::function<void (tPvFrame*)> callback)
userCallback_ = callback;
}

void Camera::setFrameRate(tPvFloat32 frame_rate){
CHECK_ERR( PvAttrFloat32Set(handle_, "FrameRate", frame_rate),
"Could not set frame rate");
}


void Camera::start(FrameStartTriggerMode fmode, AcquisitionMode amode)
{
assert( FSTmode_ == None && fmode != None );
///@todo verify this assert again
assert( fmode == SyncIn1 || fmode == SyncIn2 || fmode == Software || !userCallback_.empty() );
assert( fmode == SyncIn1 || fmode == SyncIn2 || fmode == Software || fmode == FixedRate || !userCallback_.empty() );

// set camera in acquisition mode
CHECK_ERR( PvCaptureStart(handle_), "Could not start capture");

if (fmode == Freerun || fmode == SyncIn1 || fmode == SyncIn2)
if (fmode == Freerun || fmode == FixedRate || fmode == SyncIn1 || fmode == SyncIn2)
for (unsigned int i = 0; i < bufferSize_; ++i)
PvCaptureQueueFrame(handle_, frames_ + i, Camera::frameDone);

Expand Down
11 changes: 5 additions & 6 deletions prosilica_camera/src/nodes/prosilica_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,11 @@ class ProsilicaNode
trigger_mode_ = prosilica::SyncIn2;
desired_freq_ = config.trig_rate;
}
#if 0
else if (config.trigger_mode == "fixedrate") {
ROS_DEBUG("Fixed rate not supported yet implementing software");
trigger_mode_ = prosilica::Software;
///@todo add the fixed rate implementation
desired_freq_ = 0;
trigger_mode_ = prosilica::FixedRate;
desired_freq_ = config.trig_rate;
cam_->setFrameRate(desired_freq_);
}
#endif
else if (config.trigger_mode == "polled") {
trigger_mode_ = prosilica::Software;
desired_freq_ = 0;
Expand Down Expand Up @@ -365,6 +362,8 @@ class ProsilicaNode
if (!trig_timestamp_topic_.empty())
trigger_sub_ = nh_.subscribe(trig_timestamp_topic_, 1, &ProsilicaNode::syncInCallback, this);
}
else if (trigger_mode_ == prosilica::FixedRate){
}
else {
assert(trigger_mode_ == prosilica::Freerun);
}
Expand Down

0 comments on commit 0e52dc8

Please sign in to comment.