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 |
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
|
CE Calculators
|
|
CE Calculators
|
||||||||||||||||||||||||||||||||||||
|
|
|
CE Calculators
|
|||||||||||||||||||||||||||||||||
|
CE Calculators
|
|||||||||||||||||||||||||||||||||
|
CE Calculators
|
|||||||||||||||||||||||||||||||||
|
CE Calculators
|
|||||||||||||||||||||||||||||||||
|
|
|
CE Calculators
|
|
CE Calculators
|
|||||||||||||||||||||||||||||||||
|
CE Calculators
|
TI-Nspire™ CX II
|
TI‑Nspire™ CX
|
|
TI‑Nspire™ CX
|
|||||||||||||||||||||||||||||||||
|
TI‑Nspire™ CX
|
|||||||||||||||||||||||||||||||||
|
|
|
TI‑Nspire™ CX |
|||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||
|
TI‑Nspire™ CX
|
|||||||||||||||||||||||||||||||||
|
TI‑Nspire™ CX
|
|||||||||||||||||||||||||||||||||
|
|
|
TI‑Nspire™ CX
|