CAUTION! 

It is up to the user to take extreme care in making sure that custom scripts running on your T8X spider robot are carefully written to execute “safe” moves.  Just as with some industrial robots and CNC machines, if an unintended command is sent to it, it is possible for the robot or machine to damage itself.  The most common way this can occur is when a servo motor is instructed to move past an angle that it physically cannot reach.  For example, the T8X spider robot cannot scratch its own back because the configuration of the legs physically does not allow it, but when commanded to do so, it will blindly try it anyway, twisting its leg joints in unnatural ways and potentially stressing or damaging the servo motors in the process. 

In programming mode, all safety limits are turned off.  The robot will follow instructions exactly as commanded, so if you’re writing and running your own scripts or if you’re running scripts written by a third party, do so at your own risk.  We recommended that you always check and double check your code before running it.

From time to time, we will be posting scripts on our website which have been verified and tested by us to be “safe” so that any user, with or without programming experience can download and run.

 

REQUIREMENTS

For these tutorials, the programming language used is Lua, which is built into the webapp interface.  Lua is a powerful, fast, lightweight and embeddable scripting language, making it ideal for the T8X spider robot.  If you’re already familiar with some of the more popular programming languages such as Basic, C, C++, or Java, then learning Lua will be easy.  For more information on the Lua programming language as well as documentation, you can visit the Lua website at www.lua.org.

As mentioned above, improperly written code can damage the robot so we recommend that the user have at least an intermediate level of general programming experience.  If you currently do not meet this recommended requirement, you can still have tons of fun by downloading and running the scripts we provide on our website.

 

TUTORIAL CONTENTS

The tutorial series consists of four parts.  We will begin with the safest, easiest, and most useful commands first and then gradually move on towards the riskier and more advanced commands near the end of the series.

In this first tutorial, we’ll be covering the following topics: 

  • Bare minimum code
  • Changing the color of the lights
  • Body translation
  • Body rotation
  • Tail motion

 

BARE MINIMUM CODE

The following is the bare minimum code.  This code does not do anything and is only an empty canvas for the programmer to begin creating new scripts from.

 

function setup()

end

function loop()

end

 

Code that is meant to be executed only once goes inside the setup() section, while code that is meant to loop indefinitely goes inside the loop() section.

 

CHANGING THE COLOR OF THE LIGHTS

The T8X spider robot has red, green and blue LED lights built into the “eye” of the robot.  Virtually any color can be made by mixing different combinations of brightness of these colors.

The command to change the LED color is: 

t8x.cmd(“changeLEDColor < redValue > < greenValue > < blueValue > < durationInDeciseconds >”);

where:

< redValue > is the percentage of brightness of the red color.  Range is [0 to 100]

< greenValue > is the percentage of brightness of the green color.  Range is [0 to 100]

< blueValue > is the percentage of brightness of the blue color.  Range is [0 to 100]

< durationInDeciseconds > is the time it takes to fade from one color to the next.  Range = [0, 200].  One decisecond is equal to 1/10th of a second.  In other words, 10 deciseconds = 1 second.

 

Copy and paste the following code into one of the “sequenceXX.lua” slots available in the Custom Scripts section of the user interface.

Example 1.1:

function setup() 

end

function loop()

t8x.cmd("changeLEDColor 100 0 0 10");  -- change to red color in 10 deciseconds

t8x.delay(2000);                           -- wait 2000 milliseconds

t8x.cmd("changeLEDColor 0 100 0 10");  -- change to green color in 10 deciseconds

t8x.delay(2000);

t8x.cmd("changeLEDColor 0 0 100 10");  -- change to blue color in 10 deciseconds

t8x.delay(2000);

end

 

t8x.delay() instructs the program to wait a certain amount of time in milliseconds before moving on to the next line of code.  Here, delay(2000) means to wait 2000 milliseconds (2 seconds) before moving on to the next command. 

In this example, the LED color should fade from red, to green, to blue, loop back to red, and so on.   The last parameter of the changeLEDColor command indicates how long it takes to fade from one color to another.  In this case, it takes 10 deciseconds (1 second) to smoothly transition from one color to another.  For instant color change, simply set this transition time to 0.

Note that in t8x.delay(), time is expressed in milliseconds while with t8x.cmd() time is expressed in deciseconds.  There is a reason for this, which we will not go over in this tutorial.

In Lua, the double dash “--” is used to indicate comments.  Anything typed on the right side of “--” will not be executed.

 

BODY TRANSLATION

The command for body translation is:

t8x.cmd("translateBodyTo < axis > < positionInMillimeters > < durationInDeciseconds >"); 

where:

< axis > indicates the direction of motion.

                0 = x-axis, for shifting the body of the T8X left and right.

                1 = y-axis, for shifting the body of the T8X forward and backward.

                2 = z-axis, for shifting the body of the robot up and down.

< positionInMillimeters > is the position in millimeters along the chosen axis. 

If the previous parameter, < axis > is 0:

The center position is 100.  Range is [0 to 200].  Left body shift is done using numbers between 0 and 99 while right body shift is done using numbers between 101 and 200.

If the previous parameter, < axis > is 1:

The center position is 100.  Range is [0 to 200].  Backward body shift is done using numbers between 0 and 99 while forward body shift is done using numbers between 101 and 200.

If the previous parameter, < axis > is 2:

The floor position is 0.  Range is [0 to 200].  Any value above 0 will move the robot to this specified height in millimeters above the floor.

< durationInDeciseconds > is the time it takes to transition from one position to the next.  Range = [0, 200].  One decisecond is equal to 1/10th of a second.  In other words, 10 deciseconds = 1 second.

 

In summary, the coordinate system for body translation is:

  • Positive x-axis is towards the right, with origin at 100 and range [0, 200]
  • Positive y-axis is in the forward direction with origin at 100 and range [0, 200]
  • Positive z-axis is up with the floor at 0 and range [0, 200]
  • All distances are in millimeters

 

Let’s do some spider push-ups with this next example.

Example 1.2:

function setup()

t8x.cmd("translateBodyTo 2 90 5"); --change height to 90mm

t8x.delay(1000);

t8x.cmd("translateBodyTo 2 50 5"); --change height to 50mm

t8x.delay(1000);

end

function loop()

end

 

Since < axis > = 2, the direction of motion is along the z direction, which is vertical.  The height alternates between 50 and 90mm, and it takes 0.5 seconds to transition from one position to another.

Notice how this time, the code has been placed inside setup() instead of loop().  This is ideal if you want the script to run only once instead of looping indefinitely.

 

The following example will demo the X and Y axes.

Example 1.3

function setup()

end

function loop()

t8x.cmd("translateBodyTo 0 80 5"); --move to left position 20mm

t8x.delay(1000);

t8x.cmd("translateBodyTo 0 120 5"); --move to right position 20mm

t8x.delay(1000);

t8x.cmd("translateBodyTo 0 100 5"); --move back to center x-axis

t8x.delay(1000);

 

t8x.cmd("translateBodyTo 1 120 5"); --move to forward position 20mm

t8x.delay(1000);

t8x.cmd("translateBodyTo 1 80 5"); --move to backward position 20mm

t8x.delay(1000);

t8x.cmd("translateBodyTo 1 100 5"); --move back to center y-axis

t8x.delay(1000);

end

 

BODY ROTATION

The command for body rotation is:

t8x.cmd("rotateBodyTo < axis > < angleInDegrees > < durationInDeciseconds >");

where:

< axis > indicates the direction of motion.

                0 = x-axis, for pitch

                1 = y-axis, for roll

                2 = z-axis, for yaw

< angleInDegrees > is the angle in degrees along the chosen axis. 

If the previous parameter, < axis > is 0:

The center angle is 100.  Range is [40 to 160].  Pitching down is done using numbers between 40 and 99 while pitching up is done using numbers between 101 and 160.

If the previous parameter, < axis > is 1:

The center angle is 100.  Range is [40 to 160].  Rolling left is done using numbers between 40 and 99 while rolling right is done using numbers between 101 and 160.

If the previous parameter, < axis > is 2:

The center angle is 100.  Range is [40 to 160].  Yawing left is done using numbers between 40 and 99 while yawing right is done using numbers between 101 and 160.

< durationInDeciseconds > is the time it takes to transition from one position to the next.  Range = [0, 200].  One decisecond is equal to 1/10th of a second.  In other words, 10 deciseconds = 1 second.

 

Example 1.4

function setup()

t8x.cmd("rotateBodyTo 0 80 5"); -- pitch down 20 degrees

t8x.delay(1000);

t8x.cmd("rotateBodyTo 0 120 5"); -- pitch up 20 degrees

t8x.delay(1000);

t8x.cmd("rotateBodyTo 0 100 5"); -- return to center pitch

t8x.delay(1000);

 

t8x.cmd("rotateBodyTo 1 120 5"); -- roll right 20 degrees

t8x.delay(1000);

t8x.cmd("rotateBodyTo 1 80 5"); -- roll left 20 degrees

t8x.delay(1000);

t8x.cmd("rotateBodyTo 1 100 5"); -- return to center roll

t8x.delay(1000);

 

t8x.cmd("rotateBodyTo 2 120 5"); -- yaw right 20 degrees

t8x.delay(1000);

t8x.cmd("rotateBodyTo 2 80 5"); -- yaw left 20 degrees

t8x.delay(1000);

t8x.cmd("rotateBodyTo 2 100 5"); -- return to center yaw

t8x.delay(1000);

end

function loop()

end

 

TAIL (ABDOMEN) MOTION

The command for tail motion is:

t8x.cmd("moveTail < direction > < angleInDegrees > < durationInDeciseconds >");

where

< direction > is the direction of motion

                0 = horizontal

                1 = vertical

< angleInDegrees > is the angle in degrees along the chosen axis.  The center angle is 90.  Range is [60 to 120].

< durationInDeciseconds > is the time it takes to transition from one position to the next.  Range = [0, 200].  One decisecond is equal to 1/10th of a second.  In other words, 10 deciseconds = 1 second.

 

Example 1.5:

function setup() 

t8x.cmd("moveTail 0 110 5");    -- move tail 20 degrees right

t8x.delay(1000);

t8x.cmd("moveTail 0 70 5");     -- move tail 20 degrees left

t8x.delay(1000);

t8x.cmd("moveTail 0 90 5");     -- horizontally center the tail

t8x.delay(1000);

 

t8x.cmd("moveTail 1 110 5");    -- move tail 20 degrees up

t8x.delay(1000);

t8x.cmd("moveTail 1 70 5");     -- move tail 20 degrees down

t8x.delay(1000);

t8x.cmd("moveTail 1 90 5");     -- vertically center the tail

t8x.delay(1000);

end

function loop()

end

 

This concludes the first tutorial for the T8X spider robot.  If you’re having trouble getting the code to work on your T8X, do not hesitate to contact us at support@robugtix.com.

If you have feedback, suggestions, want to report an error, or have an interesting script you would like to share with us, please email us at feedback@robugtix.com

This page may be updated or further expanded in the future based on feedback from users.