Skip to main content

Simulation Motor Controller interface

Project description

pysmc3 - Python Library for SMC3 Motor Controllers

Table of Contents

About

pysmc3 is a Python library designed to interact with SMC3, an Arduino-based software for controlling 3-DOF motion simulators used in gaming. This library provides an alternative to the existing diagnostic tools, which are only available for Windows. The library offers a convenient abstraction of the control box, allowing you to read and write parameters as well as set motor positions.

Features

  • Abstraction of the SMC3 control box through the smc3.Box class.
  • Asynchronous communications supported by asyncio.
  • Methods to read and write parameters for the control box.
  • Methods to set motor positions with ease.

Prerequisites

  • Python 3.x

Installation

Install with pip

pip instdall smc3

Or clone the GitHub repository and install the required dependencies:

git clone https://github.com/zmij/pysmc3.git
cd pysmc3
pip install -r requirements.txt

Dependencies

  • asyncio
  • serial_asyncio
  • termcolor (for example programs)

Usage

Here's a quick example snippet that demonstrates how to move Motor A on a sine wave:

from smc3 import Box, MotorNumber
import math
import time

box = Box(device="/dev/tty.usbdevice")
print(f"SMC3 Version: {box.get_version() / 100}")

motor = MotorNumber.A
box.enable_feedback(motor)
try:
    while True:
        v = int(math.sin(time.clock_gettime(time.CLOCK_MONOTONIC)) * 512) + 512
        box.set_position(motor, v)
        box.delay(0.01)
except KeyboardInterrupt:
    box.disable_feedback()
    box.delay(1)

Examples

The repository includes several example programs:

  • show_version.py: Displays the SMC3 version number.
  • show_status.py: Shows PID settings for all motors and their current status.
  • sine.py: Moves a single motor on a sine wave.
  • rock.py: Rocks the motion simulator back and forth or side to side.
  • puke.py: Moves all three motors on a sine wave with a phase shift of 2π/3.

Limitations

While the library has been tested on a MacBook connected to a control box from the DOFReality company, further testing is required to identify potential issues.

Contributing

Feel free to fork the repository and send pull requests. All contributions are welcome!

License

Licensed under the Apache License, Version 2.0.

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

smc3-0.1.1.tar.gz (12.9 kB view details)

Uploaded Source

File details

Details for the file smc3-0.1.1.tar.gz.

File metadata

  • Download URL: smc3-0.1.1.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for smc3-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6cd1f675860988bc22ffa85c7281d7f9247dafc11cf4108ba48840b6335da98f
MD5 4f5459aeaabcaca4bfbb7b7eff573d67
BLAKE2b-256 35a22457433f9950cd3508aeea5030fd480049b56ee6f182512d491892d2e0ec

See more details on using hashes here.

Supported by

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