Servo Script

by Synthiam

Bind a script to servo position movements.

How to add the Servo Script robot skill

  1. Load the most recent release of ARC (Get ARC).
  2. Press the Project tab from the top menu bar in ARC.
  3. Press Add Robot Skill from the button ribbon bar in ARC.
  4. Choose the Scripting category tab.
  5. Press the Servo Script icon to add the robot skill to your project.

Don't have a robot yet?

Follow the Getting Started Guide to build a robot and use the Servo Script robot skill.

How to use the Servo Script robot skill

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. If you had a servo that worked via Serial UART and wanted it to operate as a regular ARC servo, you could write code here to bind to it.

The alternative method would be creating your 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 the default)

  4. Specify what servos to monitor for the 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 bound to. The example code contains fake data of Position, Port & speed. You will want to use that simulated data for testing within the editor. However, you will want to comment on the "test" variables before using your scripts with accurate 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];

These variables would contain matching array lengths relevant to the requested servo movement inaccurate data. A servo on V1 may be requested to move, and you have bound to V1 so that ports would contain v1. Etc...

The Example Script A default script is created when you create a new row for binding to a servo movement. 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

Experience the transformation – subscribe to Synthiam ARC Pro and watch your robot evolve into a marvel of innovation and intelligence.


v9 has been updated for a fix with the new JavaScript engine to ensure it has been initialized.


Thank you  for your amazingly fast response with this fix.