Skip to content

OKState Fall 2022 | AI Foosball Team

License

Notifications You must be signed in to change notification settings

ragley/AI-Foosball

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI-Foosball

Links to Other READMEs

Production vs Development Code

All production code is set as bootup scripts. These scripts are stored in the /bin directory and in general should never be directly edited (rather overwritten from the development repo).

To run and test development code, the respective production code has to be stopped. For example if a new balltracking algorithm is being written then the _ball_tracking.service must be stopped before the new code can be ran. To do this you would run the following command: sudo systemctl stop ball_tracking.service

To determine what script is running what code you'll have to go to /etc/systemd/system/ and look for the .service that corresponds to whatever program you are trying to run.

After your development code is ready to be placed into production follow the below commands to either create a new startup script or update an existing one.

Running Python Scripts at Startup

Follow the instructions here: https://unix.stackexchange.com/questions/634410/start-python-script-at-startup it's fairly self-explainatory.

For our startup scripts we copied the python codes we wanted to run at start into the /bin folder. This allows the script to be run with superuser permissions. For reference, the command to copy to the /bin directory is: sudo cp ./"script name" /bin/"script name"

Note that if you are editing an already existing file (i.e. ball_tracking.py) there likely already exists a service for it. All you would need to do would be to recopy the code to the /bin directory (as seen above).

This would mean the .service file (in /etc/systemd/system/myscript.service) would like like:

[Unit]
Description=My Script

[Service]
ExecStart=/usr/bin/python3 /bin/"your script here".py

[Install]
WantedBy=multi-user.target

On thing of note however, this will not work for any graphical application (i.e. a gui). The script will also crash if you try to open a window (such as to display the camera output). It handles print statements fine, athough you won't see them unless you run sudo systemctl status "your service here".service.

The alternative is to use a crontab to set things at startup, but you'll have to figure that out yourself.

About

OKState Fall 2022 | AI Foosball Team

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 54.1%
  • Python 22.7%
  • C++ 12.8%
  • C 4.7%
  • CSS 4.0%
  • JavaScript 1.7%