Documentation

← back to Oculus Prime Contents

Oculus Prime - Another Script Example, Auto-starting Scripts

This page describes a method of auto-starting a script on boot, so it will always be running to enhance the functionality of Oculus Prime. As usual, we’re sticking with Python scripts as an example, but the same method can easily be applied to other scripting languages.

Auto Starting Scripts

1 – Create a Script: Switch Between Navigation Routes Based on Time of Day

The example script below allows you to extend the web-browser GUI functionality, which (currently) only allows for scheduling a single navigation route. This script does the following:

-Connects to the server, setting oculusprimesocket.reconnect to True first, so the script won’t exit in case the script gets started before the server.
-Gets the name of the currently running route
-Gets the current hour of the day
-Runs one of two routes, depending on the hour of the day (if it isn’t already running)
-Restart loop

2 – Save the Script Somewhere on Oculus Prime

The script will need to go somewhere on the robot. For this example, create a folder under the 'oculusPrime' directory in the home folder (or use another location of your choice):

$ mkdir /home/oculus/oculusPrime/telnet_scripts

Use a text editor to save the script above in this location, then set it to executable by doing:

$ chmod u+x /home/oculus/oculusPrime/telnet_scripts/multi_routes.py


3 – Script Support Files

Many scripts are stand-alone, but the one above happens to import the oculusprimesocket python module, so the module will have to be somewhere Python can find it. An easy way is to just put it in the same folder that the script is in. So, copy the file from here into the 'telnet_scripts' folder created above.

4 – Set to Run on Boot

There are several ways in Ubuntu to auto-run programs on boot, but probably the simplest is to add the appropriate commands to the bottom of the '/etc/rc.local' system startup script, just above the last 'exit 0' line, like this example:

The first of the last 2 lines above 'exit 0' changes the working directory to the 'telnet_scripts' folder (required so Python can find the oculusprimesocket module), and the next line runs the script (notice the full path is required as part of the command).


NEXT: Extending Oculusprime Java

← back to Oculus Prime Contents


CART 0 items | US$
    Check Order Status
Follow →
instagram twitter facebook youtube
© 2024 Xaxxon
Products Documentation Downloads Source Code
Warranty & Returns About Us Contact/Support News
instagram twitter facebook youtube