class AgentGoStraight(Agent): def __init__(self): Agent.__init__(self) self.yaw = Yaw() self.motors = StepMotorRawControl() def setup(self): print >> sys.stderr, "setup" self.yaw.off() def ready(self): print >> sys.stderr, "ready" self.yaw.on() def loop(self): direction = self.yaw.get_value() print direction #example of how to get the angular velocity #vel = self.yaw.get_velocity() #print direction, vel p_gain = 10.0 diff = 20*direction / 9 * p_gain self.motors.set_values(diff, - diff) time.sleep(0.02)
class AgentGoStraight(Agent): def __init__(self): Agent.__init__(self) self.yaw = Yaw() self.motors = StepMotorRawControl() self.hz = 0 def setup(self): print >> sys.stderr, "setup" self.yaw.off() def ready(self): print >> sys.stderr, "ready" self.yaw.on() self.hz = 0 def loop(self): direction = self.yaw.get_value() #print direction if abs(direction) > 5.0: self.hz = 0 self.hz += 10 if self.hz > 3500: self.hz = 3500 p_gain = 10.0 diff = 20 * direction / 9 * p_gain if diff > 400.0: diff = 400.0 elif diff < -400.0: diff = -400.0 self.motors.set_values(self.hz + diff, self.hz - diff) time.sleep(0.02)
class AgentGoStraight(Agent): def __init__(self): Agent.__init__(self) self.yaw = Yaw() self.motors = StepMotorRawControl() def setup(self): print >> sys.stderr, "setup" self.yaw.off() def ready(self): print >> sys.stderr, "ready" self.yaw.on() def loop(self): direction = self.yaw.get_value() print direction #example of how to get the angular velocity #vel = self.yaw.get_velocity() #print direction, vel p_gain = 10.0 diff = 20 * direction / 9 * p_gain self.motors.set_values(diff, -diff) time.sleep(0.02)
class AgentGoStraight(Agent): def __init__(self): Agent.__init__(self) self.yaw = Yaw() self.motors = StepMotorRawControl() self.hz = 0 def setup(self): print >> sys.stderr, "setup" self.yaw.off() def ready(self): print >> sys.stderr, "ready" self.yaw.on() self.hz = 0 def loop(self): direction = self.yaw.get_value() #print direction if abs(direction) > 5.0: self.hz = 0 self.hz += 10 if self.hz > 3500: self.hz = 3500 p_gain = 10.0 diff = 20*direction / 9 * p_gain if diff > 400.0: diff = 400.0 elif diff < -400.0: diff = -400.0 self.motors.set_values(self.hz + diff, self.hz - diff) time.sleep(0.02)
class AgentGoStraight(Agent): def __init__(self): Agent.__init__(self) self.yaw = Yaw() self.motors = StepMotorRawControl() self.hz = 0 def setup(self): print >> sys.stderr, "setup" self.yaw.off() def ready(self): print >> sys.stderr, "ready" self.yaw.on() def loop(self): direction = self.yaw.get_value() print direction diff = 20 * direction / 9 self.motors.set_values(diff, -diff) time.sleep(1.0)
class AgentGoStraight(Agent): def __init__(self): Agent.__init__(self) self.yaw = Yaw() self.motors = StepMotorRawControl() self.hz = 0 def setup(self): print >> sys.stderr, "setup" self.yaw.off() def ready(self): print >> sys.stderr, "ready" self.yaw.on() self.hz = 0 def loop(self): self.hz += 10 if self.hz > 3500: self.hz = 3500 self.motors.set_values(self.hz, self.hz) time.sleep(0.02)