wheeledexperimenthelper.cpp
49 const wVector centerOnPlane = wall->matrix().w_pos - wall->matrix().z_ax.scale(wall->sideZ() / 2.0);
126 void computeLinearViewFieldOccupiedRangeForCylinder(const wMatrix& cameraMtr, const wMatrix& objMtr, double height, double radius, double& minAngle, double& maxAngle, double& distance)
128 // The center of the lower base of the cylinder. The local x axis points towards the ground (cylinders
132 // We have to translate the camera to lie on the same plane of the cylinder base. We translate it along
133 // its local upvector (Z axis) until it reaches the plane containing the base of the cylinder. Of course
134 // this only works if the camera Z axis is not paraller to the plane with the base of the cylinder. In
184 void computeDistanceAndOrientationFromRobotToCylinder(wVector robotPosition, double robotOrientation, double robotRadius, double radius, wVector position, double& distance, double& angle)
278 m_vertexes(QVector<wVector>() << computeWallVertex(m_box, 0) << computeWallVertex(m_box, 1) << computeWallVertex(m_box, 2) << computeWallVertex(m_box, 3)),
338 void Box2DWrapper::computeLinearViewFieldOccupiedRange(const wMatrix& cameraMtr, double& minAngle, double& maxAngle, double& distance) const
340 // If this is a Plane or a RectangularTargetArea, we simply return a negative distance (they are not visible with
347 // We have to translate the camera to lie on the same plane of the vertex. We translate it along
348 // its local upvector (Z axis) until it reaches the plane containing the base of the wall. Of course
349 // this only works if the camera Z axis is not paraller to the plane with the base of the wall. In
369 // Now finding the min and max angle (their indexes). We have to take into account the fact that the
370 // angle with the minimum value could be the upper limit and viceversa because the object could be
371 // behind the camera. However we know that, as the camera is outside the wall, the maximum possible
372 // angular sector of the view filed occupied by the wall is 180°. This means that also the angular
373 // distance of one vertex with the center of the wall must be less than 180°. So, if we compute this
374 // distance and get a value greater than 180°, we have to take (360° - computed_angular_distance)
381 // These two are the angular distances of the current min and max angles from the center. Their initial
427 #warning QUESTO MODO DI CALCOLARE LA DISTANZA È SBAGLIATO (E NON NE CAPISCO IL SENSO), MA È QUELLO USATO IN EVOROBOT, QUINDI PER IL MOMENTO LO USO (ANCHE PERCHÉ USARE LA DISTANZA PER L OCCLUSIONE NON VA BENE COMUNQUE)
432 distance = ((mtr.w_pos - m_vertexes[minAngleID]).norm() + (mtr.w_pos - m_vertexes[maxAngleID]).norm()) / 2.0;
435 bool Box2DWrapper::computeDistanceAndOrientationFromRobot(const WheeledRobot2DWrapper& robot, double& distance, double& angle) const
438 #warning I CALCOLI PER DISTANZA E ORIENTAMENTO IN EVOROBOT SONO A DIR POCO FANTASIOSI, QUI HO CERCATO DI FARE QUALCOSA DI PIÙ SENSATO...
451 // Now we can find the point in the rectangle that is nearest to the robot position. As we work in the box
457 // Finding the nearest point is just a matter of separately computing x and y. Note that if the robot is inside
476 // Although distance is independent of the frame of reference, we convert the nearest point to the global frame
478 const wVector nearestPoint = m_box->matrix().transformVector(wVector(nearestX, nearestY, relRobotPosition.z));
480 // Now we can easily compute the distance and orientation. For the distance we have to remove the robot radius
482 const real robotOrientation = (dynamic_cast<const RobotOnPlane*>(robot.wObject()))->orientation(m_arena->getPlane());
483 angle = atan2(nearestPoint.y - robotPosition.y, nearestPoint.x - robotPosition.x) - robotOrientation;
491 m_type(((type != SmallCylinder) && (type != BigCylinder) && (type != CircularTargetArea)) ? Cylinder : type)
538 void Cylinder2DWrapper::computeLinearViewFieldOccupiedRange(const wMatrix& cameraMtr, double& minAngle, double& maxAngle, double& distance) const
540 // If this is a CircularTargetArea, we simply return a negative distance (it is not visible with
547 computeLinearViewFieldOccupiedRangeForCylinder(cameraMtr, m_cylinder->matrix(), m_cylinder->height(), m_cylinder->radius(), minAngle, maxAngle, distance);
550 bool Cylinder2DWrapper::computeDistanceAndOrientationFromRobot(const WheeledRobot2DWrapper& robot, double& distance, double& angle) const
557 const double robotOrientation = (dynamic_cast<const RobotOnPlane*>(robot.wObject()))->orientation(m_arena->getPlane());
558 computeDistanceAndOrientationFromRobotToCylinder(robot.position(), robotOrientation, robot.getRadius(), m_cylinder->radius(), m_cylinder->matrix().w_pos, distance, angle);
563 WheeledRobot2DWrapper::WheeledRobot2DWrapper(Arena* arena, RobotOnPlane* robot, double height, double radius) :
621 void WheeledRobot2DWrapper::computeLinearViewFieldOccupiedRange(const wMatrix& cameraMtr, double& minAngle, double& maxAngle, double& distance) const
627 computeLinearViewFieldOccupiedRangeForCylinder(cameraMtr, mtr, m_height, m_radius, minAngle, maxAngle, distance);
630 bool WheeledRobot2DWrapper::computeDistanceAndOrientationFromRobot(const WheeledRobot2DWrapper& robot, double& distance, double& angle) const
636 const double robotOrientation = (dynamic_cast<const RobotOnPlane*>(robot.wObject()))->orientation(m_arena->getPlane());
637 computeDistanceAndOrientationFromRobotToCylinder(robot.position(), robotOrientation, robot.getRadius(), m_radius, position(), distance, angle);
669 // Taking the two x axes. We can take the x axis of mtr1 as is, while we need to project the X axis
670 // of mtr2 onto the XY plane of mtr1. To do so we simply project the x axis of mtr2 on the z axis of