Class EV3NavigationModel

  • All Implemented Interfaces:
    MoveListener, NavigationListener, WaypointListener, FeatureListener

    public class EV3NavigationModel
    extends NavigationModel
    implements MoveListener, NavigationListener, WaypointListener, FeatureListener
    NXT version of the navigation model. All local navigation objects, including pilots, navigators, path finders, feature detectors, and range scanners can be added to the model. Where possible, the model registers itself as an event listener and when the event occurs, updates the model and sends the event and the updates to the PC. A receiver thread receives events from the PC, updates the local model, and uses the navigation objects to implement the event if it involves robot behaviour. There are set methods to set various navigation parameters.
    Author:
    Lawrie Griffiths
    • Field Detail

      • clearance

        protected float clearance
      • maxDistance

        protected float maxDistance
      • autoSendPose

        protected boolean autoSendPose
      • sendMoveStart

        protected boolean sendMoveStart
      • sendMoveStop

        protected boolean sendMoveStop
    • Constructor Detail

      • EV3NavigationModel

        public EV3NavigationModel()
        Create the model and start the receiver thread
    • Method Detail

      • log

        public void log​(java.lang.String message)
        Log a message
        Parameters:
        message - the message
      • error

        public void error​(java.lang.String message)
        Display an error message to the user
        Parameters:
        message - the error message
      • fatal

        public void fatal​(java.lang.String message)
        Display a fatal error and shut down the program
        Parameters:
        message - the error message
      • addNavigator

        public void addNavigator​(Navigator navigator)
        Add a navigator to the model
        Parameters:
        navigator - the path controller
      • addPilot

        public void addPilot​(MoveController pilot)
        Add a pilot to the model
        Parameters:
        pilot - the move controller
      • addPoseProvider

        public void addPoseProvider​(PoseProvider pp)
        Add a pose provider (which might be MCL) to the model
        Parameters:
        pp - the pose provider
      • addRangeScanner

        public void addRangeScanner​(RangeScanner scanner)
        Add a range scanner to the model
        Parameters:
        scanner - the range scanner
      • addFeatureDetector

        public void addFeatureDetector​(FeatureDetector detector)
        Add a feature detector to the model
        Parameters:
        detector - the feature detector
      • setRandomMoveParameters

        public void setRandomMoveParameters​(float maxDistance,
                                            float clearance)
        Set parameters for a random move
        Parameters:
        maxDistance - the maximum distance of the move
        clearance - the clearance distance around the robot
      • setAutoSendPose

        public void setAutoSendPose​(boolean on)
        Set or unset automatic sending of the robot pose to the PC when a move stops
        Parameters:
        on - true if the pose is to be sent, else false
      • setSendMoveStart

        public void setSendMoveStart​(boolean on)
        Sets whether events are sent to the PC when a move stops
        Parameters:
        on - true iff an event should be sent
      • setSendMoveStop

        public void setSendMoveStop​(boolean on)
        Sets whether events are sent to the PC when a move starts
        Parameters:
        on - true iff an event should be sent
      • shutDown

        public void shutDown()
        Shut down the receiver thread
      • moveStarted

        public void moveStarted​(Move event,
                                MoveProvider mp)
        Called when the pilot starts a move
        Specified by:
        moveStarted in interface MoveListener
        Parameters:
        event - the movement
        mp - the movement provider
      • moveStopped

        public void moveStopped​(Move event,
                                MoveProvider mp)
        Called when a move stops
        Specified by:
        moveStopped in interface MoveListener
        Parameters:
        event - the movement
        mp - movement provider
      • featureDetected

        public void featureDetected​(Feature feature,
                                    FeatureDetector detector)
        Called when a feature is detected. Only range features currently supported
        Specified by:
        featureDetected in interface FeatureListener
        Parameters:
        feature - The RangeReading, which contains angle and range.
      • addWaypoint

        public void addWaypoint​(Waypoint wp)
        Send a waypoint generated on the NXT to the PC
        Specified by:
        addWaypoint in interface WaypointListener
        Parameters:
        wp - the new waypoint
      • atWaypoint

        public void atWaypoint​(Waypoint waypoint,
                               Pose pose,
                               int sequence)
        Called when a waypoint has been reached
        Specified by:
        atWaypoint in interface NavigationListener
        Parameters:
        waypoint - where the robot
        pose - of the robot
        sequence - of the Waypoint in the path
      • pathComplete

        public void pathComplete​(Waypoint waypoint,
                                 Pose pose,
                                 int sequence)
        Called when a path has been completed
        Specified by:
        pathComplete in interface NavigationListener
        Parameters:
        waypoint - where the robot
        pose - of the robot
        sequence - of the Waypoint in the path
      • pathInterrupted

        public void pathInterrupted​(Waypoint waypoint,
                                    Pose pose,
                                    int sequence)
        Called when a path has been interrupted
        Specified by:
        pathInterrupted in interface NavigationListener
        Parameters:
        waypoint - toward which the robot was moving
        pose - current pose of the robot
        sequence - number of the next Waypoint
      • pathGenerated

        public void pathGenerated()
        Called when a path finder has finished generating a path
        Specified by:
        pathGenerated in interface WaypointListener