示例#1
0
        public static void Test_robot_acceleration_inferior_1g()
        {
            Random rand;
            double x, y;


            rand = new Random();

            int numberWayPoints = rand.Next(5, 10);

            List <Point2D> WayPoints = new List <Point2D>();

            for (int i = 0; i < numberWayPoints; i++)
            {
                x = rand.NextDouble() * 10000;
                y = rand.NextDouble() * 10000;
                Point2D wayPoint = new Point2D(x, y);
                WayPoints.Add(wayPoint);
            }

            MyRobot robot = new MyRobot(WayPoints[0], WayPoints[0].AbsoluteBearing(WayPoints[1]));

            List <Point2D> trajectory = robot.CalculateIntermediatePointsBetweenWayPoints(WayPoints, 1.55);

            robot.Trajectory = WayPoints;
            robot.Speed      = 0;
            double lastSpeed = 0;

            for (int i = 0; i < 100; i++)
            {
                robot.MoveRobot(new Point2D(robot.Position.X + 100, robot.Position.Y));
                (robot.Speed - lastSpeed).Should().BeLessThan(9.81);
                lastSpeed = robot.Speed;
            }
        }
示例#2
0
        public static void TestBearingShouldMakeYouMoveToRightPosition()
        {
            Random rand;
            double x1, y1, x2, y2;

            rand = new Random();
            x1   = rand.NextDouble();
            y1   = rand.NextDouble();
            x2   = rand.NextDouble();
            y2   = rand.NextDouble();

            Point2D orig = new Point2D(x1, y1);
            Point2D dest = new Point2D(x2, y2);

            double angle = orig.AbsoluteBearing(dest);

            MyRobot r = new MyRobot(orig, angle);

            double distance = orig.Norm(dest);

            r.MoveRobot(r.CalculateRobotNextPositionPolar(orig, angle, distance));

            r.Position.X.Should().BeApproximately(x2, 0.001);
            r.Position.Y.Should().BeApproximately(y2, 0.001);
        }
示例#3
0
        public static void Test_robot_should_follow_trajectory()
        {
            Random rand;
            double x, y;


            rand = new Random();

            int numberWayPoints = rand.Next(5, 10);

            List <Point2D> WayPoints = new List <Point2D>();

            for (int i = 0; i < numberWayPoints; i++)
            {
                x = rand.NextDouble() * 10000;
                y = rand.NextDouble() * 10000;
                Point2D wayPoint = new Point2D(x, y);
                WayPoints.Add(wayPoint);
            }

            MyRobot robot = new MyRobot(WayPoints[0], 0);

            List <Point2D> trajectory = robot.CalculateIntermediatePointsBetweenWayPoints(WayPoints, 1.55);

            robot.Trajectory = WayPoints;
            robot.Speed      = 1;

            for (int i = 0; i < 100; i++)
            {
                robot.MoveRobot(new Point2D(robot.Position.X + 1, robot.Position.Y + 1));
            }
        }