def human_turn(msg):
global last_message
if msg.data!=last_message:
last_message = msg.data
received_msg = String()
received_msg.data = "receives: " + msg.data
pub_reception.publish(received_msg)
label, _, items, name = read_msg(msg)
p1.human(label, items, name)
p1.mainframe.tkraise()
python类String()的实例源码
def human_predict(msg):
global last_message
if msg.data!=last_message:
last_message = msg.data
received_msg = String()
received_msg.data = "receives: " + msg.data
pub_reception.publish(received_msg)
label, _, items, name = read_msg(msg)
p1.human_predict(label, items, name)
p1.mainframe.tkraise()
def have_chosen(msg):
global last_message
if msg.data!=last_message:
last_message = msg.data
received_msg = String()
received_msg.data = "receives: " + msg.data
pub_reception.publish(received_msg)
label, choice, items, name = read_msg(msg)
p1.chosen(label, items, choice,name)
p1.mainframe.tkraise()
def new_phrase(msg):
global last_message
if msg.data!=last_message:
last_message = msg.data
received_msg = String()
received_msg.data = "receives: " + msg.data
pub_reception.publish(received_msg)
p1.telling(msg.data)
p1.mainframe.tkraise()
def human_choice(choice):
rospy.loginfo("human choice "+choice)
msg = String()
msg.data = choice
pub_human_choice.publish(msg)
def human_prediction(choice):
rospy.loginfo("human predict "+choice)
msg = String()
msg.data = choice
pub_human_prediction.publish(msg)
def look_at(target):
msg = String()
msg.data = target
pub_robot_target.publish(msg)
def say(to_say):
msg = String()
msg.data = to_say
pub_robot_say.publish(msg)
def point(robot_choice):
msg = String()
msg.data = robot_choice; rospy.loginfo("robot_choice "+robot_choice)
pub_robot_point.publish(msg)
def ending(test):
msg = String()
msg.data = ""
pub_exit.publish(msg)
def robot_turn(label, items, name="false"):
msg = String()
msg.data = label+",_,"+"-".join(items)+','+name
pub_robot_turn.publish(msg)
def human_turn(label, items, name="false"):
msg = String()
msg.data = label+",_,"+"-".join(items)+','+name
pub_human_turn.publish(msg)
def human_predict(label, items, name="false"):
msg = String()
msg.data = label+",_,"+"-".join(items)+','+name
pub_human_predict.publish(msg)
def robot_chosen(label, items, choice, name="false"):
msg1 = String()
msg2 = String()
msg1.data = label+","+choice+","+"-".join(items)+','+name
pub_robot_chosen.publish(msg1)
msg2.data = "(Nando) "+label+"\n"
pub_new_element.publish(msg2)
######################################## reacting
def story_telling(phrase):
msg = String()
msg.data = phrase
pub_story_telling.publish(msg)
############################################# what if new action message
def robot_turn(msg):
global last_message
if msg.data!=last_message:
last_message = msg.data
received_msg = String()
received_msg.data = "receives: " + msg.data
pub_reception.publish(received_msg)
label, _, items, name = read_msg(msg)
p1.robot(label, items, name)
p1.mainframe.tkraise()
def human_turn(msg):
global last_message
if msg.data!=last_message:
last_message = msg.data
received_msg = String()
received_msg.data = "receives: " + msg.data
pub_reception.publish(received_msg)
label, _, items, name = read_msg(msg)
p1.human(label, items, name)
p1.mainframe.tkraise()
def human_predict(msg):
global last_message
if msg.data!=last_message:
last_message = msg.data
received_msg = String()
received_msg.data = "receives: " + msg.data
pub_reception.publish(received_msg)
label, _, items, name = read_msg(msg)
p1.human_predict(label, items, name)
p1.mainframe.tkraise()
def new_phrase(msg):
global last_message
if msg.data!=last_message:
last_message = msg.data
received_msg = String()
received_msg.data = "receives: " + msg.data
pub_reception.publish(received_msg)
p1.telling(msg.data)
p1.mainframe.tkraise()
def new_element(msg):
global last_message
if msg.data!=last_message:
last_message = msg.data
received_msg = String()
received_msg.data = "receives: " + msg.data
pub_reception.publish(received_msg)
p1.update_trace(msg.data)
p1.mainframe.tkraise()
################################################ for the trace