Example #1
0
        if not input_queue.empty():
            arg = input_queue.get().lower().strip()
            if arg != "":
                # Arm
                if arg == "a":
                    print "arm"
                    broadcast(state.ARM)
                # Disarm
                if arg == "d":
                    print "disarm"
                    broadcast(state.IDLE)
                # Start logger (i.e. ready for launch)
                if arg == "l":
                    print "start logging"
                    broadcast(state.ARM + state.LOGGING)
                # Deploy chute
                if arg == "c":
                    print "deploy chute"
                    broadcast(state.ARM + state.LOGGING + state.CHUTE)
                # Shutdown Carlson
                if arg == "k":
                    print "power off"
                    broadcast(state.POWER_OFF)

        # Read (non-blocking) from telemetry radio
        received = radio.read()
        if received != "":
            state.set(ord(received))
            print "Air State: %s" % state
Example #2
0
                        (rad2deg(data["fusionPose"][0]),
                         rad2deg(data["fusionPose"][1]),
                         rad2deg(data["fusionPose"][2]), accel_norm, theta,
                         _freefall_detected, _apogee_detected))

        # Set chute pin high if we are using automatic apogee detection algorithm.
        if AUTO_APOGEE_DETECT and _freefall_detected and _armed:
            if _apogee_detected and not _chute_deployed:
                trigger_chute_pin()

        # Set chute pin back to LOW if blast cap burn time is reached
        if _nicrome_on and (time.time() - time_chute_deployed >
                            BLAST_CAP_BURN_TIME):
            untrigger_chute_pin()

        #######################################################################
        ## Update GROUND station
        #######################################################################

        # Update ground station once per HEARTBEAT_DELAY
        if time.time() - state_last_sent > HEARTBEAT_DELAY:
            state.set(state.IDLE)  # clear state and rebuild
            if _armed: state.add(state.ARM)
            if _logging_on: state.add(state.LOGGING)
            if _chute_deployed: state.add(state.CHUTE)
            if _freefall_detected: state.add(state.FREEFALL)
            if _apogee_detected: state.add(state.APOGEE)
            radio.write(chr(state.state))
            state_last_sent = time.time()
            debug("Sent heartbeat (%d)" % state.state)