def default_action(self): keyboard = blenderapi.keyboard() is_actived = blenderapi.input_active() if keyboard.events[blenderapi.UPARROWKEY] == is_actived: self.local_data['up'] = True else: self.local_data['up'] = False if keyboard.events[blenderapi.DOWNARROWKEY] == is_actived: self.local_data['down'] = True else: self.local_data['down'] = False if keyboard.events[blenderapi.LEFTARROWKEY] == is_actived: self.local_data['left'] = True else: self.local_data['left'] = False if keyboard.events[blenderapi.RIGHTARROWKEY] == is_actived: self.local_data['right'] = True else: self.local_data['right'] = False if keyboard.events[blenderapi.IKEY] == is_actived: self.local_data['i'] = True else: self.local_data['i'] = False if keyboard.events[blenderapi.JKEY] == is_actived: self.local_data['j'] = True else: self.local_data['j'] = False if keyboard.events[blenderapi.KKEY] == is_actived: self.local_data['k'] = True else: self.local_data['k'] = False if keyboard.events[blenderapi.LKEY] == is_actived: self.local_data['l'] = True else: self.local_data['l'] = False
def default_action(self): """ Interpret keyboard presses and assign them to movement for the robot.""" keyboard = blenderapi.keyboard() is_actived = blenderapi.input_active() # Reset movement variables vx, vy, vz = 0.0, 0.0, 0.0 rx, ry, rz = 0.0, 0.0, 0.0 if keyboard.events[blenderapi.UPARROWKEY] == is_actived: vx = self._speed if keyboard.events[blenderapi.DOWNARROWKEY] == is_actived: vx = -self._speed if keyboard.events[blenderapi.LEFTARROWKEY] == is_actived: rz = self._speed if keyboard.events[blenderapi.RIGHTARROWKEY] == is_actived: rz = -self._speed if self._type == "Position" or self._type == "Velocity": self.robot_parent.apply_speed(self._type, [vx, vy, vz], [rx, ry, rz / 2.0]) elif self._type == "Differential": self.robot_parent.apply_vw_wheels(vx, rz)
def default_action(self): """ Main loop of the actuator. Implements the component behaviour """ robot = self.robot_parent force = (robot.bge_object.mass * -9.81) #robot.bge_object.applyForce([0.0, 0.0, force], False) force2 = (robot.bge_object.mass * blenderapi.game_settings().physics_gravity) robot.bge_object.applyForce([0.0, 0.0, force2], False) keyboard = blenderapi.keyboard() is_actived = blenderapi.input_active() if keyboard.events[blenderapi.ZKEY] == is_actived: self.local_data['V'] = self.local_data['V'] + 1.0 print(self.local_data['V']) if keyboard.events[blenderapi.XKEY] == is_actived: self.local_data['V'] = self.local_data['V'] - 1.0 print(self.local_data['V']) force3 = self.local_data['V'] #robot.bge_object.applyForce([0.0, 0.0, force3], False) if not self.do_once: print(robot.bge_object.mass) print(robot.bge_object.getPropertyNames()) print(blenderapi.game_settings().physics_gravity) #print(robot.bge_object.getLinearVelocity()) self.do_once = True
def default_action(self): """ Interpret keyboard presses and assign them to movement for the robot.""" keyboard = blenderapi.keyboard() is_actived = blenderapi.input_active() # Reset movement variables vx, vy, vz = 0.0, 0.0, 0.0 rx, ry, rz = 0.0, 0.0, 0.0 if keyboard.events[blenderapi.UPARROWKEY] == is_actived: vx = self._speed if keyboard.events[blenderapi.DOWNARROWKEY] == is_actived: vx = -self._speed if keyboard.events[blenderapi.LEFTARROWKEY] == is_actived: rz = self._speed if keyboard.events[blenderapi.RIGHTARROWKEY] == is_actived: rz = -self._speed if self._type == 'Position' or self._type == 'Velocity': self.robot_parent.apply_speed(self._type, [vx, vy, vz], [rx, ry, rz / 2.0]) elif self._type == 'Differential': self.robot_parent.apply_vw_wheels(vx, rz)
def default_action(self): keyboard = blenderapi.keyboard() is_actived = blenderapi.input_active() if keyboard.events[blenderapi.UPARROWKEY] == is_actived: self.local_data['up'] = True else: self.local_data['up'] = False if keyboard.events[blenderapi.DOWNARROWKEY] == is_actived: self.local_data['down'] = True else: self.local_data['down'] = False if keyboard.events[blenderapi.LEFTARROWKEY] == is_actived: self.local_data['left'] = True else: self.local_data['left'] = False if keyboard.events[blenderapi.RIGHTARROWKEY] == is_actived: self.local_data['right'] = True else: self.local_data['right'] = False if keyboard.events[blenderapi.IKEY] == is_actived: self.local_data['i'] = True else: self.local_data['i'] = False if keyboard.events[blenderapi.JKEY] == is_actived: self.local_data['j'] = True else: self.local_data['j'] = False if keyboard.events[blenderapi.KKEY] == is_actived: self.local_data['k'] = True else: self.local_data['k'] = False if keyboard.events[blenderapi.LKEY] == is_actived: self.local_data['l'] = True else: self.local_data['l'] = False
def default_action(self): """ Interpret keyboard presses and assign them to movement for the robot.""" keyboard = blenderapi.keyboard() is_actived = blenderapi.input_active() # Reset movement variables vx, vy, vz = 0.0, 0.0, 0.0 rx, ry, rz = 0.0, 0.0, 0.0 # move forward if keyboard.events[blenderapi.UPARROWKEY] == is_actived: vx = self._speed # move backward if keyboard.events[blenderapi.DOWNARROWKEY] == is_actived: vx = -self._speed # turn left if keyboard.events[blenderapi.LEFTARROWKEY] == is_actived: rz = self._speed # turn right if keyboard.events[blenderapi.RIGHTARROWKEY] == is_actived: rz = -self._speed # move up if keyboard.events[blenderapi.TKEY] == is_actived: vz = self._speed # move down if keyboard.events[blenderapi.GKEY] == is_actived: vz = -self._speed # strafe left if keyboard.events[blenderapi.UKEY] == is_actived: vy = self._speed # strafe right if keyboard.events[blenderapi.OKEY] == is_actived: vy = -self._speed # roll left if keyboard.events[blenderapi.JKEY] == is_actived: rx = -self._speed # roll right if keyboard.events[blenderapi.LKEY] == is_actived: rx = self._speed # pitch forward if keyboard.events[blenderapi.IKEY] == is_actived: ry = self._speed # pitch backward if keyboard.events[blenderapi.KKEY] == is_actived: ry = -self._speed # Send a 'zero motion' only once in a row. if self.zero_motion and (vx,vy,vz,rx,ry,rz) == (0,0,0,0,0,0): return if self._type == 'Position' or self._type == 'Velocity': self.robot_parent.apply_speed(self._type, [vx, vy, vz], [rx, ry, rz / 2.0]) elif self._type == 'Differential': self.robot_parent.apply_vw_wheels(vx, rz) if (vx,vy,vz,rx,ry,rz) == (0,0,0,0,0,0): self.zero_motion = True else: self.zero_motion = False
def default_action(self): """ Main loop of the actuator. Implements the component behaviour """ keyboardController = blenderapi.keyboard() active_state = blenderapi.input_active() linear_change = 0.0 angular_change = 0.0 local_x = self.local_data['XDot'] local_y = self.local_data['YDot'] #if self.Mode == "Acceleration": # logger.info("Acc Mode") if keyboardController.events[blenderapi.UPARROWKEY] == active_state: linear_change += self.Acceleration if keyboardController.events[blenderapi.DOWNARROWKEY] == active_state: linear_change -= self.Acceleration if keyboardController.events[blenderapi.LEFTARROWKEY] == active_state: angular_change += self.AngularAcc if keyboardController.events[blenderapi.RIGHTARROWKEY] == active_state: angular_change -= self.AngularAcc local_x += linear_change local_y += angular_change if local_x < 0: local_x = max(local_x,-self.MaxSpeed) else: local_x = min(local_x,self.MaxSpeed) if local_y < 0: local_y = max(local_y,-self.MaxAngularSpeed) else: local_y = min(local_y,self.MaxAngularSpeed) if linear_change == 0: local_x *= self.decay if abs(local_x) < 0.005: local_x = 0.0 if angular_change == 0: local_y *= self.decay if abs(local_y) < 0.005: local_y = 0.0 # logger.info("YDot: %s" % self.local_data['YDot']) self.local_data['XDot'] = local_x self.local_data['YDot'] = local_y self.local_data["LastData"] -= 1 self.robot_parent.apply_speed('Position',[local_x ,0 ,0],[0,0,local_y / 2.0])