def get_pos(self): """ Reads the current position from the MRDS and returns it as a Vector instance. """ self.__mrds.request('GET', '/lokarria/localization') response = self.__mrds.getresponse() if response.status == 200: pos_data = json.loads(response.read()) response.close() return Vector.from_dict(pos_data['Pose']['Position']) else: raise self.UnexpectedResponse(response)
def positionPath(self, dict=False): """ Parses the positions in the loaded file into a list of either Vector instances or dictionaries depending on the value of the dict parameter. :param dict: if set to True, will parse into dictionaries instead of into Vector instances :type dict: bool """ if dict: return [{ 'X': p['Pose']['Position']['X'], 'Y': p['Pose']['Position']['Y'], 'Z': p['Pose']['Position']['Z'] } for p in self.path] else: return [Vector.from_dict(p['Pose']['Position']) for p in self.path]
def get_pos_and_orientation(self): """ Reads the current position and orientation from the MRDS server and returns it as a tuple (Vector, Quaternion). """ self.__mrds.request('GET', '/lokarria/localization') response = self.__mrds.getresponse() if response.status == 200: pos_data = json.loads(response.read()) response.close() return Vector.from_dict( pos_data['Pose']['Position']), Quaternion.from_dict( pos_data['Pose']['Orientation']) else: raise self.UnexpectedResponse(response)