TI-Innovator™ Rover Python Commands Version 1.5

The Python interface to TI-Rover is through the “ti_rover” module.

This module is bundled with the OS for both TI-Nspire™ CX II and CE platforms.


Rover Command Categories

The Rover commands fall into two categories:

1. Queued execution: All of the Rover motion commands – rv.forward(), rv.backward(), rv.lef(), rv.right(), rv.to_angle() – are queued on the TI-Innovator™ Hub. They may execute at a future time.
2. Immediate execution: Other commands – like the ones to read the sensors or set the RGB LED on the Rover – are executed immediately.

This means that certain statements in your program will execute before statements that appear earlier in the program especially if the latter commands are part of the queued family.

For example, in the program below, the RGB LED will turn RED before the Rover stops moving:

import ti_rover as rv

rv.color_rgb(255,0,255) # Immediately executed

rv.forward(5) # Queued command

rv.left(45) # Queued command

rv.right(90) # Queued command

rv.color_rgb(255,0,0) # Immediately executed

Example:

To change color after a rv.forward() movement, use the command that supports a time parameter with a sleep() command.

rv.forward_time(5)

sleep(5)

rv.color_rgb(255,0,0)

Note: You may have to import the ‘time’ module to use the ‘sleep’ function.


RV Commands, Python Code Samples, and Syntax

The following examples show how various commands for the “rv” are used.

Python Code Samples

When you see "Python Code Sample" in a command table, this "Python Code Sample" may be copied and pasted as is to send to your graphing calculator to use in your calculations.

Example:

Python
Code
Sample:

rv.forward(5)

rv.left(90)

rv.forward_time(5)

 


TI-Rover program template

To make it easier to get started with TI-Rover programs, you can use a template that automatically imports the necessary modules needed for a TI-Rover program.

CE products

When creating a new program, use the optional “Type” list to create a TI-Rover program

 

 

TI-Nspire™ products

When creating a new Python program, choose “Rover coding” from the optional “Type” dropdown list.

 

TI-Innovator™ Rover Menu

CE products

Menu
import ti_rover as rv
Drive
Inputs
Outputs
Path
Settings
Commands

CE Calculators


 

Drive
import ti_rover as rv
forward(distance)
backward(distance)
left(angle_degrees)
right(angle_degrees)
Drive with Options ->
stop()
resume()
stay(time)
to_xy(x,y)
to_polar(r, theta)

CE Calculators

to_angle(angle)
forward_time(time)
backward_time(time)
left(angle,”unit”)
right(angle,”unit”)
forward_time(time,speed,”unit”)
backward_time(time,speed,”unit”)
forward(distance,”unit”,speed,”unit”)
backward(distance,”unit”,speed,”unit”)
disconnect_rv()


 

I/O (Input/Output)
Inputs…
Outputs…
Path…

CE Calculators

Inputs
ranger_measurement() meters
color_measurement() 1-9
red_measurement() 0-255
green_measurement() 0-255
blue_measurement() 0-255
gray_measurement() 0-255
encoders_gyro_measurement() list
gyro_measurement() degrees
ranger_time() seconds

 

CE Calculators

Outputs
color_rgb(red, green, blue)
color_blink(frequency,time)
color_off()
motor_left(speed,time)
motor_right(speed,time)
motors(“ldir”,left_val,”rdir”,right_val,time)

 

CE Calculators

Path
waypoint_xythdrn()
waypoint_prev()
waypoint_eta()
path_done()
pathlist_x()
pathlist_y()
pathlist_time()
pathlist_heading()
pathlist_distance()
pathlist_revs()

CE Calculators

Path
pathlist_cmdnum()
waypoint_x()
waypoint_y()
waypoint_time()
waypoint_heading()
waypoint_distance()
waypoint_revs()


 

Settings
units/s
m/s
revs/s
units
m
revs
degrees
radians
gradians
clockwise
counter-clockwise

CE Calculators


 

Commands
from ti_system import *
sleep(seconds)
disp_at(row, “text”, “align”)
disp_clr()
disp_wait()
disp_cursor()
while not escape():
wait_until_done()
while not path_done():
position(x,y)

CE Calculators

Commands
position(x,y,heading,”unit”)
grid_origin()
grid_m_unit(scale_value)
path_clear()
zero_gyro()

CE Calculators


 

TI-Nspire™ CX II

TI Rover
import ti_rover as rv
Drive
Inputs
Outputs
Path
Settings
Commands

TI‑Nspire™ CX


 

Drive
forward(distance)
backward(distance)
left(angle_degrees)
right(angle_degrees)
Drive with Options ->
stop()
stop_clear()
resume()
stay(time)
to_xy(x,y)

TI‑Nspire™ CX

Drive with Options
forward_time(time)
backward_time(time)
forward(distance,”unit”)
backward(distance,”unit”)
left(angle,”unit”)
right(angle,”unit”)
forward_time(time,speed,”unit”)
backward_time(time,speed,”unit”)
forward(distance,”unit”,speed,”unit”)
backward(distance,”unit”,speed,”unit”)

TI‑Nspire™ CX

to_polar(radius,theta)
to_angle(angle,”unit”)


 

I/O (Input/Output)

TI‑Nspire™ CX

Inputs
ranger_measurement() m
color_measurement() 1-9
red_measurement() 0-255
green_measurement() 0-255
blue_measurement() 0-255
gray_measurement() 0-255
encoders_gyro_measurement() list
gyro_measurement() degrees

 

Outputs
color_rgb(red, green, blue)
color_blink(frequency,time)
color_off()
motor_left(speed,time)
motor_right(speed,time)
motors(“ldir”,left_val,”rdir”,right_val,time)

 

TI‑Nspire™ CX

Path
waypoint_xythdrn()
waypoint_prev()
waypoint_eta()
path_done()
pathlist_x()
pathlist_y()
pathlist_time()
pathlist_heading()
pathlist_distance()
pathlist_revs()

TI‑Nspire™ CX

pathlist_cmdnum()
waypoint_x()
waypoint_y()
waypoint_time()
waypoint_heading()
waypoint_distance()
waypoint_revs()


 

Settings
units/s
m/s
revs/s
units
m
revs
degrees
radians
gradians
clockwise
counter-clockwise

TI‑Nspire™ CX


 

Commands
sleep(seconds)
text_at(row,”text”,”align”)
cls()
while get_key()!= "esc":
wait_until_done()
while not path_done():
position(x,y)
position(x,y,heading,”unit”)
grid_origin()
grid_m_unit(scale_value)

TI‑Nspire™ CX

path_clear()
zero_gyro()