Firmata IO Controller

Firmata is a communications protocol that can be run on micro controllers boards like the Arduino that essentially turn the micro controller into a programmable extension of the master computer. An application can query a connected board and dynamically configure the individual pins to determine what type of IO control they will perform. This fits in well with the AnimatLab Robotics Framework because it again takes the programming aspects off the end user. You simply have to flash the provided Arduino sketch onto your board, plug-in the various components to the correct pin, and then configure your robot part interfaces and you are done. No programming required on your part. Firmata has a number of different input and output components that are available in the Standard Firmata sketch that comes with the Arduino software. (File->Examples->Firmata->StandardFirmata). However, I have also built a new ArbotixFirmata sketch that works with the Arduino compatible Arbotix Controller from Trossen Robotics to also allow you to control Dynamixel motors directly using Firmata. Please see the Arbotix Firmata page on how to install and use this new sketch and the C++ interface code to talk to it.

 

To use the Firmata IO controller right click on your robot interface and select Add IO Controller. Select the Firmata controller. When you plug your Arduino into the computer it will add a new serial port for communications with it. Before you can use this with AnimatLab you will first need to upload the Firmata Sketch to the Arduino micro controller. If you want to load the standard Firmata then start the Arduino software and open the sketch (File->Examples->Firmata->StandardFirmata). Select the board type and serial port and then hit Upload. It will compile and upload Firmata to your board. If everything worked correctly it will tell you that the upload was successful. You can now use this with AnimatLab. You will need to configure port setting on the Firmata IO control to match the port for your board. If you are using the default Sketch please change the baud rate to 57600. If you are using the ArbotixFirmata then use the default rate of 115,200. You can of course change these baud rates in both the sketch and the IO config to use higher data transfer rates if you want. Next, right click on the Firmata IO and select Add Part. You will get a dialog with a number of options. Below is a list of each of the available part types.

Analog Input:  This part allows you to specify one of the analog input pins to poll. When a change is detected on this pin it will send that information back to the simulation and update the associated value in the linked part.
  Pin: This is the pin on the Arduino to monitor.
  Linked Part: This is the body part or neural part that you can connect this input with.
  Linked Property: This is the property that will be set for the linked part. When a change is detected by the Arduino it will send this to the IO controller, transform it using the gain and then set this property to the new value.
  Gain: This is used to turn the input value in fixed-point into a value appropriate for the part you are connected with. For example, the analog signal converts 0-5 volts to a value of 0-1023 fixed point. If you wanted this to control the current applied to a neuron you would need to setup a gain that would convert 0-1023 into a current and then set the Linked Property to be external current, or adapter current. When a value comes in from the analog sensor it will translate that into a current and apply it to the neuron, which will change its rate of firing.
 
  Digital Input: This part allows you to specify one of the digital input pins to poll. When a change is detected on this pin it will send that information back to the simulation and update the associated value in the linked part.
  Linked Part: This is the body part or neural part that you can connect this input with.
  Linked Property: This is the property that will be set for the linked part. When a change is detected by the Arduino it will send this to the IO controller, transform it using the gain and then set this property to the new value.
  Gain: This is used to turn the input value in fixed-point into a value appropriate for the part you are connected with. For example, the digital signal will either be 0 or 1. If you wanted this to control the current applied to a neuron you would need to setup a linear gain with the current you would like injected when the signal is 1, and then set the Linked Property to be external current, or adapter current. When a value comes in from the digital sensor it will translate that into a current and apply it to the neuron, which will change its rate of firing.
 
  Digital Output: This part allows you to set a digital output based on the value of a property in your model. You specify the digital pin on the Arduino you want it to control, and the associate the part and property that will control it. A gain will convert that property value into 0 or 1. The IO thread will detect these changes and send that to the Firmata sketch running on the Arduino to set the physical pin to the same value.
  Pin: This is the pin on the Arduino to set.
  Linked Part: This is the body part or neural part that you can connect this output with.
  Linked Property: This is the property that will be set for the linked part. When a change is detected in the model it will transform the property value into a boolean value using the gain, and then send it to the micro-controller.
  Gain: This is used to turn the property value into a boolean output.
 
  Dynamixel Hinge Servo: This part allows you to control a Dynamixel motor using a hinge joint within your model. Please see the Dyanmixel USB page for details on how to configure these servos.
 
  Dynamixel Prismatic Servo: This part allows you to control a Dynamixel motor using a hinge joint within your model. Please see the Dyanmixel USB page for details on how to configure these servos.
 
  Standard Hinge Servo: This part allows you to control a standard servo motor using a hinge joint within your model. Standard servos use a pulse width modulation (PWM) signal to set their position. Unlike the Dynamixel servos, they are not networked, so each one requires its own pin for control. Also, you cannot directly set their position and velocity like you can with the Dynamixel, or directly read back any data from an unmodified servo. (It is possible to take them apart and modify them to get position data. However, that is beyond the scope of what we are doing here.) This means that only position control is really available for use with the standard servos. If you wanted to do velocity control then you would have to control its position directly to move it at the speed you want, and this would require a very fast feedback loop.
 
  Standard Prismatic Servo: This part allows you to control a standard servo motor using a prismatic joint within your model. Standard servos use a pulse width modulation (PWM) signal to set their position. Unlike the Dynamixel servos, they are not networked, so each one requires its own pin for control. Also, you cannot directly set their position and velocity like you can with the Dynamixel, or directly read back any data from an unmodified servo. (It is possible to take them apart and modify them to get position data. However, that is beyond the scope of what we are doing here.) This means that only position control is really available for use with the standard servos. If you wanted to do velocity control then you would have to control its position directly to move it at the speed you want, and this would require a very fast feedback loop.
 
  PWM Output: This part allows you to send a pulse width modulation signal from a given pin based on a property value within your model.
  Pin: This is the pin on the Arduino where the signal will be generated.
  Linked Part: This is the body part or neural part that you can connect this output with.
  Linked Property: This is the property that will be used to control the PWM output.
  Gain: This is used to convert the property value into a valid fixed point number used by the micro-controller to generate the PWM output. PWM on the Arduino uses a fixed point value from 0-255 to control the frequency, where 0 is always off and 255 is always on.