Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

None dereference error when only one motor is connected #21

Open
drigz opened this issue Jul 14, 2016 · 2 comments
Open

None dereference error when only one motor is connected #21

drigz opened this issue Jul 14, 2016 · 2 comments
Assignees
Labels

Comments

@drigz
Copy link

drigz commented Jul 14, 2016

Connect only one motor to the brick and try to send a program to drive a short distance.

robot@ev3dev:~$ python NEPOprog.py 
Exception AttributeError: "'LargeMotor' object has no attribute '_path'" in <bound method LargeMotor.__del__ of <ev3dev.core.LargeMotor object at 0xb65f7d50>> ignored
Traceback (most recent call last):
  File "NEPOprog.py", line 44, in <module>
    main()
  File "NEPOprog.py", line 33, in main
    run()
  File "NEPOprog.py", line 29, in run
    hal.driveDistance('C', 'B', False, 'foreward', 30, 20)
  File "/usr/lib/python2.7/dist-packages/roberta/ev3.py", line 353, in driveDistance
    ml.run_to_rel_pos(speed_regulation_enabled='on',
AttributeError: 'NoneType' object has no attribute 'run_to_rel_pos'

NEPOprog.py:

#!/usr/bin/python

from __future__ import absolute_import
from roberta.ev3 import Hal
from roberta.BlocklyMethods import BlocklyMethods
from sets import Set
from ev3dev import ev3 as ev3dev
import math

TRUE = True
_brickConfiguration = {
    'wheel-diameter': 5.6,
    'track-width': 18.0,
    'actors': {
        'B':Hal.makeLargeMotor(ev3dev.OUTPUT_B, 'on', 'foreward', 'right'),
        'C':Hal.makeLargeMotor(ev3dev.OUTPUT_C, 'on', 'foreward', 'left'),
    },
    'sensors': {
        '1':Hal.makeTouchSensor(ev3dev.INPUT_1),
        '2':Hal.makeGyroSensor(ev3dev.INPUT_2),
        '3':Hal.makeColorSensor(ev3dev.INPUT_3),
        '4':Hal.makeUltrasonicSensor(ev3dev.INPUT_4),
    },
}
_usedSensors = Set([])
hal = Hal(_brickConfiguration, _usedSensors)

def run():
    hal.driveDistance('C', 'B', False, 'foreward', 30, 20)

def main():
    try:
        run()
    except Exception as e:
        hal.drawText('Fehler im EV3', 0, 0)
        hal.drawText(e.__class__.__name__, 0, 1)
        if e.message:
            hal.drawText(e.message, 0, 2)
        hal.drawText('Press any key', 0, 4)
        while not hal.isKeyPressed('any'): hal.waitFor(500)
        raise

if __name__ == "__main__":
    main()
@ensonic
Copy link
Contributor

ensonic commented Jul 15, 2016

The issue is that we create brickconfiguration entries for also unused elements. Right now the factory methods there are non-fatal, that is in case of error they return None.
We want to only create the brickconfiguration for used elements and then fail if we can't create all of them.
In OpenRoberta/robertalab@d771049684fa6c3d8e4e3e4da9df3f3bfbd70607 I am unly instantiating sensors that are used.

  • also need to constrain this to actors
  • make actor / sensor instantiation failures fatal again

The plan is to rename
https://github.com/OpenRoberta/robertalab/blob/HEAD/OpenRobertaRobot/src/main/java/de/fhg/iais/roberta/syntax/hardwarecheck/ev3/UsedSensorsCheckVisitor.java
to UsedHardwareCheckVisitor.java, track other resources too and add a getter for usedActors.

@ensonic ensonic self-assigned this Jul 15, 2016
@ensonic ensonic added the bug label Jul 15, 2016
@ensonic
Copy link
Contributor

ensonic commented Sep 23, 2016

The refactoring of the server code is done.

@ensonic ensonic mentioned this issue Sep 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants