Skip to main content

Python SDK for hiwonder TurboPi device communication

Project description

Stand With Ukraine

Fast Wonder SDK

The Fast Wonder SDK is a Python library that facilitates communication with the Hiwonder TurboPi controller. It provides easy-to-use functions for controlling various peripherals such as RGB LEDs, buzzers, infrared sensors, and more, while ensuring reliable communication with checksum validation using CRC-8.

Features

  • Control RGB LEDs: Easily control the colors of RGB LEDs using indexed tuples.
  • Control BUZZER: Simple API to control the buzzer.
  • Control Infrared Sensors: Interface with infrared sensors to detect obstacles or follow lines.
  • Reliable Communication: Ensures data integrity with CRC-8 checksum validation for communication.
  • Configurable Serial Communication: Adjust serial communication parameters such as baud rate, timeout, etc.

Installation

To get started with Fast Wonder SDK, follow these steps:

  1. Clone the repository:
    git clone https://github.com/dmberezovskyii/fast-hiwonder.git
    

Usage

  1. Infra red sensors
    from fast_hi_wonder import InfraredSensors
    
    # Initialize the sensor with the default I2C address and bus
    sensors = InfraredSensors()
    
    # Read sensor data
    sensor_states = sensors.read_sensor_data()
    
    # Process sensor states
    for i, state in enumerate(sensor_states):
        print(f"Sensor {i+1} is {'active' if state else 'inactive'}")
    
  2. Mecanum wheels

    Polar Coordinates

In polar coordinates, we describe a point (or movement) in space using two parameters:

  • Radius (r): The distance from the origin (0,0) to the point.
  • Angle (θ): The direction of the point relative to the X-axis (horizontal axis) in degrees or radians.

In the case of your mechanism:

  • Velocity: The distance the robot moves per unit of time.
  • Direction: The angle at which the robot is moving, measured from the X-axis.

Trigonometry and Coordinate Transformation

To control the robot's movement, we break the velocity down into two components — vx and vy:

  • vx: The velocity component along the X-axis (horizontal axis).
  • vy: The velocity component along the Y-axis (vertical axis).

To calculate these components, we use trigonometric functions:

  • vx (component along the X-axis) is calculated using the cosine of the direction angle: [ vx = \text{velocity} \times \cos(\text{direction}) ]

  • vy (component along the Y-axis) is calculated using the sine of the direction angle: [ vy = \text{velocity} \times \sin(\text{direction}) ]

Example

If the robot needs to move at a speed of 100 mm/s in the direction of 30 degrees (from the X-axis):

  • ( vx = 100 \times \cos(30^\circ) )

  • ( vy = 100 \times \sin(30^\circ) )

    chassis = Motors()
    
     # Move forward at 100 mm/s in the direction of 0 degrees (forward along the X-axis)
     chassis.set_velocity(100, 0, 0)
    
     # Rotate the chassis at an angular rate of 30 degrees per second
     chassis.set_velocity(100, 0, 30)
    
     # Translate the chassis based on Cartesian coordinates (e.g., moving diagonally)
     chassis.translation(50, 50)
    
     # Stop all motors and reset movement attributes
     chassis.reset_motors()
    

Stand With Ukraine

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

turbopi_fast_sdk-0.3.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

turbopi_fast_sdk-0.3.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file turbopi_fast_sdk-0.3.1.tar.gz.

File metadata

  • Download URL: turbopi_fast_sdk-0.3.1.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for turbopi_fast_sdk-0.3.1.tar.gz
Algorithm Hash digest
SHA256 1e377bc0e809f44214dab9aeb59e02a3de4199f633324d118f24bc7b7a5a04b4
MD5 a39f1191aa49ce53a428fa6919448be3
BLAKE2b-256 b8bf49645dc029752016041b064ed4961b0e526c83d52e1373b63ef2d5b765bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for turbopi_fast_sdk-0.3.1.tar.gz:

Publisher: python-publish.yml on dmberezovskyii/fast-hiwonder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file turbopi_fast_sdk-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for turbopi_fast_sdk-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 60bf915924043266ad8e1808120cd4e2ca7c2a632dc8c3ca4c933939ca7e75cb
MD5 bbb203d31dc9d9cf4b22d91dce5a0615
BLAKE2b-256 95a16a54e5cb4205799d509de2487298779c6aa310fd82db68be068f5938ea2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for turbopi_fast_sdk-0.3.1-py3-none-any.whl:

Publisher: python-publish.yml on dmberezovskyii/fast-hiwonder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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