iCub-main
Loading...
Searching...
No Matches
python_simworld_control.WorldController Class Reference

Public Member Functions

 __init__ (self)
 create_object (self, obj, size, location, colour)
 move_object (self, obj_id, location)
 rotate_object (self, obj_id, rotation)
 get_object_location (self, obj_id)
 del_all (self)
 __del__ (self)

Protected Member Functions

 _execute (self, cmd)
 _is_success (self, ans)
 _prepare_del_all_command (self)
 _prepare_create_command (self, obj, size, location, colour)
 _prepare_move_command (self, obj, obj_id, location)
 _prepare_rot_command (self, obj, obj_id, rotation)
 _prepare_get_command (self, obj, obj_id)

Protected Attributes

 _rpc_client = yarp.RpcClient()
str _port_name = "/WorldController-" + str(id(self)) + "/commands"
 _sim_ids_counters = collections.defaultdict(lambda:0)
list _objects = [ ]

Detailed Description

Class for controlling iCub simulator via its RPC world port.

Definition at line 7 of file python_simworld_control.py.

Constructor & Destructor Documentation

◆ __init__()

python_simworld_control.WorldController.__init__ ( self)

Definition at line 10 of file python_simworld_control.py.

◆ __del__()

python_simworld_control.WorldController.__del__ ( self)

Definition at line 146 of file python_simworld_control.py.

Member Function Documentation

◆ _execute()

python_simworld_control.WorldController._execute ( self,
cmd )
protected
Execute an RPC command, returning obtained answer bottle.

Definition at line 23 of file python_simworld_control.py.

◆ _is_success()

python_simworld_control.WorldController._is_success ( self,
ans )
protected
Check if RPC call answer Bottle indicates successfull execution.

Definition at line 29 of file python_simworld_control.py.

◆ _prepare_create_command()

python_simworld_control.WorldController._prepare_create_command ( self,
obj,
size,
location,
colour )
protected
Prepare an RPC command for creating an object in the simulator environment.
        
        See Simulator Readme section 'Object Creation'
        
        Parameters:
            obj - object type string. 'sph', 'box', 'cyl' 'ssph', 'sbox' or 'scyl'.
            size - list of values specifying the size of an object. Parameters depend on object type:
                (s)box: [ x, y, z ]
                (s)sph: [ radius ]
                (s)cyl: [ radius, length ]
            location - coordinates of the object location, [ x, y, z ]
            colour - object colour in RGB (normalised), [ r, g, b ]
        Returns:
            yarp.Bottle with the command, ready to be sent to the rpc port of the simulator

Definition at line 40 of file python_simworld_control.py.

◆ _prepare_del_all_command()

python_simworld_control.WorldController._prepare_del_all_command ( self)
protected
Prepare the "world del all" command bottle.

Definition at line 33 of file python_simworld_control.py.

◆ _prepare_get_command()

python_simworld_control.WorldController._prepare_get_command ( self,
obj,
obj_id )
protected
Prepare the "world get <obj> <id>" command bottle.

Definition at line 89 of file python_simworld_control.py.

◆ _prepare_move_command()

python_simworld_control.WorldController._prepare_move_command ( self,
obj,
obj_id,
location )
protected
Prepare the "world set <obj> <xyz>" command bottle.

Definition at line 67 of file python_simworld_control.py.

◆ _prepare_rot_command()

python_simworld_control.WorldController._prepare_rot_command ( self,
obj,
obj_id,
rotation )
protected
Prepare the "world rot <obj> <rotxyz>" command bottle.

Definition at line 78 of file python_simworld_control.py.

◆ create_object()

python_simworld_control.WorldController.create_object ( self,
obj,
size,
location,
colour )
Create an object of a specified type, size, location and colour, returning internal object ID or -1 on error.

Definition at line 99 of file python_simworld_control.py.

◆ del_all()

python_simworld_control.WorldController.del_all ( self)
Delete all objects from the simultor

Definition at line 135 of file python_simworld_control.py.

◆ get_object_location()

python_simworld_control.WorldController.get_object_location ( self,
obj_id )
Obtain the object location from the simulator. Returns None on failure.

Definition at line 126 of file python_simworld_control.py.

◆ move_object()

python_simworld_control.WorldController.move_object ( self,
obj_id,
location )
Move an object specified by the internal id to another location.

Definition at line 116 of file python_simworld_control.py.

◆ rotate_object()

python_simworld_control.WorldController.rotate_object ( self,
obj_id,
rotation )
Rotate an object specified by the internal id giving its absolute rotation.

Definition at line 121 of file python_simworld_control.py.

Member Data Documentation

◆ _objects

python_simworld_control.WorldController._objects = [ ]
protected

Definition at line 21 of file python_simworld_control.py.

◆ _port_name

python_simworld_control.WorldController._port_name = "/WorldController-" + str(id(self)) + "/commands"
protected

Definition at line 12 of file python_simworld_control.py.

◆ _rpc_client

python_simworld_control.WorldController._rpc_client = yarp.RpcClient()
protected

Definition at line 11 of file python_simworld_control.py.

◆ _sim_ids_counters

python_simworld_control.WorldController._sim_ids_counters = collections.defaultdict(lambda:0)
protected

Definition at line 17 of file python_simworld_control.py.


The documentation for this class was generated from the following file: