ev3dev / ev3dev-lang-python-demo

Python Demo Programs
MIT License
61 stars 28 forks source link

MINDCUB3R on stretch #22

Closed IrishClanger closed 6 years ago

IrishClanger commented 7 years ago

Hi again. I decided to try the Stretch build you suggested in my previous issue. I installed snapshot-ev3dev-stretch-ev3-generic-2017-09-30.img.xz on the card and followed the instructions for MINDCUB3R on your site again. I took the current rhempel/ev3dev-lang-python and added in your demos. I get a similar motor error when trying to run calibration:

robot@ev3dev:~/ev3dev-lang-python-demo/robots/MINDCUB3R$ ./calibrate_white.py Traceback (most recent call last): File "./calibrate_white.py", line 16, in from mindcuber import MindCuber File "/home/robot/ev3dev-lang-python-demo/robots/MINDCUB3R/mindcuber.py", line 3, in from ev3dev.motor import LargeMotor, MediumMotor, OUTPUT_A, OUTPUT_B, OUTPUT_C, SpeedDPS ImportError: No module named 'ev3dev.motor'

What do I need to do to get this build combination working please? I did not want to load the ev3dev/ev3dev-lang-python version in case there is a library conflict as previously suggested.

I am interested to see if the newer version is more accurate with the colours. I had a couple of issues with white and yellow squares being mixed up by the older jessie version of the code. Thanks, Mark.

dwalton76 commented 7 years ago

Hello @IrishClanger, try this:

$ cd /home/robot/
$ git clone https://github.com/ev3dev/ev3dev-lang-python.git
$ export PYTHONPATH=${PYTHONPATH}:/home/robot/ev3dev-lang-python/ev3dev/
IrishClanger commented 7 years ago

No luck I'm afraid. It does not seem to be paying attention to the PYTHONPATH or something. I still got an error about not being able to find ev3dev.motor.

Maybe I would be better to wait until you have finished your transition. If you want to troubleshoot further now:

I then tried running it from the ev3dev-lang-python directory and got a different error. Here is the terminal output for mindcuber.py saying MediumMotor(outC) is not connected. I checked and the motor is connected to output C ok.

robot@ev3dev:~/ev3dev-lang-python$ ./demo/MINDCUB3R/mindcuber.py 
Traceback (most recent call last):
  File "./demo/MINDCUB3R/mindcuber.py", line 513, in <module>
    mcube = MindCuber()
  File "./demo/MINDCUB3R/mindcuber.py", line 41, in __init__
    self.colorarm = MediumMotor(OUTPUT_C)
  File "/home/robot/ev3dev-lang-python/ev3dev/motor.py", line 1025, in __init__
    super(MediumMotor, self).__init__(address, name_pattern, name_exact, driver_name=['lego-ev3-m-motor'], **kwargs)
  File "/home/robot/ev3dev-lang-python/ev3dev/motor.py", line 297, in __init__
    self.max_rps = float(self.max_speed/self.count_per_rot)
  File "/home/robot/ev3dev-lang-python/ev3dev/motor.py", line 497, in max_speed
    self._max_speed, value = self.get_attr_int(self._max_speed, 'max_speed')
  File "/home/robot/ev3dev-lang-python/ev3dev/__init__.py", line 263, in get_attr_int
    attribute, value = self._get_attribute(attribute, name)
  File "/home/robot/ev3dev-lang-python/ev3dev/__init__.py", line 220, in _get_attribute
    raise Exception("%s is not connected" % self)
Exception: MediumMotor(outC) is not connected
robot@ev3dev:~/ev3dev-lang-python$ ./demo/MINDCUB3R/calibrate_white.py 
Traceback (most recent call last):
  File "./demo/MINDCUB3R/calibrate_white.py", line 30, in <module>
    mcube = MindCuber()
  File "/home/robot/ev3dev-lang-python/demo/MINDCUB3R/mindcuber.py", line 41, in __init__
    self.colorarm = MediumMotor(OUTPUT_C)
  File "/home/robot/ev3dev-lang-python/ev3dev/motor.py", line 1025, in __init__
    super(MediumMotor, self).__init__(address, name_pattern, name_exact, driver_name=['lego-ev3-m-motor'], **kwargs)
  File "/home/robot/ev3dev-lang-python/ev3dev/motor.py", line 297, in __init__
    self.max_rps = float(self.max_speed/self.count_per_rot)
  File "/home/robot/ev3dev-lang-python/ev3dev/motor.py", line 497, in max_speed
    self._max_speed, value = self.get_attr_int(self._max_speed, 'max_speed')
  File "/home/robot/ev3dev-lang-python/ev3dev/__init__.py", line 263, in get_attr_int
    attribute, value = self._get_attribute(attribute, name)
  File "/home/robot/ev3dev-lang-python/ev3dev/__init__.py", line 220, in _get_attribute
    raise Exception("%s is not connected" % self)
Exception: MediumMotor(outC) is not connected
robot@ev3dev:~/ev3dev-lang-python$ 

Thanks, Mark.

IrishClanger commented 7 years ago

I discovered that PYTHONPATH should be the directory above the one you gave but I still get the motor error. export PYTHONPATH=:/home/robot/ev3dev-lang-python/

IrishClanger commented 7 years ago

Ah, I reseated the cables on the Motor and it found it but complained about the ColorSensor. I reseated that and it has run ok!

IrishClanger commented 7 years ago

I ran the program a fair few times. I had one occasion where it solved the cube but mixed up a couple of the whites and yellows (I had run calibration) but this was in a room with overhead LED lights so there was shadowing. I tried again in a more dimly lit room and, after a few goes where it failed to turn the cube over properly, it solved the cube correctly! Overall it does well since it only does a single scan of the colours. The current official program does 3 scans and still fails to identify the colours well in which case it just quits. I get the impression from the logging info that your program makes a best guess at some of the squares if it has not got a definite colour.

dwalton76 commented 7 years ago

@IrishClanger the next time it fails can you attach the /tmp/rubiks-color-resolver.html file to the ticket here? That will help me figure out what is going on.

dwalton76 commented 6 years ago

@IrishClanger please re-open this issue if you get it to fail again