@@ -0,0 +1,763 @@
+#!/usr/bin/env python%0Aimport rospy%0Afrom sensor_msgs.msg import MagneticField%0Aclass mag(object):%0A    def __init__(self):%0A        rospy.init_node('sweep_nav')%0A        sub = rospy.Subscriber('/imu/mag', MagneticField, self.mag_data, queue_size = 10)%0A        rospy.loginfo(%22Waiting for the mag to come up%22)%0A        rospy.sleep(2)%0A        now = rospy.get_time()%0A        after = 0%0A        mag = %5B%5D%0A        while not after - now %3E=10 and not rospy.is_shutdown():%0A            after = rospy.get_time()%0A            mag.append(self.mag)%0A            #print self.mag%0A        print %22bias%22%0A        print max(mag)-(max(mag)-min(mag))/2%0A%0A    def mag_data(self, msg):%0A        self.mag = msg.magnetic_field.z# + 4.635 * 0.00001%0A%0Aif __name__ == '__main__':%0A    hoge = mag()%0A        %0A

add mag_bias