How to appear object in V-rep- Poppy?

Tags: #<Tag:0x00007f5e050e9448> #<Tag:0x00007f5e050e9308>


Hello everybody!

I started tp use VREP and IP Python Notebook a few weeks ago so I don’t know to much of this kind of programms. The last week I try to appear a cube in front of poppy, but I can’t do that because of a ‘str’ trouble.

io = poppy._controllers[0].io

*# Création du cube devant Poppy

name = 'cube’
position = [0.2, 0, 0.8] # X, Y, Z
sizes = [0.1, 0.1, 0.1] # in meters
mass = 0.5 # in kg
io.add_cube((name, position, sizes, mass)

When I execute thats lines the program send me a Type Error message.

TypeError Traceback (most recent call last)
in ()
3 sizes = [0.1, 0.1, 0.1] # in meters
4 mass = 0.5 # in kg
----> 5 io.add_cube(name, position, sizes, mass)

C:\Users\Me\Anaconda3\lib\site-packages\pypot\vrep\ in add_cube(self, name, position, sizes, mass)
228 def add_cube(self, name, position, sizes, mass):
229 “”" Add Cube “”"
–> 230 self._create_pure_shape(0, 239, sizes, mass, [0, 0])
231 self.set_object_position(“Cuboid”, position)
232 self.change_object_name(“Cuboid”, name)

C:\Users\Me\Anaconda3\lib\site-packages\pypot\vrep\ in _create_pure_shape(self, primitive_type, options, sizes, mass, precision)
261 “”" Create Pure Shape “”"
262 lua_code = “simCreatePureShape({}, {}, {{{}, {}, {}}}, {}, {{{}, {}}})”.format(primitive_type, options, sizes[0], sizes[1], sizes[2], mass, precision[0], precision[1])
–> 263 self._inject_lua_code(lua_code)
265 def _inject_lua_code(self, lua_code):

C:\Users\Me\Anaconda3\lib\site-packages\pypot\vrep\ in _inject_lua_code(self, lua_code)
265 def _inject_lua_code(self, lua_code):
266 “”" Sends raw lua code and evaluate it wihtout any checking! “”"
–> 267 msg = (ctypes.c_ubyte * len(lua_code)).from_buffer_copy(lua_code)
268 self.call_remote_api(‘simxWriteStringStream’, ‘my_lua_code’, msg)

TypeError: ‘str’ does not support the buffer interface

I don’t understand what I have to do, before exposing you this problem I have read something similar, they say that it’s a ‘str’ problem because we have to convert string to bytes.

Can everybody could help me please?



Can you try to replace:

name = 'cube'


name = b'cube'

and let me know if it’s work.


I guess you are using python 3.4. I have the same issue with python 3.x
I didn’t investigate a lot but I thought that the code “.from_buffer_copy” is not compatible with Py3 ??

@Pierre just tested with b’cube’ and it doesn’t work better.

Maybe someone know a python 3 compatible syntax for :

msg = (ctypes.c_ubyte * len(lua_code)).from_buffer_copy(lua_code)


Thanks you Pierre, that doesn’t works , when I replace it sends me an error message.


Yes I’m using Python 3 and as you say in the message error it appears something about the buffer. I’ll keep searching a solution. If I find it I’ll tell you :wink:


with something like that :

msg = (ctypes.c_ubyte * len(lua_code)).from_buffer_copy(bytes(lua_code, 'utf-8')) 

the error message disappear, but I don’t know if the lua injection still works.


@Pierre I made a pull request to fix the issue. Tested on python 2.7 and 3.4




Merged in