front_sensors_pin_list_bcm = list(map(gpio.gpio_index_of_wpi_pin, [3, 4]))
rear_sensors_pin_list_bcm = [
]  #list(map(gpio.gpio_index_of_wpi_pin,    [2, 0]))

for pin in front_sensors_pin_list_bcm + rear_sensors_pin_list_bcm:
    gpio.set_pull_up_down(pin, gpio.PULL_DOWN)
    gpio.set_pin_mode(pin, gpio.INPUT)

##################     CONSTRUCTION OF THE ROBOT    ############################

#contains the (name, id) of the used AX12
AX12_list = [("atom_pusher", 129)]

robot = Robot()
for name, id in AX12_list:
    robot.add_object(AX12(id), name)

###################     ACTION FUNCTIONS    ####################################


def grobot_time_elapsed():
    '''
    called when the time is over to stop Grobot from moving
    '''
    print "switching AX12 off..."
    for name, _ in AX12_list:
        getattr(robot, name).turn(0)
        getattr(robot, name).set_torque(0)
    gpio.digital_write(pump_pin_bcm, 0)
    robot.emergency_stop()
from AX12 import AX12
from time import sleep

a = AX12(25)

for i in range(i):
    a.turn(i)
    sleep(0.01)
a.turn(0)
Beispiel #3
0
from AX12 import AX12
from time import sleep
from math import cos

# ---------------------------   ROBOT CONSTRUCTION   --------------------------#
#creates the robot skeleton

#adds motors to the robot skeleton
#r.add_object(AX12(174), "motor")

m = AX12(173)
precision = 10

# -------------------------   SEQUENCE DEFINITION ----------------------------#


def follow_scroll():
    m.turn(0)


follow_scroll()
#import the library

from robot import Robot
from AX12 import AX12
from inputs import get_mouse
from time import sleep

# ---------------------------   ROBOT CONSTRUCTION   --------------------------#
#creates the robot skeleton
r = Robot()

#adds motors to the robot skeleton
r.add_object(AX12(174), "motor")

precision = 10

# -------------------------   SEQUENCE DEFINITION ----------------------------#


def follow_scroll():
    position = 0

    while 1:
        sleep(0.001)
        events = get_mouse()
        for state in [
                event.state for event in events if event.code == "REL_X"
        ]:

            try:
                if state // precision <= 0:
    #scanned = I2C_bus.scan(print_ax12_id_on_the_fly)
    scanned = [130, 141]
    if len(scanned) < 2:
        print "[-] Not enough AX12 on I2C bus to achieve the sequence, exiting"
        exit()

    gpio.init()

    jack_pin = gpio.gpio_index_of_wpi_pin(5)
    print "Jack pin corresponds to BCM index " + str(jack_pin)

    #gpio.set_pin_mode(jack_pin, gpio.INPUT)
    gpio.set_pin_mode(
        jack_pin, gpio.OUTPUT)  #easier to test with hand (gpio write 5 0 ou 1)

    robot = init()

    robot.add_object(AX12(catapult_id), "catapult")
    robot.add_object(AX12(sorting_wheel_id), "sorting_wheel")
    robot.add_object(AX12(ball_catcher_id), "ball_catcher")

    manage_jack = add_jack_and_delay(robot, 30)

    gpio.assign_callback_on_gpio_down(24, lambda: manage_jack(False))
    gpio.assign_callback_on_gpio_up(24, lambda: manage_jack(True))

    #program

    robot.stop()
Beispiel #6
0
AMPLITUDE = 30
STICK_MAX = 30000
TRIGGER_MAX = 255
SPEAR_HORIZ = 132
SPEAR_MIN = 20
SPEAR_MAX = 150
SPEAR_SPEED = 0.5

MIN_BALLOON = -50
MAX_BALLOON = 20

import evdev
from evdev import InputDevice, categorize, ecodes
from AX12 import AX12

direction = AX12(25)
speed = AX12(172)
death_engine = AX12(142)
balloon = AX12(143)

#creates object 'gamepad' to store the data
#you can call it whatever you like
gamepad = InputDevice('/dev/input/event0')

#prints out device info at start
print(gamepad)

#evdev takes care of polling the controller in a loop
for event in gamepad.read_loop():
    type, value = str(categorize(event)).split()[-1], event.value
    print type, value
Beispiel #7
0
import pygame
import time
from AX12 import AX12

pygame.init()
pygame.display.set_mode((300, 200))
pygame.display.set_caption('robot remote')

wheel = AX12(172)
direction = AX12(25)
l = AX12(142)

while True:
    events = pygame.event.get()
    for event in events:
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_LEFT:
                direction.move(-69)
            if event.key == pygame.K_RIGHT:
                direction.move(-29)
            if event.key == pygame.K_UP:
                wheel.turn(-50)
            if event.key == pygame.K_DOWN:
                wheel.turn(50)
            if event.key == pygame.K_KP0:
                l.move(20)
        if event.type == pygame.KEYUP:
            if event.key == pygame.K_UP:
                wheel.turn(0)
            if event.key == pygame.K_DOWN:
                wheel.turn(0)
#import evdev
from evdev import InputDevice, categorize, ecodes
from AX12 import AX12

motor = AX12(172)

#creates object 'gamepad' to store the data
#you can call it whatever you like
gamepad = InputDevice('/dev/input/event0')

#prints out device info at start
print(gamepad)

#evdev takes care of polling the controller in a loop
for event in gamepad.read_loop():
    type, value = str(categorize(event)).split()[-1], event.value
    if(type == 'ABS_X'):
        motor.turn(value/300)
    
Beispiel #9
0
#import the library

from robot import Robot
from AX12 import AX12

# ---------------------------   ROBOT CONSTRUCTION   --------------------------#
#creates the robot skeleton
r = Robot()

#adds motors to the robot skeleton
r.add_object(AX12(130), "motor_1")
#r.add_object(AX12(121), "motor_2")

# -------------------------   SEQUENCE DEFINITION ----------------------------#

#defines a sequence of actions
#note that the sequence is only defined and not run (for the moment)
r.add_sequence("seq_1")

#first block of actions; all actions of a block are performed simultaneously
r.add_parallel(r.motor_1.move, [30])
#r.add_parallel(r.motor_2.move, [150])
#the "wait" defines the end of the block
#and it waits :
# 	until max_delay seconds are elapsed
# 	OR until n_callbacks actions of this block are done
r.wait(max_delay=3, n_callbacks=1)

#second block of actions; this block will be run AFTER the first one

Beispiel #10
0
from random import random
import math

from starting_block import manage_time_elapsed

gpio.init()

#switch_pin_bcm    = gpio.gpio_index_of_wpi_pin    (22)
switch_pin_bcm = 6

gpio.set_pull_up_down(  switch_pin_bcm,     gpio.PULL_UP)
gpio.set_pin_mode(      switch_pin_bcm,     gpio.INPUT)

pump_amplitude = 20

ax_shoot = AX12(121)
ax_shoot.move(100)
ax_pump = AX12(163)
ax_pump.move(-pump_amplitude)
ax_pump.set_speed(15)

turning_left = True

previous = gpio.digital_read(switch_pin_bcm)

while gpio.digital_read(switch_pin_bcm) == previous:
    sleep(1)
    
i=0
while True:
    i=i+1
Beispiel #11
0
coudea0=140#/!\ negativ angles
pinceopen=45
pinceclose=-29
l1=0.12
l2=0.15

def stop(ax12):
    stopped = False
    while not stopped:
       try:
          ax12.turn(0)
          stopped = True
       except:
          pass

base = AX12(121)
stop(base)
epaule = AX12(142)
stop(epaule)
coude = AX12(25)
stop(coude)
pince = AX12(145)
stop(pince)

try:
    pince.move(-45)
except:
    pass

def deplacerBras(x, y)
from AX12 import AX12

push = AX12(144)

v1 = -41
v2 = 135
middle = 49

push.move(49)
Beispiel #13
0
if __name__ == "__main__":

    try:
        I2C_bus.init(115200)
    except Exception as e:
        print "[-] Unable to start I2C communication (" + str(e) + "), exiting"
        exit()

    #scanned = I2C_bus.scan(print_ax12_id_on_the_fly)
    scanned = [130, 141]
    if len(scanned) < 2:
        print "[-] Not enough AX12 on I2C bus to achieve the sequence, exiting"
        exit()

    AX12_1 = AX12(scanned[0])
    AX12_2 = AX12(scanned[1])

    gpio.init()

    jack_pin = gpio.gpio_index_of_wpi_pin(5)
    print "Jack pin corresponds to BCM index " + str(jack_pin)

    #gpio.set_pin_mode(jack_pin, gpio.INPUT)
    gpio.set_pin_mode(
        jack_pin, gpio.OUTPUT)  #easier to test with hand (gpio write 5 0 ou 1)

    robot = init()
    robot.add_object(AX12_1, 'AX12_first')
    robot.add_object(AX12_2, 'AX12_second')
    robot.AX12_first.set_torque(400)
Beispiel #14
0
STRAIGHT = -45
AMPLITUDE = -10
STICK_MAX = 3000

#import evdev
from evdev import InputDevice, categorize, ecodes
from AX12 import AX12

direction = AX12(172)

#creates object 'gamepad' to store the data
#you can call it whatever you like
gamepad = InputDevice('/dev/input/event0')

#prints out device info at start
print(gamepad)

#evdev takes care of polling the controller in a loop
for event in gamepad.read_loop():
    type, value = str(categorize(event)).split()[-1], event.value
    if (type == 'ABS_X'):
        direction.move(int(value * AMPLITUDE / STICK_MAX) + STRAIGHT)
from AX12 import AX12

a = AX12(171)

a.turn(30)
from AX12 import AX12
from time import sleep
g = AX12(176)
d = AX12(175)
m = AX12(173)


def av(k=50):  #avancer
    g.turn(k)
    d.turn(-k)


def reculer(k=50):
    avancer(-k)


def l(k=70):  #tourner a gauche
    g.turn(-k)
    d.turn(-k)
    sleep(0.5)
    g.turn(0)
    d.turn(0)


def r(k=70):  #tourner a droite
    g.turn(k)
    d.turn(k)
    sleep(0.5)
    g.turn(0)
    d.turn(0)
Beispiel #17
0
#import the library

from robot import Robot
from AX12 import AX12


# ---------------------------   ROBOT CONSTRUCTION   --------------------------#
#creates the robot skeleton
r = Robot()

#adds motors to the robot skeleton
r.add_object(AX12(141), "motor_1")
r.add_object(AX12(130), "motor_2")


# -------------------------   SEQUENCE DEFINITION ----------------------------#

#defines a sequence of actions
#note that the sequence is only defined and not run (for the moment)
r.add_sequence("seq_1")

#first block of actions; all actions of a block are performed simultaneously
r.add_parallel(r.motor_1.move, [100])
r.add_parallel(r.motor_2.move, [150])
#the "wait" defines the end of the block
#and it waits :
# 	until max_delay seconds are elapsed
# 	OR until n_callbacks actions of this block are done
r.wait(max_delay=3, n_callbacks=2)

Beispiel #18
0
from AX12 import AX12

# Using the AX12 with ID 25
motor = AX12(25)

# Turning the AX12 to position 100 degrees
motor.move(100)

sleep(2)

# Rotating the AX12 at speed 50 (speeds are between -100 and 100)
motor.turn(50)

sleep(2)

# Stopping the AX12
motor.turn(0)