Giter Site home page Giter Site logo

j5's Introduction

j5

Tests Test Coverage Maintainability Documentation Status PyPI version MIT license Bees

j5 Framework - Creating consistent APIs for robotics

What is j5?

j5 is a Python 3 framework that aims to make building consistent APIs for robotics easier. It was created to reduce the replication of effort into developing the separate, yet very similar APIs for several robotics competitions. Combining the common elements into a single library with support for various hardware gives a consistent feel for students and volunteers. This means more time to work on building robots!

How do I use j5?

j5 is designed to never be visible to students. It sits behind the scenes and works magic.

from robot import Robot

r = Robot()
r.motor_boards[0].motors[1] = 0.5

The above code is likely to be familiar to any student who has competed in one of the below competitions. However, it is not a trivial problem to make this code portable across the platforms. For example, the motor board for Student Robotics is a separate board to the brain board, but is built into the same board for HR RoboCon.

j5 lets competition vendors define how the basic parts of the apis are accessed. A robot can thus be constructed from any combination of parts from various organisations.

from j5 import BaseRobot
from j5.backends.hardware.sr.v4 import (
    SRV4MotorBoardHardwareBackend,
    SRV4PowerBoardHardwareBackend,
    SRV4ServoBoardHardwareBackend,
)
from j5.boards import BoardGroup
from j5.boards.sr.v4 import MotorBoard, PowerBoard, ServoBoard


class Robot(BaseRobot):
    """My Competition Robot."""

    def __init__(self) -> None:
        self._power_boards = BoardGroup.get_board_group(
            PowerBoard,
            SRV4PowerBoardHardwareBackend,
        )
        self.power_board = self._power_boards.singular()

        self.motor_boards = BoardGroup.get_board_group(
            MotorBoard,
            SRV4MotorBoardHardwareBackend,
        )
        self.motor_board = self.motor_boards.singular()

        self.servo_boards = BoardGroup.get_board_group(
            ServoBoard,
            SRV4ServoBoardHardwareBackend,
        )
        self.servo_board = self.servo_boards.singular()

Competitions

We intend to support the kits of the following robotics competitions:

As of 2023, j5 is written and maintained by the Student Robotics Kit Team.

sbot, a j5 based API, was successfully deployed to over 100 users in August 2019. This is the first known case of a real-world deployment of a j5 based API.

If you are interested in adding support for your hardware or building your own API, please get in touch.

Contributions

This project is released under the MIT Licence. For more information, please see LICENSE.

j5 contributors refers to the people listed in the CONTRIBUTORS file.

The CONTRIBUTORS file can be generated by executing CONTRIBUTORS.gen. This generated file contains a list of people who have contributed to the j5 project.

More information about contributing, and how to contact contributors can be found in our docs

j5's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar henry-oliver-edwards avatar hu90m avatar kierdavis avatar mildlyincompetent avatar pringon avatar raccube avatar realorangeone avatar sedders123 avatar shivam60 avatar skybound1 avatar tpoomlmly avatar trickeydan avatar udhayacommits avatar willb97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

j5's Issues

[FEATURE] Hardware Support

We should aim to support hardware.

Specific hardware boards should be listed as separate issues below:

  • SR v4 Power Board
  • SR v4 Motor Board
  • SR v4 Servo Board
  • SR Ruggeduino
  • SourceBots Arduino / Servo Board

[QUESTION] How does proposed class structure cope with differing capabilities of boards?

How does the j5's class structure cope with the fact that in some environments (i.e. competitions) two APIs are physically implemented by two different boards, while in other environments they are implemented by the same board?

As a concrete example, Student Robotics provides a servo interface via a servo board and a GPIO interface via an Arduino, but Source Bots provides both of these interfaces via an Arduino (with an attached servo driver shield). Therefore code to operate a servo may look like:

robot.servo_boards[0].servos[0] = position

in a Student Robotics environment while looking like:

robot.arduinos[0].servos[0] = position

in a Source Bots environment. This inconsistency feels counterproductive to the goal of j5.

As another example, Arduinos run different firmwares in different environments: the Source Bots Arduino firmware has builtin support for ultrasound sensors while the Student Robotics firmware does not.

READ ME FIRST: How to contribute

How to contribute

  • Pick an issue that is currently unassigned.
  • Assign yourself to that issue.
  • Write some code!
  • Ensure that you lint, type and unit test your code.
  • Submit a Pull Request, including Fixes #issuenum in the description
  • Make sure that the tests pass.
  • Sign the CLA.
  • Wait for Code review to be approved.
  • Merge!

[QUESTION] Are BackendGroups extensible?

From my understanding of how j5 is currently structured (please correct me if I'm wrong), it looks like a BackendGroup must have knowledge of every type of board that could provide. It also doesn't look like HardwareBackendGroup (and presumably other types of BackendGroup too, once they are defined) is competition-specific, so a HardwareBackendGroup therefore needs to have every board used in every competition hardcoded into it. Additionally, I'm not certain but it sounds like this structure would restrict the ability for end users to define their own boards using the j5 API.

If this is indeed true, my proposal would be for BackendGroups to be initially empty, and to have each Backend register itself into its corresponding BackendGroup at the time of class definition.

[BUG]: Bad naming convention on BackendGroup

The BackendGroup class currently has a supported_boards property. This is confusing, as it actually returns a dictionary of boards to their backends, but should probably return a List of supported boards.

[FEATURE] Locks

We need to have a lock to prevent multiple robot processes. Suggestions are to use /var/run, but that does lock it down to be platform specific which we do not want.

Autodeploy releases to PyPI

Possible methods:

  • Git Tags (But need to restrict permissions)
  • GitHub Releases, requires a separate server to receive the webhook.

[FEATURE] Mock Hardware

We should aim to support hardware in mock.

Specific hardware boards should be listed as separate issues below:

  • SR v4 Power Board
  • SR v4 Motor Board
  • SR v4 Servo Board
  • SR Ruggeduino
  • SourceBots Arduino / Servo Board

Create Vision Components

We need to find a nice way to model fiducial markers without restricting ourselves to a particular library.

My initial suggestions:

  • Camera Component representing a camera
  • Token - data type of a token
  • Vector - The distance and direction of a token from a camera.
    • Spherical coordinates
    • Cartesian coordinates, we need to support this for less knowledgeable competitors
  • Orientation - The orientation of a token in 3D space

BoardGroup.__iter__ should return a disposable object, not itself

Currently, BoardGroup.__iter__ returns self, and uses an attribute of self to maintain state. This confuses the lifetime of a collection with the lifetime of an iteration over that collection. This method should really return a distinct object encapsulating the statefulness of iteration (self.boards.values(), for example).

If this gets a ๐Ÿ‘ or two I'll go ahead and make a PR.

Support SR Ruggeduino

Requires GPIO Pin - #43

We need to think about how to support direct communication. Perhaps some sort of serial component?

Enforce type hints on all code

Now that the majority of the project has type hints, we should try to keep it that way. We can enforce this by changing our mypy settings to enforce code has type hints.

I propose we enable the following flags, though I'm open to discussion (these are the command line flags but they have equivalent .cfg options):

  • --disallow-untyped-defs
  • --disallow-incomplete-defs
  • --no-implicit-optional (this one is more personal preference and less to do with maintaining type coverage)

Docs for the above flags can he found here

Review whether BoardGroups should be ordered or not

There is no inherent order to the boards attached to a robot. We should make a decision whether we want to keep this notion (requiring users to address boards by serial number), or to assign an order (in which case we need to be explicit about what that order is e.g. sort by serial number)

This is relevant to #23.

I'm happy to implement the outcome of this decision in a PR.

No check for setup method call

The board.setup() method can easily be not called by the vendor, leading to a lack of safety for that board.

Possible fixes:

  • Use __new__
  • In the constructor (causes the same issue as super())
  • Metaclass

[FEATURE] Hooks

We need to be able to support the start button.

In order to keep this nice and flexible, I'm going to suggest doing this using hooks on the lifecycle of a board.

Add PowerOutput Component

We need a component to represent the power outputs on the power board.

Another nice things would be a neat way to group them together.

Add a BatterySensor Component

We need a component to represent the battery sensing circuitry in the power board.

We can read both current and voltage from that sensor.

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.