Vision Sensor gives an error when used.
Error reads
Traceback (most recent call last): Python exception…
File “userpy”, line 74, in
File “userpy”, line 59, in when_started1
TypeError: indices must be integers
I have tried with multiple vision sensors and multiple brain.
Code works if I just ask if object exists, but throws the error if I ask it to find any measurements.
Please help
Patrick
There was no need to post this topic multiple times, can you post the code you are using so we can help you.
1 Like
To use that command / block you need to do the following:
You can use help inside VEXcode for more documentation.
vexcode_vision_6_objects = None
vexcode_brain_precision = 0
vexcode_console_precision = 0
vexcode_vision_6_object_index = None
myVariable = 0
def when_started1():
global myVariable, vexcode_vision_6_objects, vexcode_brain_precision, vexcode_console_precision, vexcode_vision_6_object_index
while True:
brain.screen.set_cursor(1, 1)
vexcode_vision_6_objects = vision_6.take_snapshot(vision_6__YELLOW_BALL)
if vexcode_vision_6_objects and len(vexcode_vision_6_objects) > 0:
brain.screen.clear_screen()
brain.screen.print("Object Exists")
brain.screen.print(vexcode_vision_6_objects[vexcode_vision_6_object_index].width, precision=6 if vexcode_brain_precision is None else vexcode_brain_precision)
else:
brain.screen.clear_screen()
brain.screen.print("Object Does Not Exist")
wait(5, MSEC)
when_started1()
You need to use the “set Vision6 object item to 1” block as the index into the array is currently None.
2 Likes
Processing: Screenshot 2023-09-25 131754.png…
I am not actually programming in python, I am programming in Blocks, but I am having a hard time uploading the blocks code.
system
Closed
September 24, 2024, 8:34pm
7
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.