def main():

    global receiver
    receiver = canvas.init_receiver()

    global sender
    sender = canvas.init_sender()

    canvas.add_id(receiver, id_filter)

    # Main loop, modelled after control node's loop
    while 1:

        # See if any messages have been sent
        msg_name, data = canvas.recv(receiver)
        if (msg_name == 'set_eddy_brake_angle'):
            set_eddy_brake_angle(data)
        elif (msg_name == 'set_eddy_brake_power'):
            set_eddy_brake_power(data)
        elif (msg_name == 'get_eddy_brake_angle'):
            canvas.send(sender, 'get_eddy_brake_angle_rep',
                        get_eddy_brake_angle())
        elif (msg_name == 'get_eddy_brake_power'):
            canvas.send(sender, 'get_eddy_brake_power_rep',
                        get_eddy_brake_power())
        elif (msg_name == 'get_eddy_brake_temp'):
            canvas.send(sender, 'get_eddy_brake_temp_rep',
                        get_eddy_brake_temp())

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

	global sender 
	sender = canvas.init_sender()
	
	canvas.add_id(receiver, id_filter)

	# Main loop, modelled after control node's loop
	while 1:
	
		# See if any messages have been sent
		msg_name, data = canvas.recv(receiver)
		if (msg_name == 'set_eddy_brake_angle'):
			set_eddy_brake_angle(data)
		elif (msg_name == 'set_eddy_brake_power'):
			set_eddy_brake_power(data)
		elif (msg_name == 'get_eddy_brake_angle'):
			canvas.send( sender, 'get_eddy_brake_angle_rep', get_eddy_brake_angle() )
		elif (msg_name == 'get_eddy_brake_power'):
			canvas.send( sender, 'get_eddy_brake_power_rep', get_eddy_brake_power() )
		elif (msg_name == 'get_eddy_brake_temp'):
			canvas.send( sender, 'get_eddy_brake_temp_rep', get_eddy_brake_temp() )
			
		time.sleep(1)
def main():

    global receiver
    receiver = canvas.init_receiver()

    global sender
    sender = canvas.init_sender()

    canvas.add_id(receiver, id_filter)

    # Main loop, modelled after control node's loop
    while 1:

        # See if any messages have been sent
        msg_name, data = canvas.recv(receiver)
        if msg_name == "set_hover_eng_angle":
            set_hover_eng_angle(data)
        elif msg_name == "set_hover_eng_power":
            set_hover_eng_power(data)
        elif msg_name == "get_hover_eng_angle":
            canvas.send(sender, "get_hover_eng_angle_rep", get_hover_eng_angle())
        elif msg_name == "get_hover_eng_power":
            canvas.send(sender, "get_hover_eng_power_rep", get_hover_eng_power())

        time.sleep(1)
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("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)
Esempio n. 7
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)
Esempio n. 9
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)
def main():
	
	global receiver 
	receiver = canvas.init_receiver()

	global sender 
	sender = canvas.init_sender()
	
	canvas.add_id(receiver, id_filter)

	# Main loop, modelled after control node's loop
	while 1:
	
		#Request several data points
		canvas.send_batch(sender, ['pod_temp_req', 'pod_pressure_req', 'pod_attitude_req'])
		msg_name, data = canvas.recv(receiver)
		
		# Check data, make sure none is abnormal
		if (msg_name == 'pod_temp_data'):
			if (data > pod_temp_max):
				alert_ground_station(1,location)
				pod_shutdown()
			elif (data < pod_temp_min):
				alert_ground_station(2,location)
				pod_shutdown()

		elif (msg_name == 'pod_pressure_data'):
			if (data > pod_pres_max):
				alert_ground_station(3,location)
				pod_shutdown()
			elif (data < pod_pres_min):
				alert_ground_station(4,location)
				pod_shutdown()
				
				
		elif (msg_name == 'pod_attitude_data'):
		
		elif (msg_name == 'hover_height_data'):
			if (data > hover_height_max):
				alert_ground_station(7,location)
				pod_shutdown()
			elif (data < hover_height_min):
				alert_ground_station(8,location)
				pod_shutdown()

		time.sleep(1)
Esempio n. 11
0
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 main():
	
	global receiver 
	receiver = canvas.init_receiver()

	global sender 
	sender = canvas.init_sender()
	
	canvas.add_id(receiver, id_filter)

	# Main loop, modelled after control node's loop
	while 1:
	
		# See if any messages have been sent
		msg_name, data = canvas.recv(receiver)
		if (msg_name == 'set_brake_force'):
			set_brake_force(data)
		elif ('get_brake_force'):
			canvas.send( sender, 'get_brake_force_rep', get_brake_force() )
		elif ('is_brake_engaged'):
			canvas.send( sender, 'is_brake_engaged_rep', is_brake_engaged() )
			
		time.sleep(1)
def main():

    global receiver
    receiver = canvas.init_receiver()

    global sender
    sender = canvas.init_sender()

    canvas.add_id(receiver, id_filter)

    # Main loop, modelled after control node's loop
    while 1:

        # See if any messages have been sent
        msg_name, data = canvas.recv(receiver)
        if (msg_name == 'set_brake_force'):
            set_brake_force(data)
        elif ('get_brake_force'):
            canvas.send(sender, 'get_brake_force_rep', get_brake_force())
        elif ('is_brake_engaged'):
            canvas.send(sender, 'is_brake_engaged_rep', is_brake_engaged())

        time.sleep(1)
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)