Beispiel #1
0
def start_pod():
    canvas.print_out("start hover engine L")
    canvas.send(sender, ml.messages['start_l']['id'], 0)  # start engine

    canvas.print_out("get hover engine L status")
    canvas.send(sender, ml.messages['get_engine_status_l']['id'],
                "")  # get engine status L
def main():
	receiver = canvas.init_receiver()
	sender = canvas.init_sender()
	time.sleep(0.5) #sleep to allow for canvas server startup. horrible hack that will go away soon

	canvas.add_id(receiver, id_filter)
	canvas.print_out("Power distribution node started")
	canvas.send_cmd(sender, "power_distribution_node_started")

	while 1:

		canvas.send_cmd(sender, 'uc_temp_req')
		canvas.send_cmd(sender, 'batt_temp_req')
		canvas.send_cmd(sender, 'batt_power_req')
		canvas.send_cmd(sender, 'so_temp_req')

		msg_name, msg_data = canvas.recv(receiver)

		if (msg_name == 'uc_temp_req'):
			data = get_umbilical_temp()
			canvas.print_out("Umbilical temp: %s" % (data))

		elif (msg_name == 'batt_temp_req'):
			data = get_battery_temp()
			canvas.print_out("Battery temp: %s" % (data))

		elif (msg_name == 'batt_power_req'):
			data = get_batter_power()
			canvas.print_out("Battery power: %s" % (data))

		elif (msg_name == 'so_temp_req'):
			data = get_standard_outlet_temp()
			canvas.print_out("Standard outlet temp: %s" % (data))

		time.sleep(2)
def main():
	receiver = canvas.init_receiver()
	sender = canvas.init_sender()
	time.sleep(0.5) #sleep to allow for canvas server startup. horrible hack that will go away soon

	canvas.add_id(receiver, id_filter)
	canvas.print_out("Status node started")
	canvas.send_cmd(sender, "status_node_started")

	while 1:

		msg_name, data = canvas.recv(receiver)

		if (msg_name == 'pod_temp_req'):
			data = read_temp();
			canvas.send_data(sender, 'pod_temp_data', data)

		if (msg_name == 'pod_pressure_req'):
			data = read_pressure();
			canvas.send_data(sender, 'pod_pressure_data', data)

		if (msg_name == 'pod_attitude_req'):
			data = read_attitude();
			canvas.send_data(sender, 'pod_attitude_data', data)

		if (msg_name == 'pod_position_req'):
			data = read_position();
			canvas.send_data(sender, 'pod_position_data', data)
def main():
    receiver = canvas.init_receiver()
    sender = canvas.init_sender()
    time.sleep(
        0.5
    )  #sleep to allow for canvas server startup. horrible hack that will go away soon

    canvas.add_id(receiver, id_filter)
    canvas.print_out("Status node started")
    canvas.send_cmd(sender, "status_node_started")

    while 1:

        msg_name, data = canvas.recv(receiver)

        if (msg_name == 'pod_temp_req'):
            data = read_temp()
            canvas.send_data(sender, 'pod_temp_data', data)

        if (msg_name == 'pod_pressure_req'):
            data = read_pressure()
            canvas.send_data(sender, 'pod_pressure_data', data)

        if (msg_name == 'pod_attitude_req'):
            data = read_attitude()
            canvas.send_data(sender, 'pod_attitude_data', data)

        if (msg_name == 'pod_position_req'):
            data = read_position()
            canvas.send_data(sender, 'pod_position_data', data)
Beispiel #5
0
def move_pod(data):
    canvas.print_out("tilt hover engine at angle calculated from target speed")
    canvas.send(sender, ml.messages['tilt_l']['id'],
                math.asin(float(data) / 20) *
                5)  # title engine at calculated angle

    canvas.print_out("get hover engine L status")
    canvas.send(sender, ml.messages['get_engine_status_l']['id'],
                "")  # get engine status L
def main():
	
	receiver = canvas.init_receiver()
	sender = canvas.init_sender()
	time.sleep(0.5) #sleep to allow for canvas server startup. horrible hack that will go away soon

	canvas.add_id(receiver, id_filter)

	message_id = "asdf"
	message_data = "Ping from node 1"

	while 1:
		#print to stdout. python's standard print can interfere with supervisord's
		#output and logging functionality in strange ways. 
		#please use this instead.
		canvas.print_out( "This is node 1" )
		canvas.send(sender, message_id, message_data)
	    	
		msg_id, data = canvas.recv(receiver)

		canvas.print_out("Node 1 recieved: %s" % data)
		time.sleep(5)
def stop_pod():
	canvas.print_out("tilt hover engine to stop position")		
	canvas.send(sender, ml.messages['tilt_l']['id'], 0) # tilt engine back to stop position
	
	canvas.print_out("stop hover engine")		
	canvas.send(sender, ml.messages['stop_l']['id'], "") # stop engine L
	
	canvas.print_out("get hover engine l status")
	canvas.send(sender, ml.messages['get_engine_status_l']['id'], "") # get engine status L	
def main():
    receiver = canvas.init_receiver()
    sender = canvas.init_sender()
    time.sleep(
        0.5
    )  #sleep to allow for canvas server startup. horrible hack that will go away soon

    canvas.add_id(receiver, id_filter)
    canvas.print_out("Power distribution node started")
    canvas.send_cmd(sender, "power_distribution_node_started")

    while 1:

        canvas.send_cmd(sender, 'uc_temp_req')
        canvas.send_cmd(sender, 'batt_temp_req')
        canvas.send_cmd(sender, 'batt_power_req')
        canvas.send_cmd(sender, 'so_temp_req')

        msg_name, msg_data = canvas.recv(receiver)

        if (msg_name == 'uc_temp_req'):
            data = get_umbilical_temp()
            canvas.print_out("Umbilical temp: %s" % (data))

        elif (msg_name == 'batt_temp_req'):
            data = get_battery_temp()
            canvas.print_out("Battery temp: %s" % (data))

        elif (msg_name == 'batt_power_req'):
            data = get_batter_power()
            canvas.print_out("Battery power: %s" % (data))

        elif (msg_name == 'so_temp_req'):
            data = get_standard_outlet_temp()
            canvas.print_out("Standard outlet temp: %s" % (data))

        time.sleep(2)
Beispiel #9
0
def stop_pod():
    canvas.print_out("tilt hover engine to stop position")
    canvas.send(sender, ml.messages['tilt_l']['id'],
                0)  # tilt engine back to stop position

    canvas.print_out("stop hover engine")
    canvas.send(sender, ml.messages['stop_l']['id'], "")  # stop engine L

    canvas.print_out("get hover engine l status")
    canvas.send(sender, ml.messages['get_engine_status_l']['id'],
                "")  # get engine status L
Beispiel #10
0
def main():
	
	#init canvas sender and receiver
	receiver = canvas.init_receiver()
	sender = canvas.init_sender()
	time.sleep(0.5) #sleep to allow for canvas server startup. horrible hack that will go away soon

	#add message id filters on receiver
	canvas.add_id(receiver, receive_message_ids)

	#remove message id filters on receiver (add and remove only take lists for now..)
	canvas.rm_id(receiver, ["7"])

	#you have 2 ways of making CAN messages:
	#either just make 2 strings
	message_id = "100"
	message_data = "Ping from node 2"
	#or a canvas "message"
	message = canvas.msg("100", "Hi it's node 2 again")

	while 1:
		#print to stdout. python's standard print can interfere with supervisord's
		#output and logging functionality in strange ways. 
		#please use this instead.
		canvas.print_out( "This is node 2" )

		#send message on the CAN bus
		canvas.send(sender, message_id, message_data)
		canvas.send_msg(sender, message)	    	

		#you can change a canvas message like this
		message.id = "101"
		message.data="Node 1 should not see this now"

		#receive message from CAN bus (only returns messages that this node has subscribed to)
		#this call will block untill a message is received
		msg_id, msg_data = canvas.recv(receiver)

		#print message to stdout
		canvas.print_out("Node 2 recieved: %s %s" % (msg_id, msg_data))

		#non-blocking receive call (only returns messages that this node has subscribed to) 
		#will return "no_id", "no_message" if no message was received
		msg_id, msg_data = canvas.recv_noblock(receiver)		
		canvas.print_out("Node 2 recieved: %s %s" % (msg_id, msg_data))

		#sleep node for 5 second
		time.sleep(5)
Beispiel #11
0
def main():
    global receiver
    receiver = canvas.init_receiver()

    global sender
    sender = canvas.init_sender()

    time.sleep(
        0.5
    )  #sleep to allow for canvas server startup. horrible hack that will go away soon

    canvas.add_id(receiver, id_filter)
    canvas.print_out("Control node started")
    canvas.wait(receiver,
                ['power_distribution_node_stared', 'status_node_started'])
    canvas.print_out("rPod running")

    while 1:
        canvas.send_cmd(sender, 'get_pod_status')
        msg_name, data = canvas.recv(receiver)
        # get status of all engines
        if (msg_name == 'get_engine_status'):
            canvas.print_out("COMMANDS:")
            canvas.print_out("get all engine statuses")

            # get the status for each individual engine node
            canvas.send_cmd(sender, 'get_engine_status_l')

        elif (msg_name == 'move'):
            canvas.print_out("COMMANDS:")
            canvas.print_out("move %s" % data)

            move_pod(data)

        elif (msg_name == 'start'):
            canvas.print_out("COMMANDS:")
            canvas.print_out("start pod")

            start_pod()

        elif (msg_name == 'stop'):
            canvas.print_out("COMMANDS:")
            canvas.print_out("stop")

            stop_pod()
        #collect data from all pod sensors
        elif (msg_name == 'get_pod_status'):
            canvas.print_out("COMMANDS:")
            canvas.print_out("get pod status")

            height = get_hover_height()
            temp, pressure, attitude, position = get_pod_status()

            canvas.print_out(
                "Pod stauts: height - %smm, temp - %sC, pressure - %skPa, attitude - %s, position - %sm"
                % (height, temp, pressure, attitude, position))

        time.sleep(1)
def main():
	global receiver 
	receiver = canvas.init_receiver()

	global sender 
	sender = canvas.init_sender()

	time.sleep(0.5) #sleep to allow for canvas server startup. horrible hack that will go away soon

	canvas.add_id(receiver, id_filter)
	canvas.print_out("Control node started")
	canvas.wait(receiver, ['power_distribution_node_stared', 'status_node_started'])
	canvas.print_out("rPod running")

	while 1:
		canvas.send_cmd(sender, 'get_pod_status')
		msg_name, data = canvas.recv(receiver)
		# get status of all engines
		if (msg_name == 'get_engine_status'):
			canvas.print_out("COMMANDS:")
			canvas.print_out("get all engine statuses")
			
			# get the status for each individual engine node
			canvas.send_cmd(sender, 'get_engine_status_l')
			
		elif (msg_name == 'move'):
			canvas.print_out("COMMANDS:")
			canvas.print_out("move %s" % data)

			move_pod(data)
			
		elif (msg_name == 'start'):
			canvas.print_out("COMMANDS:")
			canvas.print_out("start pod")
			
			start_pod()
			
		elif (msg_name == 'stop'):
			canvas.print_out("COMMANDS:")
			canvas.print_out("stop")
			
			stop_pod()
		#collect data from all pod sensors
		elif (msg_name == 'get_pod_status'):
			canvas.print_out("COMMANDS:")
			canvas.print_out("get pod status")

			height = get_hover_height()
			temp, pressure, attitude, position = get_pod_status()

			canvas.print_out("Pod stauts: height - %smm, temp - %sC, pressure - %skPa, attitude - %s, position - %sm" % (height, temp, pressure, attitude, position) )

		time.sleep(1)
def start_pod():
	canvas.print_out("start hover engine L")		
	canvas.send(sender, ml.messages['start_l']['id'], 0) # start engine

	canvas.print_out("get hover engine L status")
	canvas.send(sender, ml.messages['get_engine_status_l']['id'], "") # get engine status L
def move_pod(data):
	canvas.print_out("tilt hover engine at angle calculated from target speed")		
	canvas.send(sender, ml.messages['tilt_l']['id'], math.asin(float(data)/20)*5) # title engine at calculated angle

	canvas.print_out("get hover engine L status")
	canvas.send(sender, ml.messages['get_engine_status_l']['id'], "") # get engine status L	
def pod_shutdown():
	canvas.print_out("Shutting down pod")		
	canvas.send_cmd(sender, 'stop')
def alert_ground_station(emer, loc):
	canvas.print_out("Sending message to ground station")		
	canvas.send(sender, 'emer_1', "Emergency code: {0} \nLocation: {1}".format(emer, loc))