Giter Club home page Giter Club logo

drivetrain's Introduction

2bndy5's github stats Top Langs

drivetrain's People

Contributors

2bndy5 avatar jasper-rowan avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

jasper-rowan

drivetrain's Issues

upgrading from threading to multiprocessing

all the following code references assume myThread = threading.Thread(target=func_pointer) where func_pointer is the function that is executed by the myThread object once myThread.start() has been called. NOTE: func_pointer() is the functionality we want to reuse to smooth acceleration/deceleration on the drivetrain/motor object(s).

As it turns out, myThread.join() will block until the thread is considered "not alive" which can be determined as a bool by calling myThread.is_alive(). If we pass a timeout value to join(timeout=5.5), then the function will only wait for the myThread has finished for a up to 5.5 seconds. This does not mean the thread is finished if the timeout has been reached, rather the thread is still busy and join gave up on waiting for it to finish. Despite wheather the thread is alive or not, to execute a threaded func_pointer(), the func_pointer needs to be passed again as the target parameter to newThread = threading.Thread(target=func_pointer) object (and initiated with newThread.start() function). This is problematic since both threads can be executing simultaneously instead of aborting previous thread and re-start()-ing in under the newThread's context. Using the threading module's context managers -- like using with statements -- won't solve this either because they only care about what main program "owns" the thread.

Furthermore, threads only get cleaned up or deleted when the main python program exits (to the best of the interpreter's ability -- see the paragraph about "dummy/alien threads" just above this link). This is why we need to better manage the threads that are created.

Enter the multiprocessing module... More on this when I get my hands dirty. As it is the drivetrain is stable, so I'll be starting a new branch to do some preliminary tests.

mecanum based drivetrain

In order to test/play with mechanism wheels, we need a class that takes 2 Tank drivetrain objects upon instantiation and uses them to drive a robot with 4 mecanum wheels oriented (pointing) in the same direction. Each of the wheels' "treads" (the free spinning angled parts that make up the contact surface with the terrain) should be 45 degrees from the robot's center. This new class should take the same x-axis and y-axis input commands, but with the addition of a strafe Boolean to indicate weather turning should alter the robot's facing direction or not.

going to need a motor refactor

To allow for non direct GPIO usage like via USB/I2C/etc, the motors' c'tors should take PWMOut or DigitalInOut objects where applicable; not board.<Pin_numbers>. This also better allows for compatibility with MicoPython via new included helpers or other objects made to be PWMOut-like wrapper classes.

add a LocoMotor class

There is a use case for instantiating a single Solenoid object with 2 pins (using 2 separate solenoids in concert): an engine akin to that that of actual locomotive trains. Think about it! Each solenoid applies force in alternating turns... Of course, this requires a new Drivetrain child class that coordinates the solenoids based on a boolean-ized sensor (like a pressure switch or hall sensor) to determine when to alternate applied force between solenoids (the default behavior of the Solenoid class when its value is changed from positive to negative and vice versa).

what about Bluetooth?

We should support the cheap BLE Serial modules via UART bus; 1 for RX-ing commands, and 1 for TX-ing. It may be possible to use Bluetooth modules if they are builtin or the MCU is Bluetooth compatible (nRF52840 based boards).

Alternative Leads

Outside of that, I think we can just use Linux Bluetooth stack to manage the devices and just grab events with python-evdev. I know CircuitPython's bleio API seems to follow IanHarvey's bluepy (for CPython) API (bluepy github). I am interested in using a webapp server running on the pi to manage the Bluetooth Devices "Trusted" list on Linux. Windows may need more research, but I've had success using a "Serial Monitor" on Windows with its builtin Bluetooth module acting as a Bluetooth Serial to my Phone's and Raspberry Pi's builtin Bluetooth modules

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.