moveToPosition - Python
Hello, all.
I was trying to implement "moveToPosition" in the Python API based on this.
This is what I did:
def moveToPosition(self, x, y, z, velocity, drivetrain, yaw_mode, lookahead, adaptive_lookahead):
return self.client.call('moveToPosition',x, y, z, velocity, drivetrain, yaw_mode, lookahead, adaptive_lookahead)
But got this error:
File "/home/vinicius/.local/lib/python3.5/site-packages/msgpackrpc/session.py", line 41, in call
return self.send_request(method, args).get()
File "/home/vinicius/.local/lib/python3.5/site-packages/msgpackrpc/session.py", line 51, in send_request
self._transport.send_message([message.REQUEST, msgid, method, args])
File "/home/vinicius/.local/lib/python3.5/site-packages/msgpackrpc/transport/tcp.py", line 94, in send_message
sock.send_message(message, callback)
File "/home/vinicius/.local/lib/python3.5/site-packages/msgpackrpc/transport/tcp.py", line 19, in send_message
self._stream.write(self._packer.pack(message), callback=callback)
File "msgpack/_packer.pyx", line 231, in msgpack._packer.Packer.pack (msgpack/_packer.cpp:3661)
File "msgpack/_packer.pyx", line 233, in msgpack._packer.Packer.pack (msgpack/_packer.cpp:3503)
File "msgpack/_packer.pyx", line 221, in msgpack._packer.Packer._pack (msgpack/_packer.cpp:3230)
File "msgpack/_packer.pyx", line 221, in msgpack._packer.Packer._pack (msgpack/_packer.cpp:3230)
File "msgpack/_packer.pyx", line 224, in msgpack._packer.Packer._pack (msgpack/_packer.cpp:3312)
File "/home/vinicius/.local/lib/python3.5/site-packages/msgpackrpc/transport/tcp.py", line 12, in <lambda>
self._packer = msgpack.Packer(encoding=encodings[0], default=lambda x: x.to_msgpack())
AttributeError: 'YawMode' object has no attribute 'to_msgpack'
I would really appreciate if someone have a good idea to help me fix it. Thank you!
This PythonClient.py API works and I've tested moveToPosition. You'll see in there how YawMode has to be passed, namely, as a tuple.
Thanks! I haven't pulled the new commit.
hi, I have the same problem with you. Could you tell me how to solve it? thanks
Traceback (most recent call last):
File "pponew.py", line 325, in
Actually that is a different error:
AttributeError: 'numpy.float32' object has no attribute 'to_msgpack'
You might be able to fix this one by casting whatever values you are setting on the car_controls object to python float, so they do not remain as numpy.float32, something like this:
car_controls.steering = float(x)