Exemple #1
0
        private static void Main(string[] args)
        {
            // sudo docker run -it --rm --name tilt --privileged derungsapp/icarus.sensors.tilt.manualtests

            // test if this test is run on ARM64 and Linux (Nvidia Jetson Nano)
            Console.WriteLine($"This test runs on {RuntimeInformation.OSDescription} {RuntimeInformation.ProcessArchitecture}");
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.ProcessArchitecture != Architecture.Arm64)
            {
                ConsoleHelper.WriteLine("This manual test is not supported on this machine. \n Please make sure to run the test on the actual device with the sensors wired. \n Press 'c' to continue in debug mode", ConsoleColor.Red);
                var key = Console.ReadKey();

                if (key.KeyChar != 'c')
                {
                    return;
                }
            }

#if !DEBUG
            var serviceCollection = new ServiceCollection();
            TiltModule.Initialize(serviceCollection);
            var serviceProvider = serviceCollection.BuildServiceProvider();
            var tiltSensor      = serviceProvider.GetService <ITiltSensor>();
#else
            ITiltSensor tiltSensor = null;
#endif


            TestTiltSensorFlat(tiltSensor, 5);
            TestTiltSensorFrontUp45Degrees(tiltSensor, 8);
            TestTiltSensorBackUp45Degrees(tiltSensor, 8);
            TestTiltSensorLeftSideUp45Degrees(tiltSensor, 8);
            TestTiltSensorRightSideUp45Degrees(tiltSensor, 8);
            TestTiltSensorRightSideUpWhileWheelie45Degrees(tiltSensor, 10);
        }
Exemple #2
0
        private static void TestTiltSensorFrontUp45Degrees(ITiltSensor tiltSensor, int toleranceDegrees)
        {
            Console.WriteLine();
            ConsoleHelper.WriteLine($"Test {_testNumber}", ConsoleColor.Yellow);
            Console.WriteLine("Do a wheelie with 45° while keeping the Y-axis at 0°");
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();

            var rotationResult = tiltSensor.GetRotationResult();

            TestTiltSensor(rotationResult, new RotationResult {
                XRotation = 45, YRotation = 0
            }, toleranceDegrees);
        }
Exemple #3
0
        private static void TestTiltSensorLeftSideUp45Degrees(ITiltSensor tiltSensor, int toleranceDegrees)
        {
            Console.WriteLine();
            ConsoleHelper.WriteLine($"Test {_testNumber}", ConsoleColor.Yellow);
            Console.WriteLine("Tilt sensor 45° to the right side like a stuntman with a car where the left wheels are no longer on the ground");
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();

            var rotationResult = tiltSensor.GetRotationResult();

            TestTiltSensor(rotationResult, new RotationResult {
                XRotation = 0, YRotation = 45
            }, toleranceDegrees);
        }
Exemple #4
0
        private static void TestTiltSensorRightSideUpWhileWheelie45Degrees(ITiltSensor tiltSensor, int toleranceDegrees)
        {
            Console.WriteLine();
            ConsoleHelper.WriteLine($"Test {_testNumber}", ConsoleColor.Yellow);
            Console.WriteLine("Tilt sensor 45° to the left side like a stuntman with a car where the right wheels are no longer on the ground and do a wheelie 45° at the same time. This way only the wheel on the left back is on the ground. ");
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();

            var rotationResult = tiltSensor.GetRotationResult();

            TestTiltSensor(rotationResult, new RotationResult {
                XRotation = 45, YRotation = -45
            }, toleranceDegrees);
        }
Exemple #5
0
        private static void TestTiltSensorFlat(ITiltSensor tiltSensor, int toleranceDegrees)
        {
            Console.WriteLine();
            ConsoleHelper.WriteLine($"Test {_testNumber}", ConsoleColor.Yellow);
            Console.WriteLine("Place the TiltSensor on a flat surface");
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();

            var rotationResult = tiltSensor.GetRotationResult();

            TestTiltSensor(rotationResult, new RotationResult {
                XRotation = 0, YRotation = 0
            }, toleranceDegrees);
        }
 public TiltController(ITiltSensor tiltSensor)
 {
     this.tiltSensor = tiltSensor;
 }