ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
429 stars 145 forks source link

Difficulty Connecting Old HiTechnic Infrared Seeker to ev3dev Brick #779

Closed MichaelBonnet closed 2 years ago

MichaelBonnet commented 2 years ago
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                   Version          Architecture     Description
+++-======================-================-================-=================================================
ii  micropython-ev3dev2    2.1.0            all              Python language bindings for ev3dev for MicroPyth
ii  python3-ev3dev         1.2.0            all              Python language bindings for ev3dev
ii  python3-ev3dev2        2.1.0            all              Python language bindings for ev3dev

Problem

I am trying to somehow connect the old version of the HiTechnic NXT Infrared Seeker, part number MS1042. I have been able to find vanishingly little information on this module.

Background Info: Device Browser -> Sensors reveals just one sensor connected (a LEGO Ultrasonic Sensor), when this IR seeker is fully and securely plugged in. Device Browser -> Ports -> ev3-ports:in1 (where the ultrasonic sensor is connected) shows ev3-input-port as driver name, ev3-uart as status. Device Browser -> Ports -> ev3-ports:in2 (where this IR seeker is connected) shows ev3-input-port as driver name, nxt-i2c as status, which looking at the documentation for the new IR seeker, seems correct.

Code:

#!/usr/bin/env python3

###############
### IMPORTS ###
###############

from ev3dev2.sensor import Sensor
from ev3dev2.motor import LargeMotor, OUTPUT_A, OUTPUT_B, SpeedPercent, MoveTank
from ev3dev2.sensor import INPUT_1, INPUT_2, INPUT_3, INPUT_4, Sensor
from ev3dev2.sensor.lego import UltrasonicSensor
from ev3dev2.led import Leds

left_motor  = LargeMotor(OUTPUT_A)
right_motor = LargeMotor(OUTPUT_B)
us = UltrasonicSensor(INPUT_1)
ir = Sensor(INPUT_2, driver_name='ht-nxt-ir-seek-v2')
ir.mode = 'DC'
us.MODE_US_DIST_CM = 'US_DIST_CM'

while True:
    print(ir.value(0))
    # print( str(us.value()) + " mm")

Error:

Traceback (most recent call last):
  File "/home/robot/Project_3/main.py", line 16, in <module>
    ir = Sensor(INPUT_2, driver_name='ht-nxt-ir-seeker-v2')
  File "/usr/lib/python3/dist-packages/ev3dev2/sensor/__init__.py", line 78, in __init__
    super(Sensor, self).__init__(self.SYSTEM_CLASS_NAME, name_pattern, name_exact, **kwargs)
  File "/usr/lib/python3/dist-packages/ev3dev2/__init__.py", line 223, in __init__
    chain_exception(DeviceNotFound("%s is not connected." % self), None)
  File "/usr/lib/python3/dist-packages/ev3dev2/__init__.py", line 54, in chain_exception
    raise exception from cause
ev3dev2.DeviceNotFound: Sensor(ev3-ports:in2) is not connected.

Variations of 'ht-nxt-ir-seek-v2' such as v1, removing the v2, seek -> seeker, do nothing for me. Fundamentally, it is failing to recognize the device as connected. I'm not sure where to go from here.

MichaelBonnet commented 2 years ago

I'm sort of having the feeling that writing a driver may be the solution here, but I wouldn't be sure where to start.

MichaelBonnet commented 2 years ago

I believe I opened this issue in the wrong place, apologies.