|
From: <gb...@us...> - 2010-08-16 01:36:50
|
Revision: 512
http://gearbox.svn.sourceforge.net/gearbox/?rev=512&view=rev
Author: gbiggs
Date: 2010-08-16 01:36:43 +0000 (Mon, 16 Aug 2010)
Log Message:
-----------
Changed data pointer to reference
Modified Paths:
--------------
gearbox/trunk/src/hokuyo_aist/sensor.cpp
gearbox/trunk/src/hokuyo_aist/sensor.h
gearbox/trunk/src/hokuyo_aist/test/example.cpp
Modified: gearbox/trunk/src/hokuyo_aist/sensor.cpp
===================================================================
--- gearbox/trunk/src/hokuyo_aist/sensor.cpp 2010-08-11 00:49:53 UTC (rev 511)
+++ gearbox/trunk/src/hokuyo_aist/sensor.cpp 2010-08-16 01:36:43 UTC (rev 512)
@@ -939,12 +939,9 @@
}
-unsigned int Sensor::get_ranges(ScanData* data, int start_step,
+unsigned int Sensor::get_ranges(ScanData& data, int start_step,
int end_step, unsigned int cluster_count)
{
- if(data == 0)
- throw NoDestinationError();
-
char buffer[11];
memset(buffer, 0, sizeof(char) * 11);
@@ -989,9 +986,9 @@
// timestamp back if there was no data.
if(read_line_with_check_(buffer) == 0)
throw NoDataError();
- data->laser_time_ = decode_4_byte_value(buffer) +
+ data.laser_time_ = decode_4_byte_value(buffer) +
step_to_time_offset_(start_step);
- data->system_time_ = offset_timestamp_(wrap_timestamp_(data->laser_time_));
+ data.system_time_ = offset_timestamp_(wrap_timestamp_(data.laser_time_));
// In SCIP2 mode we're going to get back 3-byte data because we're
// sending the GD command
read_3_byte_range_data_(data, num_steps);
@@ -999,16 +996,13 @@
else
throw UnknownScipVersionError();
- return data->ranges_length_;
+ return data.ranges_length_;
}
-unsigned int Sensor::get_ranges_by_angle(ScanData* data, double start_angle,
+unsigned int Sensor::get_ranges_by_angle(ScanData& data, double start_angle,
double end_angle, unsigned int cluster_count)
{
- if(data == 0)
- throw NoDataError();
-
// Calculate the given angles in steps, rounding towards front_step_
int start_step, end_step;
start_step = angle_to_step(start_angle);
@@ -1032,12 +1026,9 @@
}
-unsigned int Sensor::get_ranges_intensities(ScanData* data, int start_step,
+unsigned int Sensor::get_ranges_intensities(ScanData& data, int start_step,
int end_step, unsigned int cluster_count)
{
- if(data == 0)
- throw NoDestinationError();
-
char buffer[11];
memset(buffer, 0, sizeof(char) * 11);
@@ -1074,23 +1065,20 @@
// timestamp back if there was no data.
if(read_line_with_check_(buffer) == 0)
throw NoDataError();
- data->laser_time_ = decode_4_byte_value(buffer) +
+ data.laser_time_ = decode_4_byte_value(buffer) +
step_to_time_offset_(start_step);
- data->system_time_ = offset_timestamp_(wrap_timestamp_(data->laser_time_));
+ data.system_time_ = offset_timestamp_(wrap_timestamp_(data.laser_time_));
// In SCIP2 mode we're going to get back 3-byte data because we're
// sending the GE command
read_3_byte_range_data_(data, num_steps);
- return data->ranges_length_;
+ return data.ranges_length_;
}
-unsigned int Sensor::get_ranges_intensities_by_angle(ScanData* data,
+unsigned int Sensor::get_ranges_intensities_by_angle(ScanData& data,
double start_angle, double end_angle, unsigned int cluster_count)
{
- if(data == 0)
- throw NoDataError();
-
// Calculate the given angles in steps, rounding towards front_step_
int start_step, end_step;
start_step = angle_to_step(start_angle);
@@ -1114,12 +1102,9 @@
}
-unsigned int Sensor::get_new_ranges(ScanData* data, int start_step,
+unsigned int Sensor::get_new_ranges(ScanData& data, int start_step,
int end_step, unsigned int cluster_count)
{
- if(data == 0)
- throw NoDestinationError();
-
if(scip_version_ == 1)
throw UnsupportedError(16);
else if(scip_version_ != 2)
@@ -1192,22 +1177,20 @@
// timestamp back if there was no data.
if(read_line_with_check_(buffer) == 0)
throw NoDataError();
- data->laser_time_ = decode_4_byte_value(buffer) +
+ data.laser_time_ = decode_4_byte_value(buffer) +
step_to_time_offset_(start_step);
- data->system_time_ = offset_timestamp_(wrap_timestamp_(data->laser_time_));
+ data.system_time_ = offset_timestamp_(wrap_timestamp_(data.laser_time_));
// In SCIP2 mode we're going to get back 3-byte data because we're
// sending the MD command
read_3_byte_range_data_(data, num_steps);
- return data->ranges_length_;
+ return data.ranges_length_;
}
-unsigned int Sensor::get_new_ranges_by_angle(ScanData* data,
+unsigned int Sensor::get_new_ranges_by_angle(ScanData& data,
double start_angle, double end_angle, unsigned int cluster_count)
{
- if(data == 0)
- throw NoDestinationError();
if(scip_version_ == 1)
throw UnsupportedError(16);
@@ -1234,12 +1217,9 @@
}
-unsigned int Sensor::get_new_ranges_intensities(ScanData* data,
+unsigned int Sensor::get_new_ranges_intensities(ScanData& data,
int start_step, int end_step, unsigned int cluster_count)
{
- if(data == 0)
- throw NoDestinationError();
-
if(scip_version_ == 1)
throw UnsupportedError(17);
else if(scip_version_ != 2)
@@ -1313,22 +1293,20 @@
// timestamp back if there was no data.
if(read_line_with_check_(buffer) == 0)
throw NoDataError();
- data->laser_time_ = decode_4_byte_value(buffer) +
+ data.laser_time_ = decode_4_byte_value(buffer) +
step_to_time_offset_(start_step);
- data->system_time_ = offset_timestamp_(wrap_timestamp_(data->laser_time_));
+ data.system_time_ = offset_timestamp_(wrap_timestamp_(data.laser_time_));
// In SCIP2 mode we're going to get back 3-byte data because we're
// sending the ME command
read_3_byte_range_and_intensity_data_(data, num_steps);
- return data->ranges_length_;
+ return data.ranges_length_;
}
-unsigned int Sensor::get_new_ranges_intensities_by_angle(ScanData* data,
+unsigned int Sensor::get_new_ranges_intensities_by_angle(ScanData& data,
double start_angle, double end_angle, unsigned int cluster_count)
{
- if(data == 0)
- throw NoDestinationError();
if(scip_version_ == 1)
throw UnsupportedError(17);
@@ -2147,7 +2125,7 @@
}
-void Sensor::read_2_byte_range_data_(ScanData* data, unsigned int num_steps)
+void Sensor::read_2_byte_range_data_(ScanData& data, unsigned int num_steps)
{
if(verbose_)
{
@@ -2157,9 +2135,9 @@
// This will automatically take care of whether it actually needs to
// (re)allocate or not.
- data->allocate_data(num_steps);
- data->model_ = model_;
- data->error_ = false;
+ data.allocate_data(num_steps);
+ data.model_ = model_;
+ data.error_ = false;
// 2 byte data is easy since it fits neatly in a 64-byte block
char buffer[SCIP2_LINE_LENGTH];
@@ -2180,7 +2158,7 @@
// Line feed in the middle of a data block? Why?
throw MisplacedLineFeedError();
}
- data->write_range_(current_step, decode_2_byte_value(&buffer[ii]));
+ data.write_range_(current_step, decode_2_byte_value(&buffer[ii]));
}
// End of this line. Go around again.
}
@@ -2193,7 +2171,7 @@
}
-void Sensor::read_3_byte_range_data_(ScanData* data, unsigned int num_steps)
+void Sensor::read_3_byte_range_data_(ScanData& data, unsigned int num_steps)
{
if(verbose_)
{
@@ -2209,9 +2187,9 @@
// This will automatically take care of whether it actually needs to
// (re)allocate or not.
- data->allocate_data(num_steps);
- data->model_ = model_;
- data->error_ = false;
+ data.allocate_data(num_steps);
+ data.model_ = model_;
+ data.error_ = false;
// 3 byte data is a pain because it crosses the line boundary, it may
// overlap by 0, 1 or 2 bytes
@@ -2231,16 +2209,16 @@
if(echo_buffer[0] != -1)
{
// Not the first value, so deal with the previous
- data->write_range_(current_step,
+ data.write_range_(current_step,
process_echo_buffer_(echo_buffer, echo_buf_ind + 1));
- if(data->ranges_)
+ if(data.ranges_)
{
- if(data->ranges_[current_step] > max_range_)
+ if(data.ranges_[current_step] > max_range_)
{
err_output_ << "WARNING: Sensor::" << __func__ <<
"() Value at step " << current_step <<
" beyond maximum range: " <<
- data->ranges_[current_step];
+ data.ranges_[current_step];
}
}
current_step++;
@@ -2269,17 +2247,17 @@
else if(echo_buffer[0] != -1)
{
// Not the first value, so deal with the previous
- data->write_range_(current_step,
+ data.write_range_(current_step,
process_echo_buffer_(echo_buffer,
echo_buf_ind + 1));
- if(data->ranges_)
+ if(data.ranges_)
{
- if(data->ranges_[current_step] > max_range_)
+ if(data.ranges_[current_step] > max_range_)
{
err_output_ << "WARNING: Sensor::" << __func__ <<
"() Value at step " << current_step <<
" beyond maximum range: " <<
- data->ranges_[current_step];
+ data.ranges_[current_step];
}
}
current_step++;
@@ -2337,7 +2315,7 @@
}
-void Sensor::read_3_byte_range_and_intensity_data_(ScanData* data,
+void Sensor::read_3_byte_range_and_intensity_data_(ScanData& data,
unsigned int num_steps)
{
if(verbose_)
@@ -2354,8 +2332,8 @@
// This will automatically take care of whether it actually needs to
// (re)allocate or not.
- data->allocate_data(num_steps, true);
- data->model_ = model_;
+ data.allocate_data(num_steps, true);
+ data.model_ = model_;
// 3 byte data is a pain because it crosses the line boundary, it may
// overlap by 0, 1 or 2 bytes
@@ -2379,7 +2357,7 @@
if(echo_buffer[0] != -1)
{
assert(nextIsIntensity == true);
- data->write_intensity_(current_intensity,
+ data.write_intensity_(current_intensity,
process_echo_buffer_(echo_buffer, echo_buf_ind + 1));
current_intensity++;
}
@@ -2409,27 +2387,27 @@
// Not the first value, so deal with the previous
if(nextIsIntensity)
{
- data->write_intensity_(current_intensity,
+ data.write_intensity_(current_intensity,
process_echo_buffer_(echo_buffer,
echo_buf_ind + 1));
}
else
{
- data->write_range_(current_range,
+ data.write_range_(current_range,
process_echo_buffer_(echo_buffer,
echo_buf_ind + 1));
}
echo_buf_ind = 0;
echo_buffer[0] = -1;
- if(data->ranges_)
+ if(data.ranges_)
{
- if(data->ranges_[current_range] > max_range_ &&
+ if(data.ranges_[current_range] > max_range_ &&
!nextIsIntensity)
{
err_output_ << "WARNING: Sensor::" << __func__ <<
"() Value at step " << current_range <<
" beyond maximum range: " <<
- data->ranges_[current_range] << " (raw bytes: ";
+ data.ranges_[current_range] << " (raw bytes: ";
if(split_count != 0)
err_output_ << split_value[0] << split_value[1] <<
split_value[2] << ")\n";
Modified: gearbox/trunk/src/hokuyo_aist/sensor.h
===================================================================
--- gearbox/trunk/src/hokuyo_aist/sensor.h 2010-08-11 00:49:53 UTC (rev 511)
+++ gearbox/trunk/src/hokuyo_aist/sensor.h 2010-08-16 01:36:43 UTC (rev 512)
@@ -296,7 +296,7 @@
@param end_step The last step to get ranges from. Set to -1 for the last
scannable step.
@return The number of range readings read into @ref data. */
- unsigned int get_ranges(ScanData* data, int start_step = -1,
+ unsigned int get_ranges(ScanData& data, int start_step = -1,
int end_step = -1, unsigned int cluster_count = 1);
/** @brief Get the latest scan data from the scanner.
@@ -313,7 +313,7 @@
single reading. The minimum value from a cluster is returned as the
range for that cluster.
@return The number of range readings read into @ref data. */
- unsigned int get_ranges_by_angle(ScanData* data, double start_angle,
+ unsigned int get_ranges_by_angle(ScanData& data, double start_angle,
double end_angle, unsigned int cluster_count = 1);
/** @brief Get the latest scan data from the scanner with intensities.
@@ -338,7 +338,7 @@
@param end_step The last step to get ranges from. Set to -1 for the last
scannable step.
@return The number of range readings read into @ref data. */
- unsigned int get_ranges_intensities(ScanData* data,
+ unsigned int get_ranges_intensities(ScanData& data,
int start_step = -1, int end_step = -1,
unsigned int cluster_count = 1);
@@ -356,7 +356,7 @@
single reading. The minimum value from a cluster is returned as the
range for that cluster.
@return The number of range readings read into @ref data. */
- unsigned int get_ranges_intensities_by_angle(ScanData* data,
+ unsigned int get_ranges_intensities_by_angle(ScanData& data,
double start_angle, double end_angle,
unsigned int cluster_count = 1);
@@ -388,7 +388,7 @@
@param end_step The last step to get ranges from. Set to -1 for the last
scannable step.
@return The number of range readings read into @ref data. */
- unsigned int get_new_ranges(ScanData* data, int start_step = -1,
+ unsigned int get_new_ranges(ScanData& data, int start_step = -1,
int end_step = -1, unsigned int cluster_count = 1);
/** @brief Get a new scan from the scanner.
@@ -407,7 +407,7 @@
single reading. The minimum value from a cluster is returned as the
range for that cluster.
@return The number of range readings read into @ref data. */
- unsigned int get_new_ranges_by_angle(ScanData* data,
+ unsigned int get_new_ranges_by_angle(ScanData& data,
double start_angle, double end_angle,
unsigned int cluster_count = 1);
@@ -438,7 +438,7 @@
@param end_step The last step to get ranges from. Set to -1 for the last
scannable step.
@return The number of range readings read into @ref data. */
- unsigned int get_new_ranges_intensities(ScanData* data,
+ unsigned int get_new_ranges_intensities(ScanData& data,
int start_step = -1, int end_step = -1,
unsigned int cluster_count = 1);
@@ -458,7 +458,7 @@
single reading. The minimum value from a cluster is returned as the
range for that cluster.
@return The number of range readings read into @ref data. */
- unsigned int get_new_ranges_intensities_by_angle(ScanData* data,
+ unsigned int get_new_ranges_intensities_by_angle(ScanData& data,
double start_angle, double end_angle,
unsigned int cluster_count = 1);
@@ -542,9 +542,9 @@
void process_ii_line_(char const* buffer, SensorInfo* info);
uint32_t process_echo_buffer_(int const* buffer, int num_echos);
- void read_2_byte_range_data_(ScanData* data, unsigned int num_steps);
- void read_3_byte_range_data_(ScanData* data, unsigned int num_steps);
- void read_3_byte_range_and_intensity_data_(ScanData* data,
+ void read_2_byte_range_data_(ScanData& data, unsigned int num_steps);
+ void read_3_byte_range_data_(ScanData& data, unsigned int num_steps);
+ void read_3_byte_range_and_intensity_data_(ScanData& data,
unsigned int num_steps);
int confirm_checksum_(char const* buffer, int length,
Modified: gearbox/trunk/src/hokuyo_aist/test/example.cpp
===================================================================
--- gearbox/trunk/src/hokuyo_aist/test/example.cpp 2010-08-11 00:49:53 UTC (rev 511)
+++ gearbox/trunk/src/hokuyo_aist/test/example.cpp 2010-08-16 01:36:43 UTC (rev 512)
@@ -181,35 +181,35 @@
{
// Get all ranges
if(get_new)
- laser.get_new_ranges(&data, -1, -1, cluster_count);
+ laser.get_new_ranges(data, -1, -1, cluster_count);
else if(get_intensities)
- laser.get_new_ranges_intensities(&data, -1, -1, cluster_count);
+ laser.get_new_ranges_intensities(data, -1, -1, cluster_count);
else
- laser.get_ranges(&data, -1, -1, cluster_count);
+ laser.get_ranges(data, -1, -1, cluster_count);
}
else if(first_step != -1 || last_step != -1)
{
// Get by step
if(get_new)
- laser.get_new_ranges(&data, first_step, last_step,
+ laser.get_new_ranges(data, first_step, last_step,
cluster_count);
else if(get_intensities)
- laser.get_new_ranges_intensities(&data, first_step, last_step,
+ laser.get_new_ranges_intensities(data, first_step, last_step,
cluster_count);
else
- laser.get_ranges(&data, first_step, last_step, cluster_count);
+ laser.get_ranges(data, first_step, last_step, cluster_count);
}
else
{
// Get by angle
if(get_new)
- laser.get_new_ranges_by_angle(&data, start_angle, end_angle,
+ laser.get_new_ranges_by_angle(data, start_angle, end_angle,
cluster_count);
else if(get_intensities)
- laser.get_new_ranges_intensities_by_angle(&data, start_angle,
+ laser.get_new_ranges_intensities_by_angle(data, start_angle,
end_angle, cluster_count);
else
- laser.get_ranges_by_angle(&data, start_angle, end_angle,
+ laser.get_ranges_by_angle(data, start_angle, end_angle,
cluster_count);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|