Skip to content

Commit

Permalink
ros-simulation#408 GetLastMeasurementTime is the time of the image th…
Browse files Browse the repository at this point in the history
…at has triggered the OnNewFrame, therefore it should go into the timestamp. (the OnNewFrame ought to contain the timestamp) There is no purpose to cur_time since the OnNewFrame is never triggered at a higher rate than gazebo sensor- maybe the idea was that a higher rate could be synthesized by sending the same image at the plugin rate even when the sensor rate was lower? Why does updateRate exist at all, it seems likely to cause confusion and be set to a non-zero number (like the same number as update_rate) that will result in skipped frames.
  • Loading branch information
lucasw committed Mar 19, 2016
1 parent a8267ee commit 6372af8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions gazebo_plugins/src/gazebo_ros_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void GazeboRosCamera::OnNewFrame(const unsigned char *_image,
unsigned int _width, unsigned int _height, unsigned int _depth,
const std::string &_format)
{
common::Time sensor_update_time = this->parentSensor_->GetLastUpdateTime();
common::Time sensor_update_time = this->parentSensor_->GetLastMeasurementTime();

if (!this->parentSensor->IsActive())
{
Expand All @@ -88,12 +88,18 @@ void GazeboRosCamera::OnNewFrame(const unsigned char *_image,
{
if ((*this->image_connect_count_) > 0)
{
common::Time cur_time = this->world_->GetSimTime();
if (cur_time - this->last_update_time_ >= this->update_period_)
// OnNewFrame is triggered at the gazebo sensor <update_rate>
// while there is also a plugin <updateRate> that can throttle the
// rate down further (but then why not reduce the sensor rate?
// what is the use case?).
// Setting the <updateRate> to zero will make this plugin
// update at the gazebo sensor <update_rate>, update_period_ will be
// zero and the conditional always will be true.
if (sensor_update_time - this->last_update_time_ >= this->update_period_)
{
this->PutCameraData(_image, sensor_update_time);
this->PublishCameraInfo(sensor_update_time);
this->last_update_time_ = cur_time;
this->last_update_time_ = sensor_update_time;
}
}
}
Expand Down

0 comments on commit 6372af8

Please sign in to comment.