In my previous post, I mentioned a tool called "Servo tools for Maya" by Dan Thompson. This tool was recommended to me by my mentor, but when I wanted to download the tool, the website was no longer online. Luckily my mentor was able to provide me with the tool and I have been working with it since.
Around 2008 Dan Thompson established a connection between Autodesk Maya and an Arduino. With this connection, Thompson is able to animate a servo by rotating a 3D model in Autodesk Maya. To establish this connection Thompson created a few scripts.
The scripts can be divided into 3 categories. The first group is MEL scripts which make up the actual tool in Maya. The second group consists of Python scripts that establish a serial connection with Maya. The third group is a singular C++ script for the Arduino. This script reads the data received from the serial port and converts it to servo input. A library called PySerial, which provides support for Serial connection, is required to write Python data to the serial port.
Since the Tool originates from 2008, it wasn't expected that it would work without a hitch. While doing research on this tool some concerns had risen:
The program Autodesk Maya received many updates since the creation of this tool, one of which is the update from a 32-bit system to a 64-bit system. People working with this tool mentioned that the PySerial library no longer works with Maya since the library is made for 32-bit programs.
Another concern of mine was that the Python version I'm running on my PC is Python 3.9. Maya runs Python 2.7.11 and the scripts are written in Python 2x.
Instead of using the same version of Maya, Python, and PySerial as Thomspon used in his video, I used the latest versions of Python and PySerial and Maya 2018 since this was already installed. This might have been a bold move on my side, but the idea behind using these versions was that I didn't want to use "outdated" software.
Reflection
What I could have done instead is try to get this tool to work with the versions Thompson used. As soon as it would work I could have tried with current versions of the software.
Installing the tool
For the installation of the tool, I tried to follow Dan Thompson's video but had to change a few things due to different software versions. In the video, Thompson explains where the scripts need to be placed in order for the tool to work. Instead of placing the PySerial library and .py scripts in the Python version I'm running outside of Maya, I placed them inside of Maya's included Python.
In the scripts, I changed the COM port to COM4 since this is the port I assigned to the Arduino and I adjusted some functions to fit the Python 3x. syntax.
The first few tests resulted in an error message. ( > screenshot error messages < )The script expected an integer value but, received a float value. When looking at the Arduino you could see that a LED started to blink as soon as you started to move the 3D model. This LED indicated that it was receiving something. In order to try to fix the error, the round() function was used to round the float to its nearest whole number. Using a print line before and after the rounding function, you could see the change.
print angle
angle = round(angle)
print angle
( > screenshot print value < )The result was not what I expected. The number rounded but kept a 0 after the comma.
The following code fixed the problem.
print angle
angle = int(round(angle))
print angle
( > Screenshot print value 2 <)
Once the error was fixed the communication worked:
Figure 1. Communication between servo and Autodesk Maya (Own work)
Jennifer, I'm an animatronic designer from the UK, I would absolutely kill for a chance to talk about how you got this up and running, the original video tutorials are down so I'd happily reward you if you can help me set this up on a modern version of Maya. my email is ostwaldsam@gmail.com