Example #1
0
 def __init__(self, **args):
     Omni.__init__(self, **args)
     # declare  zone and variables associated with the servo motor :
     self.zone2 = "zoneservo1"
     self.zone3 = "zoneservo2"
     # declare the Id of the motor, and angle of turn
     self.motor = 1
     self.minangle = 0
     self.maxangle = math.pi
     self.servospeed = 30
     # servoVS = 1 indicates that the servo spin vertically : do  not authorized negative servo motor angle
     # servoVS = -1 indicates that the servo spin vertically : do  not authorized positive servo motor angle
     # servoVS = 0 : no restriction to servo angle motor. Default value.
     self.servoVS = 0
     #read theses values from bindings.py :
     if 'minangle' in args: self.minangle = args['minangle']
     if 'maxangle' in args: self.maxangle = args['maxangle']
     if self.minangle > self.maxangle:
         xxx = self.minangle
         self.minangle = self.maxangle
         self.maxangle = xxx
     if 'servoVS' in args: self.servoVS = args['servoVS']
     if 'servospeed' in args: self.servospeed = args['servospeed']
     self.delta = 0.3
     if 'delta' in args: self.delta = args['delta']
Example #2
0
    def __init__(self, **args):
        Omni.__init__(self, **args)

        self.tickFactor = 3.75
        self.motorID = 2
        self.motorID2 = -1
        self.RPM = 0
        self.RPM2 = 0
        self.revolution = 0
        self.revolution2 = 0
        self.measuring = 0
        self.measuring2 = 0
        self.max_RPM = 0
        self.RPMhist = []
        self.avg_RPM = 0
        self.display = 0
        self.targetRPM = 100
        self.spin_reverse = 0
        self.jamTimer = 0
        self.raspberry = 1.5

        if 'ticks' in args: self.tickFactor = args['ticks']
        if 'MotorID' in args: self.motorID = args['MotorID']
        if 'Motor2ID' in args: self.motorID2 = args['Motor2ID']
        if 'DisplayRPM' in args: self.display = args['DisplayRPM']
        if 'TargetRPM' in args: self.targetRPM = args['TargetRPM']
        if 'JamTime' in args: self.raspberry = args['JamTime']

        self.triggerIterator = iter(self.triggers)

        self.tactics.append(Tactics.Engage(self))
Example #3
0
    def __init__(self, **args):
        Omni.__init__(self, **args)

        self.reloadTime = 0
        self.reloadDelay = 4
        self.mayFire = True
        self.range = 6
        self.delta = 0.5 #tolerance between full Aim
Example #4
0
    def __init__(self, **args):
        Omni.__init__(self, **args)

        tactic = [x for x in self.tactics if x.name == "Engage"]
        if len(tactic) > 0:
            self.tactics.remove(tactic[0])
        self.tactics.append(Tactics.Charge(self))
        self.tactics.append(Tactics.Shove(self))
Example #5
0
    def __init__(self, **args):
        Omni.__init__(self, **args)

        self.originose = self.fNoseOffset

        tactic = [x for x in self.tactics if x.name == "Engage"]
        if len(tactic) > 0:
            self.tactics.remove(tactic[0])

        self.tactics.append(Tactics.Ram(self))
Example #6
0
    def __init__(self, **args):
        Omni.__init__(self, **args)

        self.stopFunction = self.Stop
        self.waittime = 0.5

        if 'waittime' in args:
            self.waittime = args.get('waittime')

        tactic = [x for x in self.tactics if x.name == "Engage"]
        if len(tactic) > 0:
            self.tactics.remove(tactic[0])
        self.tactics.append(Tactics.Ram(self))
Example #7
0
    def Activate(self, active):
        bReturn = Omni.Activate(self, active)
        if not active:
            # get rid of reference to self
            self.stopFunction = None

        return bReturn
Example #8
0
 def Tick(self):
     #self.tauntbox.get("taunt1").setText("Nose: " + str(self.fNoseOffset))
     # this doesn't seem to do anything, but what the heck, it's not doing any harm either.
     #if plus.getTimeElapsed() > 3 and self.fNoseOffset == self.originose:
     if not self.weapons and self.fNoseOffset == self.originose:
         self.fNoseOffset += math.pi
     bReturn = Omni.Tick(self)
     return bReturn
Example #9
0
    def __init__(self, **args):
        Omni.__init__(self, **args)

        self.botinzone = 0
        self.compinzone = 0
        self.comptimer = 0
        self.NoChassisTime = 8
        self.RunUpsideDown = 0
        self.InverterTime = 4
        self.maybInvertible = 0

        if 'zone' in args: self.zone = args['zone']

        if 'triggers' in args: self.triggers = args['triggers']
        if 'NoChassisTime' in args:
            self.NoChassisTime = args['NoChassisTime'] * 4
        if 'RunUpsideDown' in args: self.RunUpsideDown = args['RunUpsideDown']
Example #10
0
    def Tick(self):
        # be self righteous even if we're invertible
        if self.IsUpsideDown():
            for trigger in self.trigger2:
                self.Input(trigger, 0, 1)

        bReturn = Omni.Tick(self)
        return bReturn
Example #11
0
    def Tick(self):
        # fire srimech here - allows us to be invertible and use srimech at the same time
        if self.IsUpsideDown():
            for trigger in self.trigger2:
                self.Input(trigger, 0, 1)

        bReturn = Omni.Tick(self)
        return bReturn
Example #12
0
    def Activate(self, active):
        bReturn = Omni.Activate(self, active)
        if active:
            self.RegisterSmartZone("weapon1", 2)
            self.RegisterSmartZone("weapon2", 3)
            self.RegisterSmartZone("weapon3", 4)
            self.RegisterSmartZone("weapon4", 5)

        return bReturn
Example #13
0
 def Tick(self):
     # fire weapon
     if self.weapons:
         # spin up if enemy is in smartzone.
         if self.botinspinzone == 1:
             self.Input("Spin", 0, 100)
         else:
             self.Input("Spin", 0, 0)
     bReturn = Omni.Tick(self)
     return bReturn
Example #14
0
    def Activate(self, active):
        bReturn = Omni.Activate(self, active)

        if active:
            self.RegisterSmartZone(self.zone2, 2)
            self.RegisterSmartZone(self.zone3, 3)
        else:
            # get rid of reference to self
            self.goodFunction = None

        return bReturn
Example #15
0
    def Tick(self):
        # fire srimech here - allows us to be invertible and use srimech at the same time
        if self.IsUpsideDown():
            for trigger in self.trigger2:
                self.Input(trigger, 0, 1)

        bReturn = Omni.Tick(self)

        # call this now so it takes place after other driving commands
        if self.stopFunction: self.stopFunction()

        return bReturn
Example #16
0
    def Tick(self):
        bReturn = Omni.Tick(self)
        # fire weapon
        if self.weapons:
            # flame on depending on enemy's range
            enemy, range = self.GetNearestEnemy()

            if enemy is not None and range < self.flame_range:
                self.Input("Flame", 0, 100)
            elif self.GetInputStatus("Flame", 0) != 0:
                self.Input("Flame", 0, 0)

        return bReturn
Example #17
0
    def Tick(self):
        bReturn = Omni.Tick(self)
        if self.weapons:
            if enemy is not None and range < self.spin_range:
                self.Input("Spin80", 0, 80)
            elif self.GetInputStatus("Spin", 0) != 0:
                self.Input("Spin80", 0, 0)
            if enemy is not None and range < self.spin_range:
                self.Input("Spin", 0, 100)
            elif self.GetInputStatus("Spin", 0) != 0:
                self.Input("Spin", 0, 0)

        return bReturn
Example #18
0
    def Tick(self):
        bReturn = Omni.Tick(self)
        if self.weapons:
            # If the bot is not inverted, try to invert it : use the button control called 'Inverter' :
            # here again, slight delay before inverting
            if self.InverterTime > 0: self.InverterTime -= 1

            #if (not self.ai.IsUpsideDown()) and (self.InverterTime <= 0) :
            #if (self.InverterTime <= 0) :
            if (not self.IsUpsideDown()) and (self.InverterTime <= 0):
                self.Input("Inverter", 0, 1)
                self.InverterTime = self.reloadDelay

        return bReturn
Example #19
0
    def __init__(self, **args):
        Omni.__init__(self, **args)

        self.zone2 = "spin"
        self.zone3 = "weapon2"
        self.goodFunction = self.GoodStuckHandler
        self.wiggletimer = -8
        self.srimechtimer = 0
        self.srispintimer = 0
        self.botinzone1 = 0
        self.botinzone2 = 0
        self.botinzone3 = 0
        self.usespinzone = 0
        if 'UseSpinZone' in args: self.usespinzone = args.get('UseSpinZone')

        self.pulsetime = 0
        if 'Pulse' in args: self.pulsetime = args.get('Pulse')
        self.pulse = self.pulsetime
        self.pulsetime2 = self.pulsetime / 2
        if 'Coast' in args: self.pulsetime2 = args.get('Coast')
        self.pulse_range = 0
        if 'PulseRange' in args: self.pulse_range = args.get('PulseRange')
        self.spinup = 2
        if 'StartSpinup' in args: self.spinup = args.get('StartSpinup')
Example #20
0
    def Tick(self):
        bReturn = Omni.Tick(self)
        # fire weapon
        if self.weapons:
            if len(targets) > 0 and self.reloadTime <= 0:
                try:
                    trigger = self.triggerIterator.next()
                except StopIteration:
                    self.triggerIterator = iter(self.triggers)
                    trigger = self.triggerIterator.next()

                self.Input(trigger, 0, 1)
                self.Throttle(0)
                self.reloadTime = self.reloadDelay

        return bReturn
Example #21
0
    def Tick(self):
        bReturn = Omni.Tick(self)
        # fire weapon
        if self.weapons:

            # spin up depending on enemy's range
            enemy, range = self.GetNearestEnemy()

            if enemy is not None and range < self.spin_range and self.weapons and not self.IsUpsideDown(
            ):
                self.Input("Spin", 0, 100)
            elif self.GetInputStatus("Spin", 0) != 0:
                self.Input("Spin", 0, 0)

            if self.IsUpsideDown():
                self.Input("Spin", 0, -100)

        return bReturn
Example #22
0
    def Tick(self):
        # fire weapon
        bReturn = Omni.Tick(self)
        if self.weapons:
            servoangle = self.GetMotorAngle(self.motor)
            self.DebugString(10,
                             "Current servo motor angle : " + str(servoangle))

        servoangle = self.GetMotorAngle(self.motor)
        self.DebugString(10, "servo motor angle :" + str(servoangle))
        if (self.servoVS == 1) and (servoangle < 0):
            if (servoangle > -math.pi / 2):
                self.Input("Servo", 0, -15)
            else:
                self.Input("Servo", 0, 15)
        elif (self.servoVS == -1) and (servoangle > 0):
            if (servoangle > math.pi / 2):
                self.Input("Servo", 0, -15)
        else:
            self.Input("Servo", 0, 0)

        return bReturn
Example #23
0
    def Tick(self):
        bReturn = Omni.Tick(self)
        # fire weapon
        if self.weapons:

            # spin up depending on enemy's range
            enemy, range = self.GetNearestEnemy()

            if enemy is not None and range < self.spin_range:
                if self.spincycleMax > 0:
                    self.spincycle -= 1
                    if self.spincycle > self.spincycleMax * 0.5:
                        self.Input("Spin", 0, 100)
                    if self.spincycleMax * 0.5 >= self.spincycle > 0:
                        self.Input("Spin", 0, -100)
                    if self.spincycle <= 0:
                        self.spincycle = self.spincycleMax
                else:
                    self.Input("Spin", 0, 100)
            else:
                self.Input("Spin", 0, 0)

        return bReturn
Example #24
0
    def Tick(self):
        # drive inverted
        if not self.sweapons:
            self.bInvertible = True

        #detect when bot is not moving
        if abs(self.GetSpeed()) < 0.5:
            self.notMoving = 1
        else:
            self.notMoving = 0

        #drive backwards when upside down
        if self.weapons and self.IsUpsideDown() and self.notMoving == 0:
            self.Input("DriveBack", 0, 100)

        if self.weapons and self.IsUpsideDown() and self.notMoving == 1:
            self.Input("DriveBack", 0, -100)

        if not self.IsUpsideDown():
            self.Input("DriveBack", 0, 0)

        bReturn = Omni.Tick(self)
        return bReturn
Example #25
0
 def __init__(self, **args):
     Omni.__init__(self, **args)
Example #26
0
    def Activate(self, active):
        # Activate flame control at the start of the match, leaving it alone in def Tick
        self.Input("Flame", 0, 100)
        bReturn = Omni.Activate(self, active)

        return bReturn
Example #27
0
    def Activate(self, active):
        bReturn = Omni.Activate(self, active)
        if active:
            self.RegisterSmartZone(self.spinzone, 2)

        return bReturn
Example #28
0
    def __init__(self, **args):
        Omni.__init__(self, **args)

        self.spinzone = "spinner"
        self.botinspinzone = 0
Example #29
0
    def __init__(self, **args):
        Omni.__init__(self, **args)
        self.flame_range = 30.0

        if 'flamerange' in args:
            self.flame_range = args.get('flamerange')
Example #30
0
 def __init__(self, **args):
     Omni.__init__(self, **args)
     if 'SpinCycle' in args:
         self.spincycle = self.spincycleMax = args['SpinCycle']
     else:
         self.spincycle = self.spincycleMax = 0