Giter Club home page Giter Club logo

tg_robot_code's Introduction

TG_Robot_Code

Robot Code for Tech garage compatible with the Google Coral and Raspberry Pi

Get Started

git clone https://github.com/Danny-Dasilva/TG_Robot_Code.git

path to folder

cd TG_Robot_Code

install dependencies

sh scripts/install.sh

Autoboot code

sh scripts/auto.sh

This will put the Robot code.py path in your crontab which will run on boot

Examples

In test/

controller map test

python3 pygame.py

Plug in a motor or servo on pin 1 to test the servokit library

sudo python3 simple_test.py

Robot Code

sudo python3 RobotCode.py

Map below is for the Adafruit PCA_9685 Hat This is assuming your Logitech controller is in X mode

Tank Drive

  Left Drivetrain A -> 0   
 Right Drivetrain A -> 1    
  Left Drivetrain B -> 2   
 Right Drivetrain B -> 3  
        Motor Arm 1 -> 4   
        Motor Arm 2 -> 5  
            Servo 1 -> 6  
            Servo 2 -> 7
              Empty -> 8  
              Empty -> 9  
              Empty -> 10
              Empty -> 11 
              Empty -> 12 
              Empty -> 13 
              Empty -> 14  
              Empty -> 15  

Drivetrain - Left stick and Right stick control respective Left and Right sides
Arm 1      - Motor mapped to Joystick buttons, LB to go forward RB to go back
Arm 2      - Motor mapped to Joystick buttons, LT to go forward RT to go back
Servo 1    - Increments servo on button press, A increases values B decreases values
Servo 2    - Increments servo on button press, X increases values Y decreases values
Empty      - Not currently mapped anywhere

Troubleshooting

This library assumes you are mounting on the 0x60 i2c bus

If you are getting an i2c device not found at 60 error you can solder i2c A5

Or remove the address parameter in the line below

hat = Py_Hat(address=96) -> hat = Py_Hat()

Autonomous and Custom Teleop

ask for a hat_switch

All custom code goes in the file My_Custom_Code.py

there are two classes for custom code

def my_custom_autonomous():

and

def my_custom_teleop():

Autonomous and teleop code should always go under these functions

my_custom_autonomous

example

def my_custom_autonomous(hat):
    auto = Autonomous(hat)

    # Takes a value and time
    auto.forward(.8, 2)
    auto.backward(1, 1)
    auto.turn_left(.5, 2)
    auto.turn_right(.5, 2)
    auto.stop()

my_custom_teleop

def my_custom_teleop():
    #controller class
    controller = Controller()

    # initialize Pi Hat
    hat = Py_Hat(address=96)
    
    while True:
        controller.event_get()
        # setup controls
        leftstick = controller.set_axis('leftstick')
        rightstick = controller.set_axis('rightstick')
        LT = controller.set_axis('LT')

        # Button press to run Autonomous
        if LT > .75:
            my_custom_autonomous(hat) 

        # drivetrain examples
        hat.motor(0, leftstick)
        hat.motor(1, -rightstick)
        # sleep for smooth loops
        sleep(.02)

tg_robot_code's People

Contributors

danny-dasilva avatar gatordevin avatar

Watchers

James Cloos avatar

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.