New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua code injection issue #149

Closed
cferr opened this Issue Feb 29, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@cferr
Copy link

cferr commented Feb 29, 2016

There's an error happening somewhere in Pypot when trying to create a Cube in Vrep with Poppy by following this tutorial :
https://github.com/poppy-project/poppy-torso/blob/ff6254355ce18a26f58654f5abc82485a7a22d13/software/doc/tutorial/Poppy%20Torso%20interacting%20with%20objects%20in%20V-REP%20using%20Pypot.ipynb

When running the following code :

io = poppy._controllers[0].io

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)

The following error happens :

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-32-4e90037cfd41> in <module>()
      9 sizes = [0.1, 0.1, 0.1] # in meters
     10 mass = 0.5 # in kg
---> 11 io.add_cube(name, position, sizes, mass)
     12 
     13 #io.add_cube

/usr/lib/python3.5/site-packages/pypot/vrep/io.py 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)

/usr/lib/python3.5/site-packages/pypot/vrep/io.py 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)
    264 
    265     def _inject_lua_code(self, lua_code):

/usr/lib/python3.5/site-packages/pypot/vrep/io.py 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)
    269 

TypeError: a bytes-like object is required, not 'str'


I'm using Python 3.5.1, and pypot 2.10.2, if that can be of any help. Having installed pypot via PIP, it probably doesn't come straight from the git repository.
A similar issue had been reported before :
https://forum.poppy-project.org/t/how-to-appear-object-in-v-rep-poppy/1766
The person there tried to do the same as me, and also got a TypeError when pypot was dealing with Lua code.

@pierre-rouanet

This comment has been minimized.

Copy link
Member

pierre-rouanet commented Feb 29, 2016

Indeed it has been merged into master: #117 It will be integrated in the next stable release (hopefully before next week...).

@show0k

This comment has been minimized.

Copy link
Member

show0k commented Mar 25, 2016

#117 is now on pypi.

@show0k show0k closed this Mar 25, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment