예제 #1
0
 /// <inheritdoc cref="RotationalSpeed.FromDegreesPerSecond(UnitsNet.QuantityValue)" />
 public static RotationalSpeed DegreesPerSecond <T>(this T value) => RotationalSpeed.FromDegreesPerSecond(Convert.ToDouble(value));
예제 #2
0
 public static RotationalSpeed?DegreesPerSecond <T>(this T?value) where T : struct => RotationalSpeed.FromDegreesPerSecond(value == null ? (double?)null : Convert.ToDouble(value.Value));
예제 #3
0
 /// <inheritdoc cref="RotationalSpeed.FromDegreesPerSecond(double?)"/>
 public static RotationalSpeed?DegreesPerSecond(this decimal?value) => RotationalSpeed.FromDegreesPerSecond(value == null ? (double?)null : Convert.ToDouble(value.Value));
예제 #4
0
 /// <inheritdoc cref="RotationalSpeed.FromDegreesPerSecond(double?)"/>
 public static RotationalSpeed?DegreesPerSecond(this float?value) => RotationalSpeed.FromDegreesPerSecond(value);
예제 #5
0
 /// <inheritdoc cref="RotationalSpeed.FromDegreesPerSecond(double)"/>
 public static RotationalSpeed DegreesPerSecond(this double value) => RotationalSpeed.FromDegreesPerSecond(value);
 public void NumberToDegreesPerSecondTest() =>
 Assert.Equal(RotationalSpeed.FromDegreesPerSecond(2), 2.DegreesPerSecond());
예제 #7
0
        static void Main(string[] args)
        {
            LogEvents.Subscribe(i => Console.WriteLine(i.ToLogString()), new[]
            {
                typeof(PiTop4Board).Assembly,
                typeof(FoundationPlate).Assembly,
                typeof(ExpansionPlate).Assembly,
                typeof(RoverRobot).Assembly,
            });
            Console.WriteLine("Test Rover App");
            PiTop4Board.Instance.UseCamera();

            using var rover = new RoverRobot(
                      PiTop4Board.Instance.GetOrCreateExpansionPlate(),
                      PiTop4Board.Instance.GetOrCreateCamera <StreamingCamera>(0),
                      RoverRobotConfiguration.Default);

            var camControl   = rover.TiltController;
            var motorControl = rover.MotionComponent as SteeringMotorController;
            var js           = new LinuxJoystick();

            rover.AllLightsOn();
            rover.BlinkAllLights();

            Console.WriteLine("reset");

            while (!Console.KeyAvailable)
            {
                try
                {
                    var e = js.ReadEvent();

                    if (e.type == 1)
                    {
                        switch (e.number)
                        {
                        case 0:
                            if (e.value > 0)
                            {
                                rover.AllLightsOn();
                            }
                            else
                            {
                                rover.AllLightsOff();
                            }
                            break;
                        }
                    }
                    if (e.type == 2) // axis
                    {
                        switch (e.number)
                        {
                        case 0:     // steer
                            motorControl.Steering = RotationalSpeed.FromDegreesPerSecond(
                                e.value.Interpolate(-motorControl.MaxSteering.DegreesPerSecond,
                                                    motorControl.MaxSteering.DegreesPerSecond) / 2);

                            break;

                        case 1:     // throttle
                            motorControl.Speed = Speed.FromMetersPerSecond(
                                e.value.Interpolate(motorControl.MaxSpeed.MetersPerSecond,
                                                    -motorControl.MaxSpeed.MetersPerSecond) / 2);

                            break;


                        case 2:     // pan
                            camControl.Pan = Angle.FromDegrees(e.value.Interpolate(90, -90));
                            break;

                        case 3:     // tilt
                            camControl.Tilt = Angle.FromDegrees(
                                Math.Min(45, e.value.Interpolate(90, -90)));
                            break;
                        }
                    }
                }
                catch
                {
                    motorControl.Stop();
                    throw;
                }
            }

            Console.ReadKey();
            rover.AllLightsOff();

            Console.WriteLine("bye");
        }