Jump to content
THIS IS THE TEST SITE OF EUROBRICKS! ×
THIS IS THE TEST SITE OF EUROBRICKS!

Recommended Posts

Posted

Recently @MajorAlvega created an interesting topic about ev3dev, a Linux based operating system compatible with Mindstorms EV3.

One of the possible languages for programming the software for the brick is Python. I never paid much attention to Python as a potential language to do my EV3 programming. However, it has a very big pro, which is the option to use Visual Studio Code as the IDE for programming the brick.

In this topic I will share my experience with you. I will try to maintain an index in this first post.

LINKS

 

DISCLAIMER
I know the official name is ev3dev, but I will also use the term EV3Dev.

 

  • Replies 94
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Posted

STEP 1: MicroSD Card
My first step was to get a new microSD or microSDHC card. All the cards I own are 64GB and the EV3 brick only supports a max of 32GB.

I purchased the SanDisk 16GB.

Unfortunately, I didn't have time to continue installing Python this evening, so I will probably continue tomorrow.

Posted

STEP 2: Download ev3dev-stretch

Next step is to download the proper version of ev3dev. Make sure to get the stretch version, not jessie. Check out the getting started section on ev3dev to follow the steps.

I will be working with ev3dev-stretch-ev3-generic-2018-08-06.zip

STEP 3: Flash the Micro SD Card

I need to download Etcher from their website and install it, in order to flash the card.

Done, that was easy.

Posted

STEP 4: Boot EV3Dev

Booting....which will take a minute and....done!

I really wish the LCD was backlit btw, but that's a different discussion.

Posted

STEP 4: Connect to Network

The first thing I tried was connecting to my Wifi network, using the Netgear WNA1000M Wireless N USB Micro Adapter. This one wasn't compatible with the default EV3 firmware. Works like a charm with ev3dev :wub:

s-l300.jpg

 

Too bad it isn't available anymore. Does anyone know if this one will work too?

1003004012437373.jpg

Could get this one too.

589897

  • Jim changed the title to [EV3DEV] Venturing into the World of EV3Dev and Python
Posted

STEP 5: Connect to the EV3 using SSH

I have downloaded Putty and now I am trying to connect to the brick.

Connected to the robot using login robot and password maker.

 

Capture.PNG

STEP 6: Choosing the Programming Language

Since I have decided to go with Python, I will be using the Visual Studio Code extensions.

Posted

I have setup VSCode, installed the extensions and downloaded the program. When I run it...VS states

/usr/bin/env: 'python3\r': No such file or directory

The first problem I encountered. Let's see what's wrong.

Posted

If you encounter an error such as /usr/bin/env: 'python3\r': No such file or directory, you must switch your editor’s “line endings” setting for the file from “CRLF” to just “LF”. This is usually in the status bar at the bottom. For help, see our FAQ page.

Solved the issue, thanks to the Python Language Bindings for ev3dev.

So, I just ran my first program! :wub:

Victory!

 

Posted

Great to watch your progress.

About the wi-fi dongles, I mostly use Enermax and ASUS N10 Nano. There are a few more - most (but not all) that work with the Raspberry Pi native OS (Raspbian) will also work. A few based on a specific Realtek chipset have some long run problems but recent kernel updates have made things better.

Posted

I use this one:

https://www.amazon.com/Raspberry-Pi-WIFI-Adapter-Dongle/dp/B009FA2UYK/ref=sr_1_fkmr0_2?ie=UTF8&qid=1542755291&sr=8-2-fkmr0&keywords=pig+hut+wifi

 

4 hours ago, Jim said:

I really wish the LCD was backlit btw, but that's a different discussion.

It isn't as compact as an EV3 but a pi3 + brickpi3 + this screen:

https://www.amazon.com/gp/product/B01N447AEY/ref=oh_aui_search_detailpage?ie=UTF8&psc=1

makes for a nice alternative, it boots in about 8 seconds!!  I put a SSD on it once and the boot time was even better :) (I forget exactly how fast it was though)

Posted
14 hours ago, MajorAlvega said:

Great to watch your progress.

About the wi-fi dongles, I mostly use Enermax and ASUS N10 Nano. There are a few more - most (but not all) that work with the Raspberry Pi native OS (Raspbian) will also work. A few based on a specific Realtek chipset have some long run problems but recent kernel updates have made things better.

Yeah, it worked out nicely yesterday. Accomplished the basics.

The Asus N10 Nano looks great....well the price does. Thanks, I will get me some of those. 

12 hours ago, dwalton76 said:

It isn't as compact as an EV3 but a pi3 + brickpi3 + this screen:

https://www.amazon.com/gp/product/B01N447AEY/ref=oh_aui_search_detailpage?ie=UTF8&psc=1

makes for a nice alternative, it boots in about 8 seconds!!  I put a SSD on it once and the boot time was even better :) (I forget exactly how fast it was though)

I probably need to get me something like that for my big robot project.

Let's say I want to connect like 16 motors (or a big number); how can I connect the EV3 motors to my pi3?

I see the Brickpi has several outputs, but I do need a lot of them. One option would be to use multiple Brickpi's, but maybe there is a better solution. Some of the motors can be multiplexed, but not all of them.

Posted

More importantly; can I change the name of my brick? If I am not mistaken it is called ev3dev now and since I will be using multiple bricks, I like to call them EV3A, EV3B, EV3C and......EV3D :laugh:

My next step is to setup communication between multiple bricks. Ideally, I would designate one brick (EV3A) as the master and the other three as slaves. The master is the brain of the robot and the slaves provide sensory information and operate certain functions/motors.

Posted
1 hour ago, Jim said:

Let's say I want to connect like 16 motors (or a big number); how can I connect the EV3 motors to my pi3?

Some of the motors can be multiplexed, but not all of them.

You can stack up to four brickpi3s on a single pi3 :) Support for this just went into ev3dev-lang-python about a month ago so you may need to clone the repo to run the latest and greatest.  You can see the port names for the stacked brickpi3s here:

https://github.com/ev3dev/ev3dev-lang-python/pull/562/files

In terms of motor multiplexors I am not sure which ones are supported on ev3dev off the top of my head.  I am sure there are some that are but I have never tried to use any of them.  Another option is to do a physical multiplexor:

I used this several years ago to combine an EV3 with an excavator to make it remote controlled.  I needed to be able to control six movements with just four motors:

In hindsight I should have used a smaller turntable that would have made it easier to fit everything.

2 hours ago, Jim said:

More importantly; can I change the name of my brick? If I am not mistaken it is called ev3dev now and since I will be using multiple bricks, I like to call them EV3A, EV3B, EV3C and......EV3D :laugh:

My next step is to setup communication between multiple bricks. Ideally, I would designate one brick (EV3A) as the master and the other three as slaves. The master is the brain of the robot and the slaves provide sensory information and operate certain functions/motors.

yep you can name the brick whatever you want.  ev3dev is just debian linux so anything you can do in debian you can do in ev3dev.

If you do not go the route of stacking brickpi3s and decide to do "setup communicatino between multiple bricks" come on over to ev3dev-lang-python and I can assign https://github.com/ev3dev/ev3dev-lang-python/issues/385 to you :)  We are always looking for new contributors and it sounds like you have a legit use case for that feature...it would be awesome if you implemented that one.

Posted
On 11/21/2018 at 2:26 PM, dwalton76 said:

If you do not go the route of stacking brickpi3s and decide to do "setup communicatino between multiple bricks" come on over to ev3dev-lang-python and I can assign https://github.com/ev3dev/ev3dev-lang-python/issues/385 to you :)  We are always looking for new contributors and it sounds like you have a legit use case for that feature...it would be awesome if you implemented that one.

I will check out your answer about stacking brickpi's later (thanks a lot), but I am definitely interested in the "multiple brick communication", so I will come over to ev3dev-lang-python and give it a go. I must confess that I have zero Python experience, but I am a pretty experienced software engineer, so maybe I will be able to contribute :wink: 

Posted

If you have software dev experience python is pretty easy to pick up...it is very readable. 

I did some digging and found a repo on GitHub where someone has already implemented the EV3 protocol in python...so from their laptop they can control an EV3. This part we should be able to bring into the ev3dev python library without a crazy amount of work.

What is missing is the code to implement the server side of the protocol. So if you want to take an EV3 and use it to control an ev3dev that code has not been written (not that I have found at least).  

Posted
18 hours ago, Jim said:

I will check out your answer about stacking brickpi's later (thanks a lot), but I am definitely interested in the "multiple brick communication", so I will come over to ev3dev-lang-python and give it a go. I must confess that I have zero Python experience, but I am a pretty experienced software engineer, so maybe I will be able to contribute :wink: 

I broke the "support EV3 protocol" issue up into two issues, one to implement client support and one to implement server support:

It would probably be best to start with the "client support" issue.  A large chunk of that code is already written in another repo and you could test it by trying to control a stock EV3.

Posted

Here is a TP-Link Wifi dongle that works on my EV3 with ev3dev.  I believe it is based on the Realtek chipset.  I didn't notice any network issues when I Putty'ed into my EV3.

ev3wifi.jpg

 

Instead of Etcher, I used Image Writer Win32DiskImager to put the *.img on my SD card since I am already using it to image SD cards for my Raspberry Pi'es.

Posted
On 11/21/2018 at 2:26 PM, dwalton76 said:

yep you can name the brick whatever you want.  ev3dev is just debian linux so anything you can do in debian you can do in ev3dev.

I have edited the hostname file in etc with sudoedit from ev3dev to EV3A, but it still shows ev3dev in Putty and in VSCode. Any idea why?

Admittedly, I am a Windows man, so I really need to find my way in Debian. But I do like the challenge. Can you recommend any (visual) tools to browse the brick, instead of SSH commandline with Putty.

Posted

I suddenly get pylint errors. Strange thing is that the led is actually causing an error. When I comment out the led statement, the program runs fine. And the funny thing is that the other day it worked with the led statement in the program.

I see in the readme todo "explain how to get code completion working". Can you tell me how to do this?

Sorry for all the questions, but I need to find my way around Python.

Python1.PNG

Posted

not sure but I think the last import should be

from ev3dev2.led import Leds

 

And for visual browsing the file system I think WinSCP does that, it's like Filezilla but uses SSH instead of FTP.

I'm not sure but I think Filezilla also suports SSH but never used for that.

Posted

Another question; is it possible to use the requests class in the EV3 bricks?

https://code.tutsplus.com/articles/how-to-use-restful-web-apis-in-python--cms-29493

Traceback (most recent call last):
File "/home/robot/vscode-hello-python/hello.py", line 8, in <module>
import requests
ImportError: No module named 'requests'

 

10 minutes ago, MajorAlvega said:

not sure but I think the last import should be

Ahhh yes, of course. That makes sense. Maybe I accidentally added the 4. It's working again, thanks.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.

Announcements

  • THIS IS THE TEST SITE OF EUROBRICKS!

×
×
  • Create New...