Upgrade to ARC Pro

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming


Servo Script

Bind a script to servo position movements.

+ How To Add This Control To Your Project (Click to Expand)
  1. Make sure you have the latest version of ARC installed.
  2. Select the Get button in this page to download the archive file.
  3. Double click the downloaded archive file to execute installer.
  4. The installer will add this control to ARC.
  5. Load ARC and press the Project -> Add Control button from the menu.
  6. Choose the Scripting category tab.
  7. Press the Servo Script icon to add the control to your project.


Bind a script to servo position movements. This allows you to create scripts that run each time a servo is moved. A good use-case for this is to control a Serial Bus style servo as a real servo by binding to a specific servo port. Meaning, if you had a servo that worked via Serial UART and wanted it to operate like a regular ARC servo, you could write code here to bind to it. 

The alternative method to this would be creating your own robot skill that binds to the servo movement event. This is covered in the Getting Started guide for Technology Creators. However, since creating a plugin control isn't viable for a quick hack to get something working, you may use this plugin control.

Get Started With servo Script
1) Identify the command structure or protocol for your custom servo

2) Press the GEAR configuration icon on this control

3) Specify what Board # it will be (0 is default)

4) Specify what servos to monitor for position (i.e. v1, v2, v3, v4, etc)

5) Edit the script that will run for every servo position that matches the selected ports you have binded to. The example code contains fake data of Position, Port & speed. You will want to use that fake data for testing within the editor. However, you will want to comment out the "test" variables before using your scripts with real data.

The test data merely simulates what would be expected when the program runs on each servo movement. For example, the test data includes...


var positions = [90, 90, 90];
var ports = [v1, v2, v3];
var speeds = [0, 0, 0];

In the real data, these variables would contain matching array lengths relevant to the requested servo movement. A servo on V1 may be requested to move, and you have binded to V1, so ports would contain v1. etc...

The Example Script
When you create a new row for binding to a servo movement, a default script is created. Here is a preview of what you have to work with.


// These variables are created for testing only.
// Comment these variables out when you're ready to test with real data.
// The real data will be dynamically created based on the servos, positions and speed.
// If you keep these uncommented during real data tests, the real data will never be
// used.
// For testing, you will want to add your ports and some fake values.

// Fake values here. Comment these out after editing...
var positions = [90, 90, 90];
var ports = [v1, v2, v3];
var speeds = [0, 0, 0];

// Loop through the ports, positions and their speeds
for (var i = 0; i < ports.length; i++) {

var position = positions[i];
var port = ports[i];
var speed = speeds[i];

// Do something with the position, port and speed

// This is for debugging. Comment out when everything is working
print("servo: " + port + " to " + position);



Upgrade to ARC Pro

Harnessing the power of ARC Pro, your robot can be more than just a simple automated machine.