def __init__(self, date=None): from morse.sensors._magnetometer import Magnetometer as Mag self._mag = Mag(os.path.join(MORSE_COMPONENTS, 'WMM.COF')) self._coord_conv = CoordinateConverter.instance() if date: self._date = date else: self._date = _decimal_date(datetime.date.today())
def __init__(self, date = None): from morse.sensors._magnetometer import Magnetometer as Mag self._mag = Mag(os.path.join(MORSE_COMPONENTS, 'WMM.COF')) self._coord_conv = CoordinateConverter.instance() if date: self._date = date else: self._date = _decimal_date(datetime.date.today())
class MagnetoDriver(object): def __init__(self, date=None): from morse.sensors._magnetometer import Magnetometer as Mag self._mag = Mag(os.path.join(MORSE_COMPONENTS, 'WMM.COF')) self._coord_conv = CoordinateConverter.instance() if date: self._date = date else: self._date = _decimal_date(datetime.date.today()) def compute(self, pose): pos = numpy.matrix(pose.translation) pos_lla = self._coord_conv.ltp_to_geodetic(pos) (decl, incl, f, h, x, y, z) = self._mag.compute(degrees(pos_lla[0, 0]), degrees(pos_lla[0, 1]), pos_lla[0, 2] / 1000.0, self._date) mag_field = mathutils.Vector((x, y, z)) return mag_field * pose.rotation_matrix
class MagnetoDriver(object): def __init__(self, date=None): from morse.sensors._magnetometer import Magnetometer as Mag self._mag = Mag(os.path.join(MORSE_COMPONENTS, "WMM.COF")) self._coord_conv = CoordinateConverter.instance() if date: self._date = date else: self._date = _decimal_date(datetime.date.today()) def compute(self, pose): pos = pose.translation pos_lla = self._coord_conv.ltp_to_geodetic(pos) (decl, incl, f, h, x, y, z) = self._mag.compute( degrees(pos_lla[0]), degrees(pos_lla[1]), pos_lla[2] / 1000.0, self._date ) mag_field = mathutils.Vector((x, y, z)) return mag_field * pose.rotation_matrix