Failing to start

1 post / 0 new
Jamie
Jamie's picture
Failing to start

I thought I'd share the reason my robot didn't start in Testing Round 1 on June 6th so that other's don't make the same mistake. I also hope that this might prompt others to share the reason they didn't start so we can all learn from each others mistakes.

Last season I created a custom logging class that helped me to combine the two standard log files into one file as well as add some additional logging functionality. During the last season this was imported at the beginning of Race.py. This season I decided that there is some information at startup that would be helpful to capture if I decided to make changes to it; so I moved it to the start of Formula.py and SimulationFull.py

During testing this all worked well and there were no issues, but on testing day my code failed to boot.

After some investigation and trying to recreate the error on my computer, it wasn't until I ran the startup line that is in the rc.local file that I was able to successfully crash the code.

sudo python /home/pi/formulapi/Formula.py &

I had always moved into the /home/user/formulapi directory and just the python file from here.

Why does this make a difference? Well, one of the first things the Formula.py and SimulationFull.py does is the change the directory you're working in.

# Change the current directory to where this script is
scriptDir = os.path.dirname(sys.argv[0])
os.chdir(scriptDir)

I had placed my import command and checking to make sure the log folder existed before the directory change had occurred. So when the logging class was instantiated and it attempted to log the start up it was looking to:
/logs/logfile.txt
instead of
/home/pi/formulapi/logs/logfile.txt

Since the /logs folder didn't exist and the check/create folder command hadn't run there was nothing else the program could do except crash.

This worked for me during testing since I was already in the correct folder and the log folder already existed in the formulapi folder.

A quick swap of the order the code runs and everything is working again.

Finally a big thank you to Arron and Tim for taking the time to investigate and send a picture of the error. Without that I don't know how long it would have taken me to find the problem!

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Syntax highlight code surrounded by the <pre class="brush: lang">...</pre> tags, where lang is one of the following language brushes: bash, cpp, perl, python.
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Comment Images
Files must be less than 10 MB.
Allowed file types: png gif jpg jpeg.
Comment Attachments
Files must be less than 10 MB.
Allowed file types: txt pdf nfo doc docx rtf jpg png gif bmp zip tar gz csv xls.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.