enabled range sensor layer
[ros_wild_thumper.git] / scripts / umbmark.py
index f031a67..398f2be 100755 (executable)
@@ -40,6 +40,8 @@ from math import *
 from nav_msgs.msg import Odometry
 from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal
 from actionlib_msgs.msg import GoalStatus
+from optparse import OptionParser
+
 
 class UMBMark:
        def __init__(self):
@@ -78,25 +80,29 @@ class UMBMark:
                        rospy.logerr("The base failed to (%.2f, %2f), %d°" % (x, y, angle*180/pi))
                        raise
 
-       def run(self, direction=-1):
+       def run(self, direction=-1, size=2):
                while self.odom_pose is None:
                        sleep(0.1)
                init_pose = self.odom_pose
                for i in range(4):
-                       self.next_pos(2, 0, 0)
+                       self.next_pos(size, 0, 0)
                        self.next_pos(0, 0, direction*90*pi/180)
                final_pose = map(operator.sub, self.odom_pose, init_pose)
                print "Odom Pose: x=%.3f, y=%.3f, angle=%.3f°" % (final_pose[0], final_pose[1], final_pose[2]*180/pi)
 
-       def run_cw(self):
-               self.run(-1)
+       def run_cw(self, size):
+               self.run(-1, size)
 
-       def run_ccw(self):
-               self.run(1)
+       def run_ccw(self, size):
+               self.run(1, size)
 
 if __name__ == "__main__":
+       parser = OptionParser()
+       parser.add_option("-l", "--length", dest="length", default=2, help="Square size")
+       (options, args) = parser.parse_args()
+
        p = UMBMark()
        if len(sys.argv) > 1 and sys.argv[1] == "ccw":
-               p.run_ccw()
+               p.run_ccw(float(options.length))
        else:
-               p.run_cw()
+               p.run_cw(float(options.length))