Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7503

Python • Re: HuskyLensLibrary Attribute Error

$
0
0


So now I'm trying to use requestAll() attribute.

Code:

hl.requestAll()blocks = hl.blocks()if blocks and len(blocks) > 0:    first_object = blocks[0]    print(f"ID: {first_object.ID}, X: {first_object.x}, Y: {first_object.y}")else:    print("🔍 No objects detected")
but I get an indexError: list index out of range. The compiler says something is wrong with blocks = hl.blocks().

1. You make a call to hl.requestAll() but don't make any use the data that is returned.

2. the blocks method is defined as -

Code:

def blocks(self):        cmd = self.cmdToBytes(commandHeaderAndAddress+"002131")        self.writeToHuskyLens(cmd)        return self.processReturnData()[0]
I think I am correct in saying that it returns a single value. So it won't be a list, and therefore won't have an index or length.



This will be my final contribution. I suggest seeing if Robert Prast, the developer of this undocumented library, is still at DFRobot, using the contact details given in the README.md for the Github repository. Or raise an Issue in the Repository. (But I think the chances of getting a reply are slim...) https://github.com/HuskyLens/HUSKYLENSPython/issues And note that Issue #18 seems directly relevant to your query. https://github.com/HuskyLens/HUSKYLENSPython/issues/18

Statistics: Posted by B.Goode — Sun Jul 20, 2025 5:48 pm



Viewing all articles
Browse latest Browse all 7503

Trending Articles