GithubHelp home page GithubHelp logo

ev3dev-lang-java / lejos-navigation Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 5.63 MB

LeJOS local navigation stack

License: GNU General Public License v3.0

Java 100.00%
java lego mindstorms lejos local-navigation robotics ev3 ev3dev path-planning occupancy-grid-map

lejos-navigation's Introduction

lejos-navigation

This library represent the local navigation stack from LeJOS project.

What packages include?

The packages included in this library are:

  • lejos.robotics.localization
  • lejos.robotics.mapping
  • lejos.robotics.navigation
  • lejos.robotics.objectdetection
  • lejos.robotics.pathfinding

Getting Started

To start a new project with this library, add the following repository and dependency.

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
<dependency>
    <groupId>com.github.ev3dev-lang-java</groupId>
    <artifactId>lejos-navigation</artifactId>
    <version>v0.1.0</version>
</dependency>

Further information about the Maven dependency: https://jitpack.io/#ev3dev-lang-java/lejos-navigation/v0.1.0

Now if you use EV3Dev + EV3Dev-lang-java, it is possible to enjoy with this kind of examples:

import ev3dev.utils.PilotProps;
import lejos.robotics.RegulatedMotor;
import lejos.robotics.navigation.DifferentialPilot;

import java.io.IOException;

public class PilotConfig {

    private DifferentialPilot pilot;

    public PilotConfig() throws IOException {

        PilotProps pp = new PilotProps();
        pp.loadPersistentValues();
        float wheelDiameter = Float.parseFloat(pp.getProperty(PilotProps.KEY_WHEELDIAMETER));
        float trackWidth = Float.parseFloat(pp.getProperty(PilotProps.KEY_TRACKWIDTH));
        RegulatedMotor leftMotor = PilotProps.getMotor(pp.getProperty(PilotProps.KEY_LEFTMOTOR));
        RegulatedMotor rightMotor = PilotProps.getMotor(pp.getProperty(PilotProps.KEY_RIGHTMOTOR));
        boolean reverse = Boolean.parseBoolean(pp.getProperty(PilotProps.KEY_REVERSE));

        //Special Stop modes from EV3Dev
        leftMotor.brake();
        rightMotor.brake();

        System.out.println("Any button to start");

        pilot = new DifferentialPilot(wheelDiameter, trackWidth, leftMotor, rightMotor, reverse);
        //pilot.setAngularAcceleration();
        pilot.setAngularSpeed(100);
        //pilot.setLinearAcceleration();
        pilot.setLinearSpeed(100);
        int accel = 60;
        //pilot.setAcceleration(accel);
    }

    public DifferentialPilot getPilot(){
        return pilot;
    }
}
import ev3dev.sensors.Button;
import ev3dev.sensors.ev3.EV3UltrasonicSensor;
import lejos.hardware.port.SensorPort;
import lejos.robotics.RangeFinderAdapter;
import lejos.robotics.navigation.DifferentialPilot;
import lejos.robotics.objectdetection.Feature;
import lejos.robotics.objectdetection.FeatureDetector;
import lejos.robotics.objectdetection.FeatureListener;
import lejos.robotics.objectdetection.RangeFeatureDetector;

import java.io.IOException;

public class FeatureAvoider2 {
     
    static final float MAX_DISTANCE = 50f;
    static final int DETECTOR_DELAY = 1000;
 
    public static void main(String[] args) throws IOException {

        final PilotConfig pilotConf = new PilotConfig();
        final DifferentialPilot pilot = pilotConf.getPilot();

        final EV3UltrasonicSensor ir = new EV3UltrasonicSensor(SensorPort.S1);
        final RangeFeatureDetector detector = new RangeFeatureDetector(
                new RangeFinderAdapter(ir.getDistanceMode()), MAX_DISTANCE, DETECTOR_DELAY);

        detector.enableDetection(true);
        pilot.forward();
         
        detector.addListener(new FeatureListener() {
            public void featureDetected(Feature feature, FeatureDetector detector) {
                detector.enableDetection(false);
                pilot.travel(-30);
                pilot.rotate(30);
                detector.enableDetection(true);
                pilot.forward();
            }       
        });

        Button.waitForAnyPress();
    }
}

UML Diagram

Open issues

  • Chassis package is not included (Speak with Aswin & Andy)
  • DifferentialPilot: (I have doubts with methods with arcs)
  • Fusor detector (Possible concurrency problems)

lejos-navigation's People

Contributors

jabrena avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

xsgao-github

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.