Skip to content

A suite to make an Arduino board communicate with Autodesk Maya

Notifications You must be signed in to change notification settings

giuliom95/arduino-maya

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Arduino-Maya communication suite

Software to make an Arduino board and a Maya session communicate.
This can be particularly useful to create custom input devices.
It is programmed in Python and Arduino language. It uses pySerial (https://github.com/pyserial/pyserial).
See it working on my twitter and on my July 2017 reel.

Directory structure

This repository contains:

  • A Maya Python API/PyMEL plugin (src/maya)
  • A Python script to read the serial stream incoming from Arduino and feed it to Maya via socket connection (src/driver)
  • An Arduino test firmware (src/arduino)

How to use this

What do you need

  • An Arduino board. I've used an UNO v3. Other boards are ok. Just watch out for interrupt mappings
  • Three potentiometers. I recommend sliders. But the choice is yours
  • Jumper wires
  • pySerial (https://github.com/pyserial/pyserial)
  • Maya. I've used the 2017 v3 Student Edition. Not too old versions are fine too

Quick Start

  1. Follow this circuit diagram to make the connections:
    Circuit diagram
  2. Flash the Arduino sketch src/arduino/firmware.ino to your board.
  3. Put the src/maya-plugin/arduinomaya.py plugin into the Maya plug-ins folder.
  4. Load the arduinomaya.py plugin within a Maya session.
  5. Start the src/driver/serial2maya.py script.
  6. Connect the three available channels using the GUI that can be brought up with the arduinoGUI command.
  7. Enjoy.

How does this works

Here an approximate system diagram:
System diagram
The data flow is pretty simple. The potentiometers generate analog signals. The Arduino board converts them with its ADC and sends them through serial connection to the computer where Maya is running. Here the signals are translated into Maya commands and are feeded to the Maya session through its commandPort socket. Finally, Maya must understand them and modify the current scene.

To make this work, three software pieces are needed: the Arduino firmware, the "Serial to Maya" driver, and a Maya plugin. Here the details for each piece.

1: The firmware

The provided Arduino firmware reads the three analog signals that comes into A0,A1, and A2 ports. Every ~30ms it puts the delta value for each port in to the Serial outgoing stream.

2: The "bridge" program

It is a Python script that uses the pySerial lib for Arduino to PC serial communication and the socket module to send messages to Maya. It runs an endless loop that launches the MEL command defined in the Maya plugin.

3: The Maya plugin

The plugin adds four commands. Usually the user should invoke only arduinoGUI.

  • arduinoGUI: Brings up the GUI.
  • arduinoConnectAttribute <channel> <object> <attribute>: This connects the channel to the attribute of the given object. The attribute must be a float attribute. Example: arduinoConnectAttribute 0 pCube1 rotateX this connects the first channel (or potentiometer if you are using the firmware provided here) to the attribute rotateX of the pCube1 object.
  • arduinoConnectTime <channel>: This connects channel to the time slider.
  • arduinoUpdateChannel <channel> <delta>: Adds delta to the attribute connected to channel.

About

A suite to make an Arduino board communicate with Autodesk Maya

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published