NONI Robot Reference

Starting/ending

Simple

Advanced

Description

Select the map to use with the robot.

This is the first of 3 functions that must be called before writing any code.

Syntax

selectMap(myMapName)

Parameters

myMapName Map name without file extension, e.g., “map1” or “map2” etc.

Returns

Nothing

Examples

selectMap("map1"); selectMap("map2"); selectMap("map3"); selectMap("map4");

Related

selectMap()
robotStartPosition()
robotConnect()
robotDisconnect()

Top

Description

Place the robot at the starting position on the map.

This is the second of 3 functions that must be called before writing any code.

The angle is measured between the x-axis of the robot frame and the x-axis of the world frame. Counter clockwise rotation is positive. When the angle is zero, the robot is pointed in the forward direction in the world frame.

Reference frames:
– World frame has positive x-axis to the right, positive y-axis forward. Origin at bottom left of map.
– Robot body frame has positive x-axis to the right, positive y-axis forward. Origin at the center of the robot.

Syntax

robotStartPosition(x, y, theta)

Parameters

x X coordinate of the starting location of the robot (world frame) [mm]

y Y coordinate of the starting location of the robot (world frame) [mm]

theta Starting direction of the robot world frame positive counterclockwise [deg]

Returns

Nothing

Examples

robotStartPosition(100, 100, 0);

robotStartPosition(300, 100, 45);

robotStartPosition(500, 500, 90);

robotStartPosition(500, 500, 180);

robotStartPosition(200, 200, 270);

Related

selectMap()
robotStartPosition()
robotConnect()
robotDisconnect()

Top

Description

Connect to the robot.

This is the third of 3 functions that must be called before writing any code.

Syntax

robotConnect()

Parameters

None

Returns

Nothing

Examples

robotConnect();

Related

selectMap()
robotStartPosition()
robotConnect()
robotDisconnect()

Top

Description

Disconnect from the robot.

This function must always be called at the end of the code.

Syntax

robotDisconnect()

Parameters

None

Returns

Nothing

Examples

robotDisconnect();

Related

selectMap()
robotStartPosition()
robotConnect()
robotDisconnect()

Top

Description

Go forward one step (100 mm).

Syntax

forward()

Parameters

None

Returns

Nothing

Examples

forward();

Related

forward()
backward()
right()
left()
paint()
blink()

Top

Description

Go backward one step (100 mm).

Syntax

backward()

Parameters

None

Returns

Nothing

Examples

backward();

Related

forward()
backward()
right()
left()
paint()
blink()

Top

Description

Turn right (90 degrees).

Syntax

right()

Parameters

None

Returns

Nothing

Examples

right();

Related

forward()
backward()
right()
left()
paint()
blink()

Top

Description

Turn left (90 degrees).

Syntax

left()

Parameters

None

Returns

Nothing

Examples

left();

Related

forward()
backward()
right()
left()
paint()
blink()

Top

Description

Make a paint dot at the current robot location.

The paint dot appears under the body of the robot, so it will not be visible if the robot stays at that location. It will be visible once the robot moves away from that location.

Syntax

paint()

Parameters

None

Returns

Nothing

Examples

paint();

Related

forward()
backward()
right()
left()
paint()
blink()

Top

Description

Blink the onboard LED 3 times.

The blink pattern is 1 second on, 1 second off.

Syntax

blink()

Parameters

None

Returns

Nothing

Examples

blink();

Related

forward()
backward()
right()
left()
paint()
blink()

Top

Description

Set motor velocity for left motor.

Set to 100 for full speed forward. Set to -100 for full speed backward. Set to 0 to stop motor.

Syntax

leftMotorVelocity(velocity)

Parameters

velocity Motor velocity (-100 to 100).

Returns

Nothing

Examples

Drive the left wheel at full speed in the forward direction:
leftMotorVeclocity(100);

Drive the left wheel at half speed in the forward direction:
leftMotorVeclocity(50);

Drive the left wheel at full speed in the backward direction:
leftMotorVeclocity(-100);

Stop the left wheel:
leftMotorVeclocity(0);

Related

leftMotorVelocity
rightMotorVelocity()
lineSensor()
led()
waitSeconds()
timeSeconds()

Top

Description

Set motor velocity for right motor.

Set to 100 for full speed forward. Set to -100 for full speed backward. Set to 0 to stop motor.

Syntax

rightMotorVelocity(velocity)

Parameters

velocity Motor velocity (-100 to 100).

Returns

Nothing

Examples

Drive the right wheel at full speed in the forward direction:
rightMotorVeclocity(100);

Drive the right wheel at half speed in the forward direction:
rightMotorVeclocity(50);

Drive the right wheel at full speed in the backward direction:
rightMotorVeclocity(-100);

Stop the right wheel:
rightMotorVeclocity(0);

Related

leftMotorVelocity
rightMotorVelocity()
lineSensor()
led()
waitSeconds()
timeSeconds()

Top

Description

Read analog value from the line sensor.

Uses infrared light to detect the black lines on a map. A value of zero indicates that no light is being reflected, that is, the surface is black. A value of 255 indicates that all the light is being reflected, that is, the surface is white.

Syntax

lineSensor()

Parameters

None

Returns

Analog value from 0 to 255.

Examples

Check if the line sensor value indicates a dark line. If true, turn on the LED:

var sensorValue;
sensorValue = lineSensor();
if(sensorValue < 128) {
  led(1);
  waitSeconds(0.1);
}

Related

leftMotorVelocity
rightMotorVelocity()
lineSensor()
led()
waitSeconds()
timeSeconds()

Top

Description

Turn onboard LED on or off.

Syntax

led(value)

Parameters

value On/off value, 0 for on, 1 for off.

Returns

Nothing

Examples

Turn the LED on for 2 seconds, off for 3 seconds, then on for 1 second:

led(1);
waitSeconds(2);
led(0);
waitSeconds(3);
led(1);
waitSeconds(1);

Related

leftMotorVelocity
rightMotorVelocity()
lineSensor()
led()
waitSeconds()
timeSeconds()

Top

Description

Wait for a specified amount of seconds.

If you are using the advanced commands, use this. Can use whole seconds, e.g. 1, 2, 3, or partial seconds, e.g. 1.1, 2.5, 5.7, etc.

You must to use this after advanced commands in order to give the robot time to respond to your commands. If you do not use this at all in your code, then your robot will not have time to carry out any commands and the robot will never move.

At a minimum, after each group of advanced commands, use 0.030 seconds.

Syntax

waitSeconds(seconds)

Parameters

seconds Number of seconds.

Returns

Nothing

Examples

Drive the robot a tiny distance forward, then stop:

leftWheelVelocity(75);
rightWheelVelocity(75);
waitSeconds(0.1);
leftWheelVelocity(0);
rightWheelVelocity(0);
waitSeconds(0.1);

Turn the robot right for 2.5 seconds, then stop:

leftWheelVelocity(50);
rightWheelVelocity(-50);
waitSeconds(2.5);
leftWheelVelocity(0);
rightWheelVelocity(0);
waitSeconds(0.1);

Related

leftMotorVelocity
rightMotorVelocity()
lineSensor()
led()
waitSeconds()
timeSeconds()

Top

Description

Get time elapsed since the start of the program.

Use this for keeping track of time.

Syntax

timeSeconds()

Parameters

None

Returns

Nothing

Examples

Turn the robot right for 2.5 seconds, then stop:

var currTime = timeSeconds();
while((timeSeconds() - currTime) < 2.5) {
  leftWheelVelocity(50);
  rightWheelVelocity(-50);
  waitSeconds(0.1);
}
leftWheelVelocity(0);
rightWheelVelocity(0);
waitSeconds(0.1);

Drive the robot forward for 5 seconds, then stop:

var currTime = timeSeconds();
while((timeSeconds() - currTime) < 5) {
  leftWheelVelocity(50);
  rightWheelVelocity(50);
  waitSeconds(0.1);
}
leftWheelVelocity(0);
rightWheelVelocity(0);
waitSeconds(0.1);

Related

leftMotorVelocity
rightMotorVelocity()
lineSensor()
led()
waitSeconds()
timeSeconds()

Top