Exemplo n.º 1
0
    async def send_kills(self):
        while True:
            if self.home_page_connection is None:
                js = Joystick()
                js.kill = True
                js.forward_back = 0
                js.left_right = 0
                self.lcm_.publish("/drive_control", js.encode())

            await asyncio.sleep(0.5)
Exemplo n.º 2
0
    def __init__(self):  # other args if ya want em
        # all initially defined variables should be here
        # while not technically globals, this is basically where they are
        # defined for the sim, since the entire instance is the SimMetaClass

        Obstacles = []
        Waypoints = []
        Tennis_Balls = []

        # below: class list, one class for each message type
        # published or recieved. instantiate them at the bottom
        # of this message definition block
        # use the provided imported classes and dump these later
        # you still need to set all the defaults

        self.NavStatusMsg = NavStatus()
        self.JoystickMsg = Joystick()
        # self.GPSMsg = GPS()
        # self.BearingMsg = Bearing()
        self.GPSMsg = GPS()
        self.ObstacleMsg = Obstacle()
        self.TennisBallMsg = TennisBall()
        self.CourseMsg = Course()
        self.AutonStateMsg = AutonState()

        self.NavStatusMsg.nav_state = 0
        self.NavStatusMsg.completed_wps = 0
        self.NavStatusMsg.missed_wps = 0
        self.NavStatusMsg.total_wps = 0

        self.JoystickMsg.forward_back = 0
        self.JoystickMsg.left_right = 0
        self.JoystickMsg.dampen = 0

        self.GPSMsg.latitude_deg = 39
        self.GPSMsg.latitude_min = 0
        self.GPSMsg.longitude_deg = -110
        self.GPSMsg.longitude_min = 0
        self.GPSMsg.bearing = 0
        self.GPSMsg.speed = -999  # this value is never used
        # so it's being set to a dummy value. DO NOT USE IT

        self.ObstacleMsg.detected = 0
        self.ObstacleMsg.bearing = 0

        self.TennisBallMsg.found = 0
        self.TennisBallMsg.bearing = 0
        self.TennisBallMsg.distance = 0

        self.CourseMsg.num_waypoints = 0
        self.CourseMsg.hash = 0
        self.CourseMsg.waypoints = []

        self.AutonStateMsg.is_auton = False
Exemplo n.º 3
0
async def transmit_fake_joystick():
    while True:
        new_joystick = Joystick()
        new_joystick.forward_back = random.uniform(-1, 1)
        new_joystick.left_right = random.uniform(-1, 1)
        new_joystick.dampen = random.uniform(-1, 1)
        new_joystick.kill = False
        new_joystick.restart = False

        with await lock:
            lcm_.publish('/joystick', new_joystick.encode())

        print("Published new joystick\nfb: {}   lr: {}"
              .format(new_joystick.forward_back, new_joystick.left_right))
        await asyncio.sleep(0.5)