Skip to content
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

Added support for fixedrate mode #5

Merged
merged 3 commits into from
Mar 4, 2014
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
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It it not entirely obvious that the user should set the parameter described as "External triggering rate" when in fixed-rate mode.

What are your thoughts on adding another parameter which is explicitly the frame rate for fixed rate mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like a second parameter might be more confusing, especially when not using fixed rate mode. The description of trigger rate could be adjusted to make clear the meaning of this value in fixed rate mode

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