ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
425 stars 144 forks source link

BrickPi3 example #728

Open dlech opened 4 years ago

dlech commented 4 years ago

We get a fairly steady stream of people trying to use BrickPi3 and failing because it cannot automatically detect sensors and motors. It would be super-helpful if the docs here had an example that people could copy and paste to get started.

Despite the constant questions, I still cannot find any known working example in any of the ev3dev GithHub issues.

WasabiFan commented 4 years ago

Good call. I don't personally have a BrickPi but I can certainly try to write some code if someone else can test it.

WasabiFan commented 4 years ago

I'm trying to test manually setting port modes on my EV3. This works with tacho motors, but when I have a US sensor connected I see the following behavior:

robot@ev3dev:~$ cat /sys/class/lego-port/port0/address   
ev3-ports:in1
robot@ev3dev:~$ echo ev3-uart > /sys/class/lego-port/port0/mode        
robot@ev3dev:~$ echo lego-ev3-us > /sys/class/lego-port/port0/set_device 
-bash: echo: write error: Operation not supported

Is there something obvious I'm doing wrong here, or do you have suggestions for where I should look? This should be supported on the EV3, right?

ev3dev-stretch-ev3-generic-2019-05-29
Kernel version:     4.14.117-ev3dev-2.3.4-ev3
dlech commented 4 years ago

Since EV3 can automatically detect UART sensors, it doesn't let you pick a different one. BrickPi3 and PiStorms (and mindsensors EV3 sensor multiplexer) on the other hand can't automatically detect sensors, so you have explicitly tell them which sensor is attached.

WasabiFan commented 4 years ago

Ah, got it -- I didn't realize it wasn't supported on the EV3 ports. I opened a PR on the python demo repo with a sample program; would you be able to test it?

WasabiFan commented 4 years ago

I'll link to this example in docs and maybe quote some of it too.

dlech commented 4 years ago

I opened a PR on the python demo repo with a sample program; would you be able to test it?

Yeah, I'll try it tomorrow.

dlech commented 4 years ago

Perhaps another tip for the documentation, if you get this error...

Starting: brickrun --directory="/home/robot/brickpi3" "/home/robot/brickpi3/main.py"
----------
Traceback (most recent call last):
  File "/home/robot/brickpi3/main.py", line 11, in <module>
    from ev3dev2.motor import OUTPUT_A, LargeMotor, SpeedPercent
  File "/usr/lib/python3/dist-packages/ev3dev2/motor.py", line 77, in <module>
    raise Exception("Unsupported platform '%s'" % platform)
Exception: Unsupported platform 'None'
----------
Exited with error code 1.

Then you probably forgot to edit config.txt.

WasabiFan commented 4 years ago

@dlech Do you have any particular recommendations for where that should go? I am tempted to put it in our FAQ but no one reads the FAQ 😢

dlech commented 4 years ago

The more places the better 😄

Maybe add some links to the FAQ from different places? e.g. at the top of the sensor docs, say "If you are using BrickPi3, also see the FAQ"