17 #include <gtest/gtest.h> 20 #include <nav_msgs/OccupancyGrid.h> 21 #include <ros/console.h> 28 msg.info.height = 500;
29 msg.info.resolution = 0.1;
30 msg.info.origin.position.x = rand() % 10 - 5;
31 msg.info.origin.position.y = rand() % 10 - 5;
32 msg.info.origin.position.z = 0;
34 msg.info.origin.orientation.x = 0;
35 msg.info.origin.orientation.y = 0;
36 msg.info.origin.orientation.z = 0;
37 msg.info.origin.orientation.w = 1;
39 msg.data.resize(msg.info.width * msg.info.height, -1);
44 nav_msgs::OccupancyGrid srcRos;
49 srcRos.info.origin.orientation.x = 0;
55 for (uint32_t h = 0; h < srcRos.info.width; h++)
57 for (uint32_t w = 0; w < srcRos.info.width; w++)
60 desMrpt.
getPos(w, h), 0.5);
65 TEST(Map, check_ros2mrpt_and_back)
67 nav_msgs::OccupancyGrid srcRos;
69 nav_msgs::OccupancyGrid desRos;
77 for (uint32_t h = 0; h < srcRos.info.width; h++)
78 for (uint32_t w = 0; w < srcRos.info.width; w++)
79 EXPECT_EQ(desRos.data[h * srcRos.info.width + h], -1);
82 for (
int i = 0; i <= 100; i++)
85 srcRos.data[i] = (std::abs(i - 50) <= 2) ? -1 : i;
91 for (
int i = 0; i <= 100; i++)
99 EXPECT_NEAR(srcRos.data[i], desRos.data[i], 1) <<
"ros to mprt to ros";
EXPECT_TRUE(mrpt::system::fileExists(ini_fil))
float getResolution() const
Returns the resolution of the grid map.
TEST(Map, basicTestHeader)
unsigned int getSizeX() const
Returns the horizontal size of grid map in cells count.
A class for storing an occupancy grid map.
bool toROS(const mrpt::obs::CObservationGPS &obj, const std_msgs::Header &msg_header, sensor_msgs::NavSatFix &msg)
Convert mrpt::obs::CObservationGPS -> sensor_msgs/NavSatFix The user must supply the "msg_header" fie...
bool fromROS(const sensor_msgs::NavSatFix &msg, mrpt::obs::CObservationGPS &obj)
Convert sensor_msgs/NavSatFix -> mrpt::obs::CObservationGPS.
void getEmptyRosMsg(nav_msgs::OccupancyGrid &msg)
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
float getPos(float x, float y) const
Read the real valued [0,1] contents of a cell, given its coordinates.
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
unsigned int getSizeY() const
Returns the vertical size of grid map in cells count.
float getCell(int x, int y) const
Read the real valued [0,1] contents of a cell, given its index.