Ejemplo n.º 1
0
 def __init__(self, name=None):
     SensorCreator.__init__(self, name)
     self.camera = Camera("CameraRobot")
     self.camera.name = "CameraRobot"
     self.append(self.camera)
     self.properties(cam_width = 256, cam_height = 256, cam_focal = 35.0,
                     capturing = True, Vertical_Flip = True)
     # set the frequency to 20 Hz
     self.frequency(20)
     # add toggle capture action (`Space` key)
     bpymorse.add_sensor(type="KEYBOARD")
     obj = bpymorse.get_context_object()
     sensor = obj.game.sensors[-1]
     sensor.key = 'SPACE'
     bpymorse.add_controller(type='LOGIC_AND')
     controller = obj.game.controllers[-1]
     bpymorse.add_actuator(type='PROPERTY')
     actuator = obj.game.actuators[-1]
     actuator.mode = 'TOGGLE'
     actuator.property = 'capturing'
     controller.link(sensor = sensor, actuator = actuator)
     # looking in +X
     SensorCreator.rotate(self, x=math.pi/2, z=math.pi/2)
     # append CameraMesh with its textures
     self.append_meshes(['CameraMesh'], "camera")
     self.rotate(z=math.pi)
Ejemplo n.º 2
0
 def __init__(self, name=None):
     SensorCreator.__init__(self, name)
     self.camera = Camera("CameraRobot")
     self.camera.name = "CameraRobot"
     self.append(self.camera)
     self.properties(cam_width = 256, cam_height = 256, cam_focal = 35.0,
                     capturing = True, Vertical_Flip = True)
     # set the frequency to 20 Hz
     self.frequency(20)
     # add toggle capture action (`Space` key)
     bpymorse.add_sensor(type="KEYBOARD")
     obj = bpymorse.get_context_object()
     sensor = obj.game.sensors[-1]
     sensor.key = 'SPACE'
     bpymorse.add_controller(type='LOGIC_AND')
     controller = obj.game.controllers[-1]
     bpymorse.add_actuator(type='PROPERTY')
     actuator = obj.game.actuators[-1]
     actuator.mode = 'TOGGLE'
     actuator.property = 'capturing'
     controller.link(sensor = sensor, actuator = actuator)
     # looking in +X
     SensorCreator.rotate(self, x=math.pi/2, z=math.pi/2)
     # append CameraMesh with its textures
     self.mesh = self.append_meshes(['CameraMesh'], "camera")[0]
     self.rotate(z=math.pi)
Ejemplo n.º 3
0
 def __init__(self, name=None, cclass="VideoCameraClass", \
              cpath="morse/sensors/video_camera", bname = "video_camera"):
     SensorCreator.__init__(self, name, cpath, cclass, bname)
     camera = Camera("CameraRobot")
     camera.name = "CameraRobot"
     self.append(camera)
     self.properties(cam_width = 256, cam_height = 256, cam_focal = 35.0, \
                     capturing = True, Vertical_Flip = True)
     # set the frequency to 3 (20ips for ticrate = 60Hz)
     self.frequency(3)
     # add toggle capture action (`Space` key)
     bpymorse.add_sensor(type="KEYBOARD")
     obj = bpymorse.get_context_object()
     sensor = obj.game.sensors[-1]
     sensor.key = 'SPACE'
     bpymorse.add_controller(type='LOGIC_AND')
     controller = obj.game.controllers[-1]
     bpymorse.add_actuator(type='PROPERTY')
     actuator = obj.game.actuators[-1]
     actuator.mode = 'TOGGLE'
     actuator.property = 'capturing'
     controller.link(sensor = sensor, actuator = actuator)
     # looking in +x
     self.rotate(x=math.pi/2, z=-math.pi/2)
     # append CameraMesh with its textures
     imported_objects = self.append_meshes(['CameraMesh'], "video_camera")
     # TODO fix the CameraMesh location and rotation in video_camera.blend
     camera_mesh = imported_objects[0]
     camera_mesh.rotation_euler = (math.pi/2, -math.pi/2, 0)
     camera_mesh.location = (0, 0, 0.015)
Ejemplo n.º 4
0
 def __init__(self, name=None):
     SensorCreator.__init__(self, name)
     mesh = Cylinder("SearchAndRescueCylinder")
     mesh.scale = (.15, .04, .04)
     mesh.color(.2, .8, .6)
     mesh.rotate(y = math.pi / 2)
     self.append(mesh)
     self.frequency(6)
     self.properties(Heal_range = 2.0, Abilities = "1,2")
     # add Radar freq: 3 Hz, prop: Injured, angle: 60.0, distance: 10.0
     bpymorse.add_sensor(type="RADAR", name="Radar")
     obj = bpymorse.get_context_object()
     sensor = obj.game.sensors[-1]
     sensor.angle = 60.0
     sensor.distance = 10.0
     sensor.use_pulse_true_level = True
     sensor.frequency = 20
     sensor.property = "Injured"
     # link it to the Python controller
     controller = obj.game.controllers[-1]
     controller.link(sensor = sensor)
Ejemplo n.º 5
0
 def __init__(self, name=None):
     SensorCreator.__init__(self, name)
     mesh = Cylinder("SearchAndRescueCylinder")
     mesh.scale = (.15, .04, .04)
     mesh.color(.2, .8, .6)
     mesh.rotate(y = math.pi / 2)
     self.append(mesh)
     self.frequency(6)
     self.properties(Heal_range = 2.0, Abilities = "1,2")
     # add Radar freq: 3 Hz, prop: Injured, angle: 60.0, distance: 10.0
     bpymorse.add_sensor(type="RADAR", name="Radar")
     obj = bpymorse.get_context_object()
     sensor = obj.game.sensors[-1]
     sensor.angle = 60.0
     sensor.distance = 10.0
     sensor.use_pulse_true_level = True
     self._set_sensor_frequency(sensor, 20)
     sensor.property = "Injured"
     # link it to the Python controller
     controller = obj.game.controllers[-1]
     controller.link(sensor = sensor)
Ejemplo n.º 6
0
 def __init__(self, name=None):
     """ Sensor to detect objects colliding with the current object,
     with more settings than the Touch sensor
     """
     SensorCreator.__init__(self, name)
     obj = bpymorse.get_context_object()
     # Sensor, Collision Sensor, detects static and dynamic objects but
     # not the other collision sensor objects.
     obj.game.physics_type = 'SENSOR'
     # Specify a collision bounds type other than the default
     obj.game.use_collision_bounds = True
     # replace Always sensor by Collision sensor
     sensor = obj.game.sensors[-1]
     sensor.type = 'COLLISION'
     # need to get the new Collision Sensor object
     sensor = obj.game.sensors[-1]
     sensor.use_pulse_true_level = True # FIXME doesnt seems to have any effect
     # Component mesh (eye sugar)
     mesh = Cube("CollisionMesh")
     mesh.scale = (.02, .02, .02)
     mesh.color(.8, .2, .1)
     self.append(mesh)
Ejemplo n.º 7
0
 def __init__(self, name=None):
     """ Sensor to detect objects colliding with the current object,
     with more settings than the Touch sensor
     """
     SensorCreator.__init__(self, name)
     obj = bpymorse.get_context_object()
     # Sensor, Collision Sensor, detects static and dynamic objects but
     # not the other collision sensor objects.
     obj.game.physics_type = 'SENSOR'
     # Specify a collision bounds type other than the default
     obj.game.use_collision_bounds = True
     # replace Always sensor by Collision sensor
     sensor = obj.game.sensors[-1]
     sensor.type = 'COLLISION'
     # need to get the new Collision Sensor object
     sensor = obj.game.sensors[-1]
     sensor.use_pulse_true_level = True  # FIXME doesnt seems to have any effect
     # Component mesh (eye sugar)
     mesh = Cube("CollisionMesh")
     mesh.scale = (.02, .02, .02)
     mesh.color(.8, .2, .1)
     self.append(mesh)
Ejemplo n.º 8
0
 def __init__(self, name=None):
     SensorCreator.__init__(self, name, "morse/sensors/velodyne", \
                            "VelodyneClass", "velodyne")
     # set components-specific properties
     self.properties(Visible_arc = True, laser_range = 50.0, \
                     scan_window = 31.500, resolution = 0.5)
     # Add Always (use_true_level) - And - Motion (rotation z: 0.017453)
     bpymorse.add_sensor(type='ALWAYS')
     obj = bpymorse.get_context_object()
     sensor = obj.game.sensors[-1]
     sensor.use_pulse_true_level = True
     bpymorse.add_controller(type='LOGIC_AND')
     controller = obj.game.controllers[-1]
     # Motion (rotation z: 0.017453)
     bpymorse.add_actuator(type='MOTION')
     actuator = obj.game.actuators[-1]
     actuator.offset_rotation.z = math.radians(1)
     controller.link(sensor = sensor, actuator = actuator)
     # append velodyne mesh, from MORSE_COMPONENTS/sensors/velodyne.blend
     imported_objects = self.append_meshes(['VelodyneMesh', 'Arc_31'])
     # TODO fix the VelodyneMesh location in velodyne.blend (z=1.2m!)
     velodyne_mesh = self.get_child('VelodyneMesh', imported_objects)
     velodyne_mesh.location.z = 0
Ejemplo n.º 9
0
    def __init__(self, name=None):
        """ Sensor to detect objects colliding with the current object.

        Doc: https://www.blender.org/manual/game_engine/logic/sensors/collision.html
        """
        SensorCreator.__init__(self, name)
        obj = bpymorse.get_context_object()
        # Sensor, Collision Sensor, detects static and dynamic objects but
        # not the other collision sensor objects.
        obj.game.physics_type = 'SENSOR'
        # Specify a collision bounds type other than the default
        obj.game.use_collision_bounds = True
        obj.scale = (0.02,0.02,0.02)
        # replace Always sensor by Collision sensor
        sensor = obj.game.sensors[-1]
        sensor.type = 'COLLISION'
        # need to get the new Collision Sensor object
        sensor = obj.game.sensors[-1]
        sensor.use_pulse_true_level = True # FIXME doesnt seems to have any effect
        sensor.use_material = False # we want to filter by property, not by material
        # Component mesh (eye sugar)
        mesh = Cube("CollisionMesh")
        mesh.color(.8, .2, .1)
        self.append(mesh)