Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

struct.error: required argument is not an integer

I have the following python code:

velocity = 0
rotation = 0
vr = velocity + (rotation/2)
vl = velocity - (rotation/2)
cmd = struct.pack(">Bhh", 145, vr, vl)

I dealing with the following error:

File "control.py", line 125, in __init__  
cmd = struct.pack(">Bhh", 145, vr, vl)  
struct.error: required argument is not an integer
like image 898
C0NFUS3D Avatar asked Sep 06 '15 07:09

C0NFUS3D


1 Answers

You are using the incorrect formats for the arguments you are passing in: h format indicates storing of short, while the value you are passing in, i.e. vr and vl, look like doubles.

Consider typecasting them to int or using ">Bdd" format.

like image 133
musically_ut Avatar answered Oct 26 '22 22:10

musically_ut