Example #1
0
        public SkillHelper(IRobotMessenger misty)
        {
            _misty = misty ?? throw new ArgumentNullException(nameof(misty));

            _misty.RegisterDriveEncoderEvent(EncoderEventCallback, 100, true, null, "SkillHelperEncoderEvent", OnResponse);
            _misty.RegisterIMUEvent(ImuEventCallback, 100, true, null, "SkillHelperIMUEvent", OnResponse);
            _misty.RegisterTimeOfFlightEvent(TofEventCallback, 0, true, null, "SkillHelperTofEventEvent", OnResponse);
            _misty.RegisterHazardNotificationEvent(HazardEventCallback, 0, true, "SkillHelperHazardEvent", OnResponse);
        }
Example #2
0
        public SkillHelper(IRobotMessenger misty)
        {
            _misty = misty ?? throw new ArgumentNullException(nameof(misty));

            LogMessage("SkillHelper initiating. Registering event callbacks for encoders and IMU.");

            _misty.RegisterDriveEncoderEvent(EncoderEventCallback, 100, true, null, "SkillHelperEncoderEvent", OnResponse);
            _misty.RegisterIMUEvent(ImuEventCallback, 100, true, null, "SkillHelperIMUEvent", OnResponse);

            // THE HAZARD HANDLING CODE IS CURRENTLY DISABLED
            //_misty.RegisterHazardNotificationEvent(HazardEventCallback, 0, true, "SkillHelperHazardEvent", OnResponse);
        }
Example #3
0
        /// <summary>
        /// This event handler is called when the robot/user sends a start message
        /// The parameters can be set in the Skill Runner (or as json) and used in the skill if desired
        /// </summary>
        /// <param name="parameters"></param>
        public void OnStart(object sender, IDictionary <string, object> parameters)
        {
            try
            {
                _misty.SendDebugMessage("MistyMiner skill started", null);
                _misty.MoveHead(20, 0, 0, 0, AngularUnit.Position, null);
                //_takeImageTimer = new Timer(CheckForOreCallback, null, 0, 5000);
                _misty.RegisterCapTouchEvent(CheckForOreCallback, 1000, true, null, null, null);
                _misty.RegisterIMUEvent(setYaw, 5, true, null, null, null);

                List <ActuatorPositionValidation> HeadPositionValidation = new List <ActuatorPositionValidation>();
                HeadPositionValidation.Add(new ActuatorPositionValidation {
                    Name = ActuatorPositionFilter.SensorName, Comparison = ComparisonOperator.Equal, ComparisonValue = ActuatorPosition.HeadPitch
                });
                _misty.RegisterActuatorEvent(setHeadPitch, 10, true, HeadPositionValidation, null, null);

                List <ActuatorPositionValidation> ArmPositionValidation = new List <ActuatorPositionValidation>();
                ArmPositionValidation.Add(new ActuatorPositionValidation {
                    Name = ActuatorPositionFilter.SensorName, Comparison = ComparisonOperator.Equal, ComparisonValue = ActuatorPosition.RightArm
                });
                _misty.RegisterActuatorEvent(setArmPitch, 100, true, ArmPositionValidation, null, null);

                _misty.RegisterTimeOfFlightEvent(setTimeOfFlight, 0, true, null, null, null);


                //Clean up any lingering runs
                yaw.YawReached -= HandleYawReached;
                yaw.YawReached -= HandleReturnYawReached;
                yaw.YawReached -= FinalYaw;

                tof.DistanceReached -= HandleOreReached;
                tof.DistanceReached -= HandleReturnReached;

                arm.ArmPosReached -= ArmDown;
                arm.ArmPosReached -= ArmUp;
            }
            catch (Exception ex)
            {
                _misty.SkillLogger.Log($"MistyMiner : OnStart: => Exception", ex);
                _misty.SendDebugMessage($"MistyMiner : OnStart: => Exception" + ex, null);
            }
        }