Go to the documentation of this file.00001
00002
00003
00004 import roslib; roslib.load_manifest('clearpath_base')
00005 import rospy
00006
00007 from base import Clearpath
00008
00009
00010 class Torque(Clearpath):
00011 def __init__(self):
00012 rospy.loginfo("Clearpath Base")
00013 rospy.loginfo("Using closed-loop current control")
00014
00015
00016 Clearpath.__init__(self)
00017
00018 if self.horizon:
00019 self.max_current = rospy.get_param('~max_current', 26)
00020 self.linear_scale = rospy.get_param('~linear_scale', 1.2)
00021 self.angular_scale = rospy.get_param('~angular_scale', 2)
00022 rospy.loginfo("Using %f m/s as %f A output (linear scale)",
00023 self.linear_scale, self.max_current)
00024 rospy.loginfo("Using %f rad/s as +/- %f A (angular scale)",
00025 self.angular_scale, self.max_current)
00026
00027 def cmd_vel(self, linear_velocity, angular_velocity):
00028 linear = linear_velocity * (self.max_current / self.linear_scale)
00029 diff = angular_velocity * (self.max_current / self.angular_scale)
00030 left_current = max(min(linear - diff, self.max_current), -self.max_current)
00031 right_current = max(min(linear + diff, self.max_current), -self.max_current)
00032 self.horizon.set_differential_current(left_current, right_current)
00033
00034
00035 Torque().run()