def __init__(self, scene_object, name, data, color=(0, 0, 1)): LegacySkeletonAnimationController.__init__(self, scene_object) self.motion_primitive = MotionStateGraphNode(None) self.skeleton = SkeletonBuilder().load_from_json_data(data["skeleton"]) self.frameTime = self.skeleton.frame_time self._visualizations = [] self.samples = [] self.algorithm_config = DEFAULT_ALGORITHM_CONFIG self.color = color self.motion_primitive._initialize_from_json(convert_to_mgrd_skeleton(self.skeleton), data) print("loaded motion primitive") print("spatial", self.motion_primitive.get_n_spatial_components()) print("time", self.motion_primitive.get_n_time_components()) self.motion_primitive.cluster_tree = None self.training_data = None #print("n gmm", len(self.motion_primitive.get_gaussian_mixture_model().weights)) self.name = name self._regenerate = True self.type = CONTROLLER_TYPE_MP set_log_mode(LOG_MODE_DEBUG) self.start_pose = {"position": [0, 0, 0], "orientation": [0, 0, 0]} self.mock_graph = MockGraph(self.skeleton) self.label_color_map = dict()
def __init__(self, scene_object, name, graph, start_node=None, config=DEFAULT_ALGORITHM_CONFIG, color=(0, 0, 1)): SkeletonAnimationController.__init__(self, scene_object) self.name = name # file_path.split("/")[-1] self._graph = graph #loader.build() self.algorithm_config = config self._service_config = SERVICE_CONFIG self._graph_walk = None self._motion = None self._regenerate = True self.frameTime = self._graph.skeleton.frame_time print(self._graph.skeleton.animated_joints) print("set frame time to", self.frameTime) #self._visualization = SkeletonVisualization(scene_object, color) #self._visualization.set_skeleton(self._graph.skeleton) self.type = CONTROLLER_TYPE_MG set_log_mode(LOG_MODE_DEBUG) if start_node is None: print("generate random start") start_node = self._graph.get_random_start_node() self.start_node = start_node print("start node", self.start_node) self.start_pose = {"position": [0, 0, 0], "orientation": [0, 0, 0]}
def __init__(self, scene_object, file_path, color=(0, 0, 1)): LegacySkeletonAnimationController.__init__(self, scene_object) loader = MotionStateGraphLoader() loader.set_data_source(file_path[:-4]) loader.use_all_joints = False # = set animated joints to all self.name = file_path.split("/")[-1] self._graph = loader.build() self.algorithm_config = DEFAULT_ALGORITHM_CONFIG self._service_config = SERVICE_CONFIG self._graph_walk = None self._motion = None self._regenerate = True self.frameTime = self._graph.skeleton.frame_time print(self._graph.skeleton.animated_joints) print("set frame time to", self.frameTime) self._visualization = SkeletonVisualization(scene_object, color) self._visualization.set_skeleton(self._graph.skeleton) self.type = CONTROLLER_TYPE_MG set_log_mode(LOG_MODE_DEBUG) self.start_node = self._graph.get_random_start_node() print("start node", self.start_node) self.start_pose = {"position": [0, 0, 0], "orientation": [0, 0, 0]}
def __init__(self, scene_object, graph, start_node=None, use_all_joints=False, config=DEFAULT_CONFIG, pfnn_data=None): StateMachineController.__init__(self, scene_object) self._graph = graph if start_node is None or start_node not in self._graph.nodes: start_node = self._graph.start_node self.start_node = start_node self.frame_time = self._graph.skeleton.frame_time self.skeleton = self._graph.skeleton self.thread = None self._visualization = None set_log_mode(LOG_MODE_DEBUG) self.current_node = self.start_node self.use_all_joints = use_all_joints self.node_type = NODE_TYPE_IDLE self.state = None self.set_initial_idle_state(use_all_joints) print("start node", self.current_node) self.start_pose = {"position": [0, 0, 0], "orientation": [0, 0, 0]} self.speed = 1 if "speed" in config: self.speed = config["speed"] print("set speed", self.speed) self.pose_buffer = [] self.buffer_size = 10 self.max_step_length = 80 self.direction_vector = np.array([-1.0, 0.0, 0.0]) self.action_constraint = None self.target_projection_len = 0 self.n_joints = len(self.skeleton.animated_joints) self.n_max_state_queries = 20 self.retarget_engine = None self.target_skeleton = None self.activate_emit = False self.show_skeleton = True self.node_queue = [] self.activate_grounding = False self.collision_boundary = None self.hand_collision_boundary = None self.aligning_transform = np.eye(4) self.draw_root_trajectory = False self.planner = MGStatePlanner(self, self._graph, config) self.motion_grounding = MotionGrounding(self.skeleton, config["algorithm"]["inverse_kinematics_settings"], self.skeleton.skeleton_model) self.actions = self.planner.action_definitions self.planner.settings.use_all_joints = use_all_joints self.state.play = True self.thread = None self.animation_server = None self.success = True self.is_recording = False self.stop_current_state = False self.lock = threading.Lock() self.recorded_poses = list() #if pfnn_data is not None: # self.planner.pfnn_wrapper = PFNNWrapper.load_from_dict(self.skeleton, pfnn_data["weights"], pfnn_data["means"]) # self.planner.use_pfnn = True self.load_clips = dict() if "clip_directory" in config and "clip_directory" in config: data_path = config["data_directory"] + os.sep + config["clip_directory"] if os.path.isdir(data_path): self.loaded_clips = load_clips(data_path) else: print("Could not find clip directory", data_path)
else: write_message_to_log( "Warning: Did not find JSONPath " + json_path_str + " in data", LOG_MODE_ERROR) if __name__ == "__main__": test_data = { "model_data": "motion_primitives_quaternion_PCA95_unity-integration-1.0.0", "port": 8888, "write_log": True, "log_level": 1, "list_test": [{ "ab": 1 }, { "ab": 3 }] } import argparse set_log_mode(LOG_MODE_DEBUG) parser = argparse.ArgumentParser(description="Test") parser.add_argument("-set", nargs='+', default=[], help="JSONPath expression") args = parser.parse_args() update_data_using_jsonpath(test_data, args.set)