Skip to main content

A simplified version of the dji robomaster library with some addons. Made for the bendigo tech school.

Project description

BTS-dji

Table of Contents

Description

BTS-dji is a library designed to assist children in programming the DJI Robomasters and DJI Tellos in a simple way. It includes additional features to provide extra help to children, and it was specifically created for the Bendigo Tech School.

BTS-dji.Robomaster

BTS-dji.Robomaster is a Python library for controlling a robot. Below is a list of functions that can be used to interact with the robot:

  • robot.start(): This function starts the robot and shows the camera feed.

  • robot.driveWheels(fr, fl, bl, br): This function controls the speed of each wheel individually, setting it to a value between 200 and -200. The variables are:

    • Wheels
    • fr = front right
    • fl = front left
    • bl = back left
    • br = back right Example: robot.driveWheels(w1=w1, w2=w2, w3=w3, w4=w4) # drive each wheel at a given speed
  • sleep(t): This function pauses your code for a specific amount of time. The variable is:

    • t = time Example: sleep(10) # sleep for 10 seconds
  • robot.gripper(t, d): Use this function to open or close the gripper on the robot's arm, with "d" indicating the direction (-1 for close, 1 for open). The variables are:

    • t = time
    • d = direction Example: robot.gripper(0.5, 1) # time | direction 1 or -1
  • robot.arm(x, y): This function moves the robot's arm relative to its current position. For example, if it's currently at position (20, 20), a movement command of (10, 10) would move it to (30, 30). The variables are:

    • x = forward
    • y = up/down Example: robot.arm(10, 10) # move arm by 10 x and 10 y
  • robot.LED(r, g, b): Use this function to set the color of the robot's LEDs using RGB values ranging from 0 to 255. The variables are:

    • r = red
    • g = green
    • b = blue Example: robot.LED(255, 255, 255) # r g b

Here is an example code snippet that demonstrates how to use the Robomaster library to control a robot:

from BTS-dji import Robomaster as robot  # import the Robomaster module from BTS-dji library
from time import sleep  # import the sleep function from the time module

robot.start()  # start the robot

def drive():  # define the drive function

    # set the speed of each wheel to 1000 for one second
    w1 = 1000
    w2 = 1000
    w3 = 1000
    w4 = 1000
    robot.driveWheels(w1=w1, w2=w2, w3=w3, w4=w4)
    sleep(1)  # pause for one second

    # set the speed of all wheels to 0
    w1 = 0
    w2 = 0
    w3 = 0
    w4 = 0
    robot.driveWheels(w1=w1, w2=w2, w3=w3, w4=w4)

def gripper():  # define the gripper function

    # open and close the gripper on the robot's arm
    robot.gripper(0.5, 1)
    robot.gripper(0.5, -1)

def arm():  # define the arm function

    # move the robot's arm to two different positions and pause for two seconds in between
    robot.arm(10, 10)
    sleep(2)
    robot.arm(30, 30)

def led():  # define the led function

    # set the color of the robot's LEDs to white for two seconds, then to green
    robot.LED(255, 255, 255)
    sleep(2)
    robot.LED(0, 255, 0)
    
drive()  # calls drive
arm()  # calls arm
gripper()  # calls gripper
led()  # calls led

BTS-dji.Tello

BTS-dji.Tello is still in development and not yet available.

BTS-dji.Controler

BTS-dji.Controler is a simple gamepad/joystick input library designed for beginners in Python. To use it, follow these steps:

  1. Import the module.
  2. Start the script by running Controler.start().
  3. To check if a button or joystick is pressed, run input = Controler.get_state(0).
  4. The input variable is a dictionary that contains the states of all buttons and joysticks. You can access the state of a specific button or joystick by looking it up in the dictionary using its name, for example: print(input["button_a"]) will return either 0 or 1 depending on whether the 'A' button is currently pressed or not.
from BTS-dji import Controler  # import controler

Controler.start()  # start the controler listener

while True:
    input = Controler.get_state(0)  # get the state of the controler
    print(input["a"])  # print the state of the "a" button

BTS-dji.kbd

BTS-dji.kbd is a simple keyboard input library designed for beginners in Python. To use it, follow these steps:

  1. Import the module.
  2. Start the script by running kbd.start().
  3. To check if a key is pressed, run input = kbd.get_state(0).
  4. The input variable is a dictionary that contains the states of all keys. You can access the state of a specific key by looking it up in the dictionary using its name, for example: print(input["b"]) will return either 0 or 1 depending on whether the 'b' key is currently pressed or not.
from BTS-dji import kbd  # import kbd

kbd.start()  # start the kbd listener

while True:
    input = kbd.get_state(0)  # get the state of the kbd
    print(input["a"])  # print the state of the "a" key

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

BTS-dji-0.1.10.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

BTS_dji-0.1.10-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file BTS-dji-0.1.10.tar.gz.

File metadata

  • Download URL: BTS-dji-0.1.10.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for BTS-dji-0.1.10.tar.gz
Algorithm Hash digest
SHA256 66ec1b859ffcecc7c4b7fa7c37ef94f701d9243cb4353a3a874ed23cc3f38e75
MD5 27a8ac53a751d26799accfbf9a420348
BLAKE2b-256 578cd9054f0a62052e8af1077b0683f9f40b460dec1dc114ca4ad7fe16635e45

See more details on using hashes here.

File details

Details for the file BTS_dji-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: BTS_dji-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for BTS_dji-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 ec7cbc930f6e69d206b256c8941ac40eac0184e991b42d45c855f2cbba478039
MD5 f3631288c0a412e356077633a0856369
BLAKE2b-256 0c1be2cc1fce7e064a37da04523124eeff7cb8fb9c7ec4b6549f21aebe02cca6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page