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(const wVector& robotPosition, double robotOrientation, double robotRadius, double radius, const wVector& position, double& distance, double& angle)
274 m_vertexes(QVector<wVector>() << computeWallVertex(m_box, 0) << computeWallVertex(m_box, 1) << computeWallVertex(m_box, 2) << computeWallVertex(m_box, 3)),
334 void Box2DWrapper::computeLinearViewFieldOccupiedRange(const wMatrix& cameraMtr, double& minAngle, double& maxAngle, double& distance) const
336 // If this is a Plane or a RectangularTargetArea, we simply return a negative distance (they are not visible with
343 // We have to translate the camera to lie on the same plane of the vertex. We translate it along
344 // its local upvector (Z axis) until it reaches the plane containing the base of the wall. Of course
345 // this only works if the camera Z axis is not paraller to the plane with the base of the wall. In
365 // Now finding the min and max angle (their indexes). We have to take into account the fact that the
366 // angle with the minimum value could be the upper limit and viceversa because the object could be
367 // behind the camera. However we know that, as the camera is outside the wall, the maximum possible
368 // angular sector of the view filed occupied by the wall is 180°. This means that also the angular
369 // distance of one vertex with the center of the wall must be less than 180°. So, if we compute this
370 // distance and get a value greater than 180°, we have to take (360° - computed_angular_distance)
377 // These two are the angular distances of the current min and max angles from the center. Their initial
423 #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)
428 distance = ((mtr.w_pos - m_vertexes[minAngleID]).norm() + (mtr.w_pos - m_vertexes[maxAngleID]).norm()) / 2.0;
431 bool Box2DWrapper::computeDistanceAndOrientationFromRobot(const WheeledRobot2DWrapper& robot, double& distance, double& angle) const
434 #warning I CALCOLI PER DISTANZA E ORIENTAMENTO IN EVOROBOT SONO A DIR POCO FANTASIOSI, QUI HO CERCATO DI FARE QUALCOSA DI PIÙ SENSATO...
447 // Now we can find the point in the rectangle that is nearest to the robot position. As we work in the box
453 // Finding the nearest point is just a matter of separately computing x and y. Note that if the robot is inside
472 // Although distance is independent of the frame of reference, we convert the nearest point to the global frame
474 const wVector nearestPoint = m_box->matrix().transformVector(wVector(nearestX, nearestY, relRobotPosition.z));
476 // Now we can easily compute the distance and orientation. For the distance we have to remove the robot radius
478 const real robotOrientation = (dynamic_cast<const RobotOnPlane*>(robot.wObject()))->orientation(m_arena->getPlane());
479 angle = atan2(nearestPoint.y - robotPosition.y, nearestPoint.x - robotPosition.x) - robotOrientation;
487 m_type(((type != SmallCylinder) && (type != BigCylinder) && (type != CircularTargetArea)) ? Cylinder : type)
534 void Cylinder2DWrapper::computeLinearViewFieldOccupiedRange(const wMatrix& cameraMtr, double& minAngle, double& maxAngle, double& distance) const
536 // If this is a CircularTargetArea, we simply return a negative distance (it is not visible with
543 computeLinearViewFieldOccupiedRangeForCylinder(cameraMtr, m_cylinder->matrix(), m_cylinder->height(), m_cylinder->radius(), minAngle, maxAngle, distance);
546 bool Cylinder2DWrapper::computeDistanceAndOrientationFromRobot(const WheeledRobot2DWrapper& robot, double& distance, double& angle) const
553 const double robotOrientation = (dynamic_cast<const RobotOnPlane*>(robot.wObject()))->orientation(m_arena->getPlane());
554 computeDistanceAndOrientationFromRobotToCylinder(robot.position(), robotOrientation, robot.getRadius(), m_cylinder->radius(), m_cylinder->matrix().w_pos, distance, angle);
559 WheeledRobot2DWrapper::WheeledRobot2DWrapper(Arena* arena, RobotOnPlane* robot, double height, double radius) :
617 void WheeledRobot2DWrapper::computeLinearViewFieldOccupiedRange(const wMatrix& cameraMtr, double& minAngle, double& maxAngle, double& distance) const
623 computeLinearViewFieldOccupiedRangeForCylinder(cameraMtr, mtr, m_height, m_radius, minAngle, maxAngle, distance);
626 bool WheeledRobot2DWrapper::computeDistanceAndOrientationFromRobot(const WheeledRobot2DWrapper& robot, double& distance, double& angle) const
632 const double robotOrientation = (dynamic_cast<const RobotOnPlane*>(robot.wObject()))->orientation(m_arena->getPlane());