Giter Site home page Giter Site logo

ev3dev's Introduction

Robocup using ev3dev

This is a robocup program running ev3dev with python. I have put together a library to make it a little easier to work with but it mainly the same as what the guys over at ev3dev built. You can go over to http://www.ev3dev.org/ to learn how to install ev3dev onto your EV3. Once you have that installed and running (which may take a while and a few tries) you will need to download my library. Just as a note you will definitely need to know a good amount of python to use this library.

Documentation

Once the library is all installed you will need to import it into your python file using:

from lib.motor import *
from lib.sensor import *

This grabs all the motor and sensor classes. You may also need to import ev3dev with:

import ev3dev.ev3 as ev3

This is mainly if there is an unsupported class or function in my library. Thats pretty much it for the imports, onto how to use the classes.

Motors

To setup a new motor you need to make it a new motor class and give it a port like:

newMotor = Motor('outA') # You can go from ports 'outA' through to 'outD'

Once you have a motor setup you can preform the following commands:

newMotor.run(80) # speed to run at (runs forever until stop())
newMotor.stop() # stops motor
newMotor.position() # returns the motors current rotation
newMotor.reset() # resets rotation to 0

Sensors

Like a motor to set up a sensor:

colorSensor = ColorSensor('in1') # You can go from ports 'in1' through to 'in4'
ultrasonicSensor = UltrasonicSensor('in2')
gyroSensor = GyroSensor('in3') # Other sensors are coming

Once you have a sensor setup you can preform the following commands:

Color Sensor
colorSensor.value(0) # this is the main value for most modes though it can range up to value(2)
colorSensor.mode('COL-REFLECT') # changes the sensors mode list of modes are: 
# 'COL-REFLECT' reflected light value [value(0)] 0 - 100
# 'COL-AMBIENT' ambient light value [value(0)] 0 - 100
# 'COL-COLOR' predefined color value [value(0)] 0 - 7
# color values 1: black, 2: blue, 3: green, 4: yellow, 5: red, 6: white and 7: brown
# 'REF-RAW' no idea [value(0)] 0 - 1020
# 'RGB-RAW' raw rgb values (use sensor.rgb() for array format) [value(0), value(1), value(3)] 0 - 1020
# 'COL-CAL' no idea
colorSensor.rgb() # returns array of value(0) to value(2)
Ultrasonic Sensor
ultrasonicSensor.value(0) # this is the only value ranging from 0 - 2550
Gyro Sensor
gyroSensor.value(0) # this is the only value ranging from 0 - 2550
gyroSensor.mode('GYRO-ANG') # changes the sensors mode list of modes are: 
# 'GYRO-ANG' angle [value(0)] -32768 - 32767
# 'GYRO-RATE' turning speed rate [value(0)] -440 - 440
# 'GYRO-G&A' angle and turning speed [value(0), value(1)] -32768 - 32767, -440 - 440
# 'GYRO-FAS' no idea
# 'GYRO-CAL' calibration? no idea
Touch Sensor
touchSensor.value(0) # this is the only value ranging from 0 - 1 (0: released, 1: pressed)

As a note I will add more sensor classes in the future. For any other info go to http://www.ev3dev.org/docs/sensors

Logger

If you want to use my logger as well import with:

from lib.logger import *

To log to a new file and write to it use:

output = Logger('log/output.log') # path for new log

output.log('hello')
output.warn('warning') # logs warning
output.err('error') # logs error

For this you might want to install a .log file grammar (for atom) such as https://atom.io/packages/language-log.

Sound

Another thing ev3dev supports is sound. I've also put together a library for that, you can import it like so:

from lib.sound import *

sound = Sound()

You can use use some sound with:

sound.beep() # beep!
sound.speak('hello') # say hello
sound.note(392, 350) # play a note for a certain amount of time
sound.starwars() # play the star wars theme song

Liam Brennan 2016

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.