def get_T_emgs(self): """ Seperates then EMGs data :return: EMGs data :rtype: Bio.side """ joints = {} count = 0 emgs = self.vicon.get_all_t_emg() for key, emg in emgs.items(): joints[key] = [] for inc in self.vicon_set_points: start = emg.get_offset_index(inc[0]) end = emg.get_offset_index(inc[1]) data = np.array(emg.get_values())[start:end] time = (len(data) / float(self.vicon.length)) * self.dt stamp = Data.Data(data, np.linspace(0, time, len(data))) if self._use_black_list: if count in self._black_list: continue joints[key].append(stamp) count += 1 return joints
def get_pots(self): """ Seperates Pot data :return: Pot data :rtype: Dict """ left_leg = self.exoskeleton.left_leg right_leg = self.exoskeleton.right_leg left = [] right = [] count = 0 for inc in self.exo_set_points: left_data = np.array( [[left_leg.hip.pot.get_values()[inc[0]:inc[1]]], [left_leg.knee.pot.get_values()[inc[0]:inc[1]]], [left_leg.ankle.pot.get_values()[inc[0]:inc[1]]]]) right_data = np.array( [[right_leg.hip.pot.get_values()[inc[0]:inc[1]]], [right_leg.knee.pot.get_values()[inc[0]:inc[1]]], [right_leg.ankle.pot.get_values()[inc[0]:inc[1]]]]) time = (len(left_data) / float(self.exoskeleton.length)) * self.dt stamp_left = Data.Data() stamp_right = Data.Data() stamp_right.data = right_data stamp_left.data = left_data stamp_left.time = np.linspace(0, time, len(left_data)) stamp_right.time = np.linspace(0, time, len(right_data)) if self._use_black_list: if count in self._black_list: continue else: left.append(stamp_left) right.append(stamp_right) count += 1 side = Side.Side(left, right) return side
def get_FSRs(self): """ Seperates FSR data :return: FSR data :rtype: Dict """ left_fsr = self.exoskeleton.left_leg.ankle.FSRs right_fsr = self.exoskeleton.right_leg.ankle.FSRs left = [] right = [] for inc in self.exo_set_points: left_data = np.array([[left_fsr[0].get_values()[inc[0]:inc[1]]], [left_fsr[1].get_values()[inc[0]:inc[1]]], [left_fsr[2].get_values()[inc[0]:inc[1]]]]) right_data = np.array([[right_fsr[0].get_values()[inc[0]:inc[1]]], [right_fsr[1].get_values()[inc[0]:inc[1]]], [right_fsr[2].get_values()[inc[0]:inc[1]]]]) time = (len(left_data) / float(self.exoskeleton.length)) * self.dt stamp_left = Data.Data(left_data, np.linspace(0, time, len(left_data))) stamp_right = Data.Data(right_data, np.linspace(0, time, len(right_data))) # if self._use_black_list: # if count in self._black_list: # continue # else: # left.append(stamp_left) # right.append(stamp_right) # # count += 1 side = Side.Side(left, right) return side
def get_CoPs(self): """ Seperates then CoP data :return: CoP data :rtype: Dict """ left = [] right = [] count = 0 left_cop = self.exoskeleton.left_leg.calc_CoP() right_cop = self.exoskeleton.right_leg.calc_CoP() left = [] right = [] for inc in self.exo_set_points: left_data = left_cop[inc[0]:inc[1]] right_data = right_cop[inc[0]:inc[1]] time = (len(left_data) / float(self.exoskeleton.length)) * self.dt stamp_left = Data.Data(left_data, np.linspace(0, time, len(left_data))) stamp_right = Data.Data(right_data, np.linspace(0, time, len(right_data))) if self._use_black_list: if count in self._black_list: continue else: left.append(stamp_left) right.append(stamp_right) count += 1 side = Side.Side(left, right) return side
def get_force_plates(self): """ Seperates then force plate data :return: Force plate data :rtype: Dict """ joints = {} plate1 = self.vicon.get_force_plate(1) plate2 = self.vicon.get_force_plate(2) plate1_forces = plate1.get_forces() plate2_forces = plate2.get_forces() plate1_moments = plate1.get_moments() plate2_moments = plate2.get_moments() p1 = (1, plate1_forces, plate1_moments) p2 = (2, plate2_forces, plate2_moments) joints[1] = [] joints[2] = [] for p in (p1, p2): key = p[0] if self._use_black_list: if key in self._black_list: continue plateF = p[1] plateM = p[2] for inc in self.vicon_set_points: start = plate1.get_offset_index(inc[0]) end = plate1.get_offset_index(inc[1]) Fx = np.array(plateF.x)[start:end] Fy = np.array(plateF.y)[start:end] Fz = np.array(plateF.z)[start:end] Mx = np.array(plateM.x)[start:end] My = np.array(plateM.y)[start:end] Mz = np.array(plateM.z)[start:end] f = Point.Point(Fx, Fy, Fz) m = Point.Point(Mx, My, Mz) data = Newton.Newton(None, f, m, None) time = (len(Fx) / float(self.vicon.length)) * self.dt stamp = Data.Data(data, np.linspace(0, time, len(data))) joints[key].append(stamp) return joints
def get_joint_trajectories(self): """ Seperates then joint trajs data :return: joint trajectory data :rtype: Dict """ joints = {} count = 0 model = self.vicon.get_model_output() for fnc, side in zip((model.get_left_leg(), model.get_right_leg()), ("L", "R")): for joint_name in ["_hip", "_knee", "_ankle"]: name = side + joint_name[1:] joints[name] = [] for inc in self.vicon_set_points: time = np.linspace(0, 1, (inc[1] - inc[0])) current_joint = fnc.__dict__[joint_name] angleX = Data.Data( np.array(current_joint.angle.x[inc[0]:inc[1]]), time) angleY = Data.Data( np.array(current_joint.angle.y[inc[0]:inc[1]]), time) angleZ = Data.Data( np.array(current_joint.angle.z[inc[0]:inc[1]]), time) angle = Point.Point(x=angleX, y=angleY, z=angleZ) powerX = Data.Data( np.array(current_joint.power.x[inc[0]:inc[1]]), time) powerY = Data.Data( np.array(current_joint.power.y[inc[0]:inc[1]]), time) powerZ = Data.Data( np.array(current_joint.power.z[inc[0]:inc[1]]), time) power = Point.Point(x=powerX, y=powerY, z=powerZ) torqueX = Data.Data( np.array(current_joint.moment.x[inc[0]:inc[1]]), time) torqueY = Data.Data( np.array(current_joint.moment.y[inc[0]:inc[1]]), time) torqueZ = Data.Data( np.array(current_joint.moment.z[inc[0]:inc[1]]), time) torque = Point.Point(x=torqueX, y=torqueY, z=torqueZ) forceX = Data.Data( np.array(current_joint.force.x[inc[0]:inc[1]]), time) forceY = Data.Data( np.array(current_joint.force.y[inc[0]:inc[1]]), time) forceZ = Data.Data( np.array(current_joint.force.z[inc[0]:inc[1]]), time) force = Point.Point(forceX, forceY, forceZ) stamp = Joint.Joint(angle, force, torque, power) if self._use_black_list: if count in self._black_list: continue joints[name].append(stamp) count += 1 left_leg = Leg.Leg(joints["Rhip"], joints["Rknee"], joints["Rankle"]) right_leg = Leg.Leg(joints["Lhip"], joints["Lknee"], joints["Lankle"]) body = Side.Side(left_leg, right_leg) return body