Asked — Edited

Multi-Threading With The Ez Script

HI Everyone

I am new to EZ and am wondering if I can have the Ultrasonic sensor detect distances while the EZ is moving, not in between movement. So far the closest thing I am able to do is move then sense, but sometimes during the movement I go past my desired sensor value.

Any thought/tip/advise

Thanks, Graham


Upgrade to ARC Pro

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.


Of course... that's not all, you can run many controls/scripts all at once. The ezb4 is a fully multitasking robot controller... Drive, talk, avoid objects, listen for voice commands, play music, track objects (objects, face, colour) look up stuff on the internet, etc, etc, etc......all at once if you want:)


As usual, Richard's beat me to it again! If you can expand further on your robot and project, we can help you.

Each control in ARC is a separate thread. The software was developed with that in mind - to enable each behavior to run asynchronous my of each other. Communication between controls is done with the ControlCommand() in Ez-script.

Do not confuse behavior with actions. An action is the final result of what a robot is doing (i.e. Moving, talking, etc). The skill controls produce actions.

So, in short... Every control is a separate thread which means you can have separate actions and scripts running at the same time.

United Kingdom

You mean you want to do something like this?:)

That script does lots of things at the same time, without issue.


Wow, thanks for the help!

I guess I should explain my scenario. I am currently teaching a grade 11 robotics course and we have set up a maze for the robots to solve (we have the educational 3 pack).

In short, we are having the six robot:

  • detect a color on the wall using the camera,
  • turn left or right depending on the color,
  • Walk forward until i reaches the next color post using the ultrasonic for distance
  • repeat until finished

As usual, my students are better at this stuff than me, so I have shown them this thread and they already have some new ideas. One of them is especially excited by Rich's response, so thanks you!

I guess this leads me to another question: Does anyone have a link to, or know of good project idea/challenges I could give my class to complete?

Thanks again


What an excellent course idea! Autonomous navigation will be important for robotics in the future - for navigating warehouses, hospitals and more.

Here's an idea....

  1. Teach the robot each color using Multi Color

  2. Enable Multi Color tracking

  3. Write a script like this... In the example below, the robot starts to move forward. It checks the distance sensor in the loop. If the distance is less than the specified distance (i.e. reaches a wall) then check the color. The color is pre-configured as a Multi Color. If the color is Red, turn right. If the color is green, right left. The turning happens for 3 seconds (3000 milliseconds). Finally, start walking again.



# get the distance of the ping sensor
$distance = getping(d0, d1)

if ($distance < 30)

  print("Distance is close enough to a wall so let's check the color")

  if ($CameraObjectColor = "Red")
  ELSEif ($CameraObjectColor = "Green")


# A delay to prevent the script from running too quickly


Here is a recommendation. There is a variable to see if the color is being detected, it's $CameraIsTracking. Anyway, i would check that variable when as well in the distance condition. This way, if the variable is not set that means it isn't detecting a color. Do something, such as start turning until there is nothing in front of it -or- start turning until it sees a color.


As for new ideas for courses - one of the future uses of robotics will be remote presence. This means controlling a robot from afar. Perhaps the robot is on Mars while you are on earth. Now, you only can see what is in the camera. You're not able to actually see the robot! Put the robot in a separate room or have the students controlling it turn their back to the robot.

Here is a video example of one of the exercises - the robot is modified to "pick up cotton balls" and place them into their respective matching colored bowls. The robot is controlled by a joystick - but can also be autonomous.

It is possible to program the robot to automatically pick up a color and place it in the respective bowl - one step at a time:)