Python3 port

17 posts / 0 new
Last post
topshed
Python3 port

I've now ported all of the race code including the simulation stuff to Python3 (although it should work with Python2.7+ too).

I'd like to use this as my race platform so should I send you an SD card with my Raspbian build on? I've used the latest Jessie-Lite image with the only main difference from a standard install being that OpenCV needs to be compiled for Python3.

Then could I upload revisions to the formulapi code (e.g. modified Race.py) via SourceForge normally? Or would that too much hassle?

piborg
piborg's picture
Python 3 code

That sounds like the easiest way to do things.

Hopefully you have received your YetiLid, if so the best thing to do would be:

  1. Decorate your YetiLid
  2. Setup a micro SD card which runs on the ZeroBorg complete with a copy of the formulapi code installed so that it is run from rc.local at startup
  3. Put the micro SD card into the YetiLid and mail it to us
  4. Upload your revised code using our provided fpi-upload.sh script before each round

Each round we will take the SD card and:

  1. Empty the ~/formulapi/logs directory
  2. Overwrite the contents of the ~/formulapi directory with the uploaded zip

The instructions for setting up rc.local can be found in our Standard Formula Pi SD card image instructions under the Final notes section.

The address to mail the YetiLid back to is:
Freeburn Robotics Limited
Unit 15, Earith Business Park
Meadow Drove
Earith
Huntingdon
Cambridgeshire
PE28 3QF

zlite
Link to your Python 3 port?

Topshed, I'd like to do the same thing (use Python 3 rather than 2.7). Do you have a link to your port or any tips on how to do it?

Thanks!

zlite
I just went ahead and ported to Python 3 myself

I also abstracted the motor driver so you can use an Arduino and generic PWM motor driver. My port to Python 3 is here: https://github.com/zlite/FormulaPi3

piborg
piborg's picture
Sharing code

Hi Zlite,

While we are happy that you want to share your Python 3 port, but we also want to make our standard code available to our race entrants only.

If you could share the changes you have made to the code instead that would still allow you to share the port without sharing our standard code as well in the process.

We are sorry if it was not clear that we did not want the standard code shared with everybody, hopefully this clears up any misunderstanding :)

zlite
I'm not sure how to just

I'm not sure how to just share the changes but not the underlying code. Is there any chance you could host this version of the ForumlaPi code for Python 3 yourself? The advantages of using Python 3 is that it allows the use of other libraries that are Python 3 specific, while also being able to use the latest OpenCV 3.2

piborg
piborg's picture
Hosting on SourceForge

No problem, we are happy to host your version :)

I have added a new project and imported the code from your GitHub here:
https://sourceforge.net/p/formulapi3/code

The user permissions are set the same as the standard copy, but I have added you as a developer so you should be able to make changes.

Geoff Riley
Geoff Riley's picture
Jolly good idea!

Holding the code together is an excellent plan, and ensures that the code stays in house for the ‘combatants.’ :)

The GitHub project needs to be removed before anyone starts to branch it. [hehe]

Geoff

zlite
Thanks!

Thanks for hosting my fork locally! (I've made my own GitHub repository private)

I should note that my port also abstracts the motor driver and allows the use of an Arduino to control the motors, so it doesn't run on the stock hardware. But I'll add a Python 3 compatible original ZeroBorg.py file for people using the original ZeroBorg board.

BTW, the main reason that I did this port is that I think that the Pi Zero just doesn't have enough processing power to do OpenCV properly, so I wanted to upgrade to a Pi3 and also the possibility of doing all the processing on a laptop with the video sent over wifi. I also wanted to experiment with using other sensors, such as sonar, which requires the Arduino as an I/O processor.

I'd suggest that the default hardware platform shifts to a Pi3 for starters. That would allow 4 threads, which in my experience significantly improves performance.

piborg
piborg's picture
Pi Zero vs Pi 3

Having the Python 3 version of ZeroBorg.py is great, that way people can use your port as a base for their own code.

When I am back at work (sometime next week) I will send everyone out a message to let them know your port is available for everybody.
I will also add a brief explanation of the changes and what they will need to do.

There were a few reasons we went with the Pi Zero for this round of racing:

  1. We wanted to challenge people to write efficient code
  2. The lower power requirements allowed us to use a small battery
  3. It is a good demonstration that self-driving robots do not have to be very expensive
  4. We also wanted to show how powerful the Pi Zero can actually be :)

We did however write our code so it should work on the Pi 3, as well as older Raspberry Pis.
In fact our early test versions were based on an RC car and used:

  1. A PicoBorg Reverse instead of a ZeroBorg
  2. A Raspberry Pi 3 as the brains
  3. Four processing threads, one per core
  4. 30 fps camera input

Here is some footage of the RC car racing during development:

We are still intending to have a higher speed competition in the future.
This will have a Pi 3 instead of the Pi Zero as it will need to perform the processing faster to keep up with the track :)

Jeanine (not verified)
ZeroBorg.py for Python3

Hello,

excuse me for replying to such an old post, but I was wondering if you (or anyone else) can help me to get access to the script I can use for the ZeroBorg in Python3. I've been looking around, but haven't been succesful so far. Also tried to create it from the python2 script available on GitHub, but without any luck so far. I hope anyone here can help me. Thanks in advance

Regards,
Jeanine

Arron Churchill
Arron Churchill's picture
Python 3 version of ZeroBorg.py

You can find the Python 3 version of ZeroBorg.py here: http://forum.piborg.org/comment/6256#comment-6256

zlite
What licence is the FormulaPi code published under?

Is the ForumulaPi code open source? If not, what licence is it published under? I can't find a licence file in the repository

piborg
piborg's picture
Well spotted

We must have forgotten to add our license document to the code :)

It is actually our own license to fit how we intend our Formula Pi type events to be handled.
To summarise:

  1. You may use the code for any form of personal use
  2. You can modify the code any way you like
  3. You may NOT redistribute the code either built or as source

In this case "You" can be your entire Formula Pi team.

It is not quite an open source license in the normal sense.
This kind of license is normally referred to as shared source or source available instead.

I have added the license document to both repositories now, it is also attached below.

Comment Attachments: 
zlite
Why not open source the code?

Out of curiosity, why not open source the code? Most of the other autonomous car code projects are now open source (Comma.ai, Udacity, OSCC, CPFL:Autoware, Carputer, PX4:Rover, APM:Rover, etc), and it's the best way to get participation and contributions to speed development.

I'd love to get local high school students started by using ForumulaPi with their own vehicles on local tracks, but given your current licence I don't think I can. Thus I'll have to switch to another code base and leave FormulaPi, which is unfortunate since I really like it!

piborg
piborg's picture
Why is the code not open source?

There are two basic reasons we decided not to go with a conventional open source license for Formula Pi:
1. We want to encourage competition between teams
2. To ensure the code stays at a suitable level for everybody

By having a license like this it does not stop anyone from asking us if they could run their own event like Formula Pi. What it does do is stop people running events based on the Formula Pi code without our acknowledgement / involvement.

We have invested a large amount of time and effort into Formula Pi to get to this stage. It would be a real shame for us if someone decided to use all our hard work without involving us. We are happy to try and offer assistance to people who would like to run a Formula Pi based event.

As you have pointed out there are a lot of projects for self-driving cars and robots which are already available. We want to add a competitive element to what is available as a different means to encourage development of better and smarter code. We think that having a mixture of both competitive and cooperative development available that we can encourage everyone who is interested to help improve autonomous cars in their own way.

Keeping the code secret encourages the competing teams to keep their code secret as well. This makes it easier for people to come up with their own unique ideas, with the races deciding which work better and which do not. At the end of each series we then share the winners code with all the teams, this avoids the usual problem of some teams being left behind if they did not do as well as others in the last series.

On the other side of things we want to keep the standard code simple enough that people of any level feel they can get stuck in and try their luck. Often these projects seem very complex, putting those with less experience off as they feel they would not be able to do well. We have found that if the code available is presented to people as simple for getting started then they are more likely to have a go, often with good results.

What we have done is to try and make the code as easy to alter and understand at each level as possible. This does mean there are some parts of the code which are far from perfect, such as the overtaking logic :) The result is that we have teams of all ages and skill levels trying without feeling overwhelmed.

We think that events like Formula Pi and the open source development of self-driving cars and robots complement each other nicely. We encourage anyone who is interested in looking at or helping with autonomous code to take a look at them.

zlite
Starting another thread on running our own FormulaPi events

Great answer! I'm very interested in your offer ("We are happy to try and offer assistance to people who would like to run a Formula Pi based event"), so I'll start another thread to learn more about that.

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.