X-Git-Url: https://defiant.homedns.org/gitweb/?p=ros_wild_thumper.git;a=blobdiff_plain;f=scripts%2Fmove_base.py;h=5ece2683f6d0ad31cee0dd0cebfd9efdb95b26e2;hp=fbd265fb9c6001c75879da1d0cb406ab7d110f9a;hb=6bbe85b249210dd265f51cfde4288530d9bb05fb;hpb=ece97d94709b5e779ec2a48cf47319163a122bc5;ds=sidebyside diff --git a/scripts/move_base.py b/scripts/move_base.py index fbd265f..5ece268 100755 --- a/scripts/move_base.py +++ b/scripts/move_base.py @@ -19,14 +19,20 @@ class MoveBase: self.run() def run(self): - rate = rospy.Rate(10.0) + rate = rospy.Rate(20.0) while not rospy.is_shutdown(): + self.get_pos() #self.get_dist_forward() #self.get_dist_backward() #self.get_dist_left() #self.get_dist_right() rate.sleep() + def get_pos(self): + s = i2c_read_reg(0x50, 0x10, 8) + hall1, hall2, hall3, hall4 = struct.unpack(">hhhh", s) + print hall1, hall2, hall3, hall4 + def set_speed(self, left, right): if left > 0: left+=80 elif left < 0: left-=80 @@ -38,10 +44,7 @@ class MoveBase: if right > 255: right=255 elif right < -255: right=-255 - dev = i2c(0x50) - s = struct.pack(">Bhhhh", 0x1, right, right, left, left) - dev.write(s) - dev.close() + i2c_write_reg(0x50, 0x1, struct.pack(">hhhh", right, right, left, left)) def cmdVelReceived(self, msg): trans = msg.linear.x