richrd / nxt-python

Automatically exported from code.google.com/p/nxt-python
GNU General Public License v3.0
1 stars 0 forks source link

object has no attribute 'set_input_mode' #62

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am using a Raspberry Pi with nxt-python-2.2.2 to control a small robot I have 
built. I have been able to use the test_sensor.py program successfully, but 
when I try to use the HiTechnic motor controller I get the following error.

pi@raspberrypi ~/nxt-python-2.2.2/examples $ sudo python htmotor1.py
Traceback (most recent call last):
  File "htmotor1.py", line 7, in <module>
    v = nxt.sensor.hitechnic.MotorCon(b, PORT_1).get_battery_voltage()
  File "/usr/local/lib/python2.7/dist-packages/nxt/sensor/hitechnic.py", line 54 3, in __init__
    super(MotorCon, self).__init__(brick, port, check_compatible)
  File "/usr/local/lib/python2.7/dist-packages/nxt/sensor/digital.py", line 65,  in __init__
    self.set_input_mode(Type.LOW_SPEED_9V, Mode.RAW)
  File "/usr/local/lib/python2.7/dist-packages/nxt/sensor/common.py", line 67, i n set_input_mode
    self.brick.set_input_mode(self.port, type_, mode)
AttributeError: 'function' object has no attribute 'set_input_mode'

I am new to python and don't really know how to fix this problem. The code I 
wrote is below.

#!/usr/bin/env python

import nxt.locator
from nxt.sensor import *

b = nxt.locator.find_one_brick
v = nxt.sensor.hitechnic.MotorCon(b, PORT_1).get_battery_voltage()

print v

Please let me know if there is a mistake in my code that is causing the 
problem. I will be happy to help test any solutions if you need. Thanks.

Original issue reported on code.google.com by m.sidler...@gmail.com on 17 Oct 2013 at 8:28

GoogleCodeExporter commented 9 years ago
The issue has been resolved here:

https://groups.google.com/forum/#!topic/nxt-python/LRzLpUcU3Vc

The problem was with my code, but we also discovered a typo that needs to be 
fixed.

Original comment by m.sidler...@gmail.com on 20 Nov 2013 at 3:01