Resolved some float->double conversion errors to fix the tolerances for #1651

git-svn-id: https://code.ros.org/svn/ros-pkg/stacks/laser_pipeline/trunk@26612 eb33c2ac-9c88-4c90-87e0-44a10359b0c3
This commit is contained in:
Jeremy Leibs 2010-01-07 19:29:45 +00:00
parent 77f5de54ee
commit 671ec17afe
3 changed files with 15 additions and 15 deletions

View File

@ -209,9 +209,9 @@ namespace laser_geometry
* it is left protected so that test code can evaluate it * it is left protected so that test code can evaluate it
* appropriately. * appropriately.
*/ */
const boost::numeric::ublas::matrix<double>& getUnitVectors_(float angle_min, const boost::numeric::ublas::matrix<double>& getUnitVectors_(double angle_min,
float angle_max, double angle_max,
float angle_increment, double angle_increment,
unsigned int length); unsigned int length);
private: private:

View File

@ -150,7 +150,7 @@ namespace laser_geometry
cloud_out.channels[d].set_values_size(count); cloud_out.channels[d].set_values_size(count);
}; };
const boost::numeric::ublas::matrix<double>& LaserProjection::getUnitVectors_(float angle_min, float angle_max, float angle_increment, unsigned int length) const boost::numeric::ublas::matrix<double>& LaserProjection::getUnitVectors_(double angle_min, double angle_max, double angle_increment, unsigned int length)
{ {
//construct string for lookup in the map //construct string for lookup in the map
std::stringstream anglestring; std::stringstream anglestring;

View File

@ -72,18 +72,18 @@ sensor_msgs::LaserScan build_constant_scan(double range, double intensity,
class TestProjection : public laser_geometry::LaserProjection class TestProjection : public laser_geometry::LaserProjection
{ {
public: public:
const boost::numeric::ublas::matrix<double>& getUnitVectors(float angle_min, const boost::numeric::ublas::matrix<double>& getUnitVectors(double angle_min,
float angle_max, double angle_max,
float angle_increment, double angle_increment,
unsigned int length) unsigned int length)
{ {
return getUnitVectors_(angle_min, angle_max, angle_increment, length); return getUnitVectors_(angle_min, angle_max, angle_increment, length);
} }
}; };
void test_getUnitVectors(float angle_min, float angle_max, float angle_increment, unsigned int length) void test_getUnitVectors(double angle_min, double angle_max, double angle_increment, unsigned int length)
{ {
double tolerance = 1e-6; double tolerance = 1e-12;
TestProjection projector; TestProjection projector;
const boost::numeric::ublas::matrix<double> & mat = projector.getUnitVectors(angle_min, angle_max, angle_increment, length); const boost::numeric::ublas::matrix<double> & mat = projector.getUnitVectors(angle_min, angle_max, angle_increment, length);
@ -167,7 +167,7 @@ TEST(laser_geometry, getUnitVectors)
TEST(laser_geometry, projectLaser) TEST(laser_geometry, projectLaser)
{ {
double tolerance = 1e-5; double tolerance = 1e-12;
laser_geometry::LaserProjection projector; laser_geometry::LaserProjection projector;
double min_angle = -M_PI/2; double min_angle = -M_PI/2;
@ -259,8 +259,8 @@ TEST(laser_geometry, projectLaser)
for (unsigned int i = 0; i < cloud_out.points.size(); i++) for (unsigned int i = 0; i < cloud_out.points.size(); i++)
{ {
EXPECT_NEAR(cloud_out.points[i].x , scan.ranges[i] * cos(scan.angle_min + i * scan.angle_increment), tolerance); EXPECT_NEAR(cloud_out.points[i].x , (float)((double)(scan.ranges[i]) * cos((double)(scan.angle_min) + i * (double)(scan.angle_increment))), tolerance);
EXPECT_NEAR(cloud_out.points[i].y , scan.ranges[i] * sin(scan.angle_min + i * scan.angle_increment), tolerance); EXPECT_NEAR(cloud_out.points[i].y , (float)((double)(scan.ranges[i]) * sin((double)(scan.angle_min) + i * (double)(scan.angle_increment))), tolerance);
EXPECT_NEAR(cloud_out.points[i].z, 0, tolerance); EXPECT_NEAR(cloud_out.points[i].z, 0, tolerance);
EXPECT_NEAR(cloud_out.channels[0].values[i], scan.intensities[i], tolerance);//intensity \todo determine this by lookup not hard coded order EXPECT_NEAR(cloud_out.channels[0].values[i], scan.intensities[i], tolerance);//intensity \todo determine this by lookup not hard coded order
EXPECT_NEAR(cloud_out.channels[1].values[i], i, tolerance);//index EXPECT_NEAR(cloud_out.channels[1].values[i], i, tolerance);//index
@ -280,7 +280,7 @@ TEST(laser_geometry, transformLaserScanToPointCloud)
tf::Transformer tf; tf::Transformer tf;
double tolerance = 1e-5; double tolerance = 1e-12;
laser_geometry::LaserProjection projector; laser_geometry::LaserProjection projector;
double min_angle = -M_PI/2; double min_angle = -M_PI/2;
@ -375,8 +375,8 @@ TEST(laser_geometry, transformLaserScanToPointCloud)
for (unsigned int i = 0; i < cloud_out.points.size(); i++) for (unsigned int i = 0; i < cloud_out.points.size(); i++)
{ {
EXPECT_NEAR(cloud_out.points[i].x , scan.ranges[i] * cos(scan.angle_min + i * scan.angle_increment), tolerance); EXPECT_NEAR(cloud_out.points[i].x , (float)((double)(scan.ranges[i]) * cos((double)(scan.angle_min) + i * (double)(scan.angle_increment))), tolerance);
EXPECT_NEAR(cloud_out.points[i].y , scan.ranges[i] * sin(scan.angle_min + i * scan.angle_increment), tolerance); EXPECT_NEAR(cloud_out.points[i].y , (float)((double)(scan.ranges[i]) * sin((double)(scan.angle_min) + i * (double)(scan.angle_increment))), tolerance);
EXPECT_NEAR(cloud_out.points[i].z, 0, tolerance); EXPECT_NEAR(cloud_out.points[i].z, 0, tolerance);
EXPECT_NEAR(cloud_out.channels[0].values[i], scan.intensities[i], tolerance);//intensity \todo determine this by lookup not hard coded order EXPECT_NEAR(cloud_out.channels[0].values[i], scan.intensities[i], tolerance);//intensity \todo determine this by lookup not hard coded order
EXPECT_NEAR(cloud_out.channels[1].values[i], i, tolerance);//index EXPECT_NEAR(cloud_out.channels[1].values[i], i, tolerance);//index