ev3dev / ev3dev-lang-python

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

pycharm shows ColorSensor is not connected #698

Closed xingtianyux closed 4 years ago

xingtianyux commented 4 years ago
**I want to use the color sensor to detect colors. the hardwares are connected well and my code is following:** import ev3dev.ev3 as ev3 cs = ev3.ColorSensor(ev3.INPUT_3) cs.mode = 'COL-COLOR' col = cs.value() print(col) **if I run the file in SSH, I can get the return value, but in pycharm I cannot get it which shows my color sensor is not connected. like following:** Traceback (most recent call last): File "F:/robot@group-003/sensor.py", line 5, in cs.mode = 'COL-COLOR' File "C:\Users\xty\AppData\Local\Programs\Python\Python38\lib\site-packages\ev3dev\core.py", line 1716, in mode self._mode = self.set_attr_string(self._mode, 'mode', value) File "C:\Users\xty\AppData\Local\Programs\Python\Python38\lib\site-packages\ev3dev\core.py", line 229, in set_attr_string return self._set_attribute(attribute, name, value) File "C:\Users\xty\AppData\Local\Programs\Python\Python38\lib\site-packages\ev3dev\core.py", line 216, in _set_attribute raise Exception("%s is not connected" % self) Exception: ColorSensor(in3) is not connected **How to solve the problem to get the return value in pycharm**
WasabiFan commented 4 years ago

The simple answer is — you can't. The code needs to be running on the EV3 to be able to control the motors/read from sensors. It looks like what you've done is run it on your local machine.

Running via SSH is running on the EV3. Running via pycharm is running it on your own computer.