def handle_blendermode(self, msg): # Disable if mode not allowed msg = msg.data if not msg in self.modes: rospy.loginfo("Unsupported mode %s" % msg) msg = 'Dummy' modes.enable(msg)
def handle_blendermode(self, msg): #disable if mode not allowed msg = msg.data if not msg in self.modes: msg = 'Dummy' if msg == "disable": modes.disable() else: modes.enable(msg)
def execute(self): # Try to shut down if the script is already running. blparams = PersistentParams() if blparams.get("running"): blparams.set("running", False) return blparams.set("running", True) rospy.init_node('robo_blender', anonymous=True) inputs_config = [] # current animations blender file do not require inputs if not 'Animations' in self.modes: inputs_config = Utils.read_yaml(os.path.join(self.config_dir, "inputs.yaml")) inputs.initialize(inputs_config) outputs.initialize( Utils.read_yaml(os.path.join(self.config_dir, "outputs.yaml")) ) rospy.Subscriber('cmd_blendermode', String, self.handle_blendermode) @persistent def handle_scene_update(dummy): # Check whether to shut down if not blparams.get("running"): bpy.app.handlers.scene_update_pre.remove(handle_scene_update) rospy.loginfo("ROBO: Ended") return # Limit execution to intervals of self.frame_interval t = time.time() if t - self.lastframe < self.frame_interval or self.step_in_process: return self.lastframe = self.lastframe + self.frame_interval # Limited execution starts here. self.step_in_process = True self.step(self.frame_interval) self.step_in_process = False # The boolean wrapper above prevents infinite recursion in case step() # invokes blender to call handle_scene_update again self.lastframe = time.time() bpy.app.handlers.scene_update_pre.append(handle_scene_update) rospy.loginfo("Available modes: " + str(self.modes).strip('[]')) # Enable default mode modes.enable("Dummy") rospy.loginfo("ROBO: Started")
def execute(self): # Try to shut down if the script is already running. blparams = PersistentParams() if blparams.get("running"): blparams.set("running", False) return blparams.set("running", True) rospy.init_node('robo_blender', anonymous=True) inputs_config = [] # current animations blender file do not require inputs if not 'Animations' in self.modes: inputs_config = Utils.read_yaml( os.path.join(self.config_dir, "inputs.yaml")) inputs.initialize(inputs_config) outputs.initialize( Utils.read_yaml(os.path.join(self.config_dir, "outputs.yaml"))) rospy.Subscriber('cmd_blendermode', String, self.handle_blendermode) @persistent def handle_scene_update(dummy): # Check whether to shut down if not blparams.get("running"): bpy.app.handlers.scene_update_pre.remove(handle_scene_update) rospy.loginfo("ROBO: Ended") return # Limit execution to intervals of self.frame_interval t = time.time() if t - self.lastframe < self.frame_interval or self.step_in_process: return self.lastframe = self.lastframe + self.frame_interval # Limited execution starts here. self.step_in_process = True self.step(self.frame_interval) self.step_in_process = False # The boolean wrapper above prevents infinite recursion in case step() # invokes blender to call handle_scene_update again self.lastframe = time.time() bpy.app.handlers.scene_update_pre.append(handle_scene_update) rospy.loginfo("Available modes: " + str(self.modes).strip('[]')) # Enable default mode modes.enable("Dummy") rospy.loginfo("ROBO: Started")