1+ #include " Map.hpp"
2+
3+ Map::Map (std::function<Pose3D()> pose_getter, std::function<Pose3D()> noisy_pose_getter)
4+ : pose_getter_(pose_getter), noisy_pose_getter_(noisy_pose_getter) {}
5+
6+ cv::Mat Map::RTx (double angle, double tx, double ty, double tz) {
7+ cv::Mat RT = (cv::Mat_<double >(4 , 4 ) <<
8+ 1 , 0 , 0 , tx,
9+ 0 , std::cos (angle), -std::sin (angle), ty,
10+ 0 , std::sin (angle), std::cos (angle), tz,
11+ 0 , 0 , 0 , 1 );
12+ return RT;
13+ }
14+
15+ cv::Mat Map::RTy (double angle, double tx, double ty, double tz) {
16+ cv::Mat RT = (cv::Mat_<double >(4 , 4 ) <<
17+ std::cos (angle), 0 , std::sin (angle), tx,
18+ 0 , 1 , 0 , ty,
19+ -std::sin (angle), 0 , std::cos (angle), tz,
20+ 0 , 0 , 0 , 1 );
21+ return RT;
22+ }
23+
24+ cv::Mat Map::RTz (double angle, double tx, double ty, double tz) {
25+ cv::Mat RT = (cv::Mat_<double >(4 , 4 ) <<
26+ std::cos (angle), -std::sin (angle), 0 , tx,
27+ std::sin (angle), std::cos (angle), 0 , ty,
28+ 0 , 0 , 1 , tz,
29+ 0 , 0 , 0 , 1 );
30+ return RT;
31+ }
32+
33+ cv::Mat Map::RTVacuum () {
34+ return RTz (M_PI / 2.0 , 50 , 70 , 0 );
35+ }
36+
37+ std::vector<double > Map::getRobotCoordinates () {
38+ Pose3D pose = pose_getter_ ();
39+ double x = pose.x ;
40+ double y = pose.y ;
41+
42+ double scale_y = -23.53 ;
43+ double offset_y = -31.95 ;
44+ y = scale_y * (offset_y - y);
45+
46+ double scale_x = -23.58 ;
47+ double offset_x = -20.36 ;
48+ x = scale_x * (offset_x - x);
49+
50+ return {x, y, pose.yaw };
51+ }
52+
53+ std::vector<double > Map::getRobotCoordinatesWithNoise () {
54+ Pose3D pose = noisy_pose_getter_ ();
55+ double x = pose.x ;
56+ double y = pose.y ;
57+
58+ double scale_y = -23.53 ;
59+ double offset_y = -31.95 ;
60+ y = scale_y * (offset_y - y);
61+
62+ double scale_x = -23.58 ;
63+ double offset_x = -20.36 ;
64+ x = scale_x * (offset_x - x);
65+
66+ return {x, y, pose.yaw };
67+ }
68+
69+ void Map::reset () {
70+ }
0 commit comments