6#define _USE_MATH_DEFINES
23#define DEG2RAD M_PI/180.0
38 XYCell robot = m_map.world2Cell(
XYWorld(m_robot_loc_x, m_robot_loc_y));
55void FakeLaserWithMotor::obst_the_robot(
double siz,
double dist)
65void FakeLaserWithMotor::trap_the_robot(
double siz)
99void FakeLaserWithMotor::free_the_robot()
104void FakeLaserWithMotor::drawStraightLine(
XYCell src,
XYCell dst)
108 dx = (
long int)dst.
x - (
long int)src.
x;
109 dy = (
long int)dst.
y - (
long int)src.
y;
126 xe = (
long int)src.x;
129 for (
i = 0; x <
xe;
i++)
138 if ((
dx < 0 &&
dy < 0) || (
dx > 0 &&
dy > 0))
157 ye = (
long int)dst.y;
163 ye = (
long int)src.y;
166 for (
i = 0; y <
ye;
i++)
175 if ((
dx < 0 &&
dy < 0) || (
dx > 0 &&
dy > 0))
190double FakeLaserWithMotor::checkStraightLine(
XYCell src,
XYCell dst)
198 int dx = abs(
int(dst.
x - src.
x));
199 int dy = abs(
int(dst.
y - src.
y));
204 if (src.
x < dst.
x) {
sx = 1; }
else {
sx = -1; }
205 if (src.
y < dst.
y) {
sy = 1; }
else {
sy = -1; }
242 return std::numeric_limits<double>::infinity();
249 double t0 = 0.0;
double t1 = 1.0;
261 if (
p == 0 &&
q < 0) {
return false; }
265 if (r > t1) {
return false; }
266 else if (r >
t0) {
t0 = r; }
270 if (r <
t0) {
return false; }
271 else if (r < t1) { t1 = r; }
const yarp::os::LogComponent & FAKE_LASER_UTILS()
fakeLaserWithMotor : fake sensor device driver for testing purposes and reference for IRangefinder2D ...
yarp::dev::Nav2D::MapGrid2D m_originally_loaded_map
yarp::dev::Nav2D::MapGrid2D m_map
XYCell world2Cell(XYWorld world) const
XYWorld cell2World(XYCell cell) const
size_t height() const
Retrieves the map height, expressed in cells.
bool setMapFlag(XYCell cell, map_flags flag)
Set the flag of a specific cell of the map.
size_t width() const
Retrieves the map width, expressed in cells.
bool isWall(XYCell cell) const
Checks if a specific cell of the map contains a wall.
void getResolution(double &resolution) const
Retrieves the resolution of the map, i.e.
A mini-server for performing network communication in the background.
#define YARP_LOG_COMPONENT(name,...)
yarp::math::Vec2D< size_t > XYCell
yarp::math::Vec2D< double > XYWorld
The main, catch-all namespace for YARP.