Esempio n. 1
0
    def morseable(self, calling_module=None):
        """ Make this component simulable in MORSE

        :param calling_module: Module called each simulation cycle.
                               enum in ['calling.sensor_action',
                                        'calling.actuator_action',
                                        'calling.robot_action']

        """
        if not calling_module:
            calling_module = "calling." + self._category[:-1] + "_action"
        # add default class to this component
        if calling_module == "calling.robot_action":
            self.properties(Robot_Tag=True, classpath="morse.core.robot.Robot")
        elif calling_module == "calling.sensor_action":
            self.properties(Component_Tag=True, classpath="morse.core.sensor.Sensor")
        elif calling_module == "calling.actuator_action":
            self.properties(Component_Tag=True, classpath="morse.core.actuator.Actuator")
        else:
            logger.warning(self.name + ": unknown category: " + calling_module)

        # add Game Logic sensor and controller to simulate the component
        # Sensor: Always --- Controller: Python: module = 'calling.XXX_action'
        self.select()
        bpymorse.add_sensor(type="ALWAYS", name="MORSE_LOGIC")
        sensor = self._bpy_object.game.sensors[-1]
        sensor.use_pulse_true_level = True
        bpymorse.add_controller(type="PYTHON")
        controller = self._bpy_object.game.controllers[-1]
        controller.mode = "MODULE"
        controller.module = calling_module
        controller.link(sensor=sensor)
Esempio n. 2
0
    def morseable(self, calling_module=None):
        """ Make this component simulable in MORSE

        :param calling_module: Module called each simulation cycle.
                               enum in ['calling.sensor_action',
                                        'calling.actuator_action',
                                        'calling.robot_action']

        """
        if not calling_module:
            calling_module = 'calling.' + self._category[:-1] + '_action'
        # add default class to this component
        if calling_module == 'calling.robot_action':
            self.properties(Robot_Tag=True, classpath='morse.core.robot.Robot')
        elif calling_module == 'calling.sensor_action':
            self.properties(Component_Tag=True,
                            classpath='morse.core.sensor.Sensor')
        elif calling_module == 'calling.actuator_action':
            self.properties(Component_Tag=True,
                            classpath='morse.core.actuator.Actuator')
        else:
            logger.warning(self.name + ": unknown category: " + calling_module)

        # add Game Logic sensor and controller to simulate the component
        # Sensor: Always --- Controller: Python: module = 'calling.XXX_action'
        self.select()
        bpymorse.add_sensor(type='ALWAYS', name='MORSE_LOGIC')
        sensor = self._bpy_object.game.sensors[-1]
        sensor.use_pulse_true_level = True
        bpymorse.add_controller(type='PYTHON')
        controller = self._bpy_object.game.controllers[-1]
        controller.mode = 'MODULE'
        controller.module = calling_module
        controller.link(sensor=sensor)
Esempio n. 3
0
    def setgraspable(self):
        """
        Makes an object graspable to the human avatar by adding a NEAR collision
        sensor to the object.

        This function also set the object to be an active game object (property
        'Object' set to true), and set the object label to the Blender object
        name (if not already set).
        """
        obj = self._bpy_object

        if not "Label" in obj.game.properties:
            self.properties(Object=True, Graspable=True, Label=obj.name)
        else:
            self.properties(Object=True, Graspable=True)

        # Add collision sensor for object placement
        if not 'Collision' in obj.game.sensors:
            bpymorse.add_sensor(type='NEAR')
            sens = obj.game.sensors[-1]
            sens.name = 'Collision'
            sens.distance = 0.05
            sens.reset_distance = 0.075
            bpymorse.add_controller()
            contr = obj.game.controllers[-1]
            contr.link(sensor=sens)
Esempio n. 4
0
    def setgraspable(self):
        """
        Makes an object graspable to the human avatar by adding a NEAR collision
        sensor to the object.

        This function also set the object to be an active game object (property
        'Object' set to true), and set the object label to the Blender object
        name (if not already set).
        """
        obj = self._bpy_object

        if not "Label" in obj.game.properties:
            self.properties(Object=True, Graspable=True, Label=obj.name)
        else:
            self.properties(Object=True, Graspable=True)

        # Add collision sensor for object placement
        if not "Collision" in obj.game.sensors:
            bpymorse.add_sensor(type="NEAR")
            sens = obj.game.sensors[-1]
            sens.name = "Collision"
            sens.distance = 0.05
            sens.reset_distance = 0.075
            bpymorse.add_controller()
            contr = obj.game.controllers[-1]
            contr.link(sensor=sens)
Esempio n. 5
0
    def morseable(self, calling_module=None):
        """ Make this component simulable in MORSE

        :param calling_module: Module called each simulation cycle.
            enum in ['calling.sensor_action', 'calling.actuator_action',
                    'calling.robot_action']
        """
        if not calling_module:
            calling_module = 'calling.'+self._category[:-1]+'_action'
        # add default class to this component
        if calling_module == 'calling.robot_action':
            self.properties(Robot_Tag = True, Path = 'morse/core/robot', \
                Class = 'Robot')
        elif calling_module == 'calling.sensor_action':
            self.properties(Component_Tag = True, Path = 'morse/core/sensor', \
                Class = 'Sensor')
        elif calling_module == 'calling.actuator_action':
            self.properties(Component_Tag = True, Path = 'morse/core/actuator',\
                Class = 'Actuator')
        else:
            logger.warning(self.name + ": unknown category: " + calling_module)

        # add Game Logic sensor and controller to simulate the component
        self.select()
        bpymorse.add_sensor(type='ALWAYS')
        sensor = self._bpy_object.game.sensors[-1]
        sensor.use_pulse_true_level = True
        bpymorse.add_controller(type='PYTHON')
        controller = self._bpy_object.game.controllers[-1]
        controller.mode = 'MODULE'
        controller.module = calling_module
        controller.link(sensor = sensor)
Esempio n. 6
0
 def make_grasper(self, obj_name):
     obj = bpymorse.get_object(obj_name)
     bpymorse.select_only(obj)
     bpymorse.add_sensor(type='NEAR')
     sens = obj.game.sensors[-1]
     sens.name = 'Near'
     sens.distance = 5.0
     sens.reset_distance = 0.075
     sens.property = "Graspable"
     bpymorse.add_controller()
     contr = obj.game.controllers[-1]
     contr.link(sensor=sens)
Esempio n. 7
0
 def make_grasper(self, obj_name):
     obj = bpymorse.get_object(obj_name)
     bpymorse.select_only(obj)
     bpymorse.add_sensor(type = 'NEAR')
     sens = obj.game.sensors[-1]
     sens.name = 'Near'
     sens.distance = 5.0
     sens.reset_distance = 0.075
     sens.property = "Graspable"
     bpymorse.add_controller()
     contr = obj.game.controllers[-1]
     contr.link(sensor = sens)