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

Problem with Color Sensor #9

Open
aeblik opened this issue Apr 17, 2024 · 2 comments
Open

Problem with Color Sensor #9

aeblik opened this issue Apr 17, 2024 · 2 comments

Comments

@aeblik
Copy link

aeblik commented Apr 17, 2024

For a school project we are trying to work with the color sensor. We don't understand how to use the implemented functions. We tried the following approach:

from lib.interface import Interface
from serial.tools import list_ports

available_ports = list_ports.comports()
print(f'available ports: {[x.device for x in available_ports]}')

port = available_ports[0].device
bot = Interface(port)

print('Bot status:', 'connected' if bot.connected() else 'not connected')

bot.set_color_sensor(1, True, port, version="2")

But keep running into a struct.error in the parsers library: "required argument is not an integer". Specifically in line 82.

Did anyone have success with the color sensor or is somehow able to help us?

@AlexGustafsson
Copy link
Owner

I no longer have access to the robot and quite frankly it's been a while since I looked at the code. Could it be that the port you're using is intended to be a dobot port number, rather than the serial port? Since the bot instance already has knowledge of the port, I can't see why I would have a function taking that as an argument again. Try with values like 0, 1 or something and see if that correlates to a port on the robot.

@aeblik
Copy link
Author

aeblik commented Apr 23, 2024

Thank you for the quick response! We are working with the Dobots again right now and you were absolutely right. I had to use the dobot port number. The remaining problem we have is that the color sensor alwways returns (0, 0, 1) or (0, 1, 0). We are trying to figure out wether this comes from the index argument in the function or the sensor itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants