示例#1
0
def bug2main():
	rospy.init_node('bug2')
	pub=rospy.Publisher('rcout', bug2, queue_size=1)
	sub=rospy.Subscriber('collision_detected', Float32, callback)
	sub1=rospy.Subscriber('ir_array', ir_array, callback0)
	rate=rospy.Rate(10)

	msg=bug2()
	msg.forward=0
	msg.reverse=0
	msg.spinright=0
	msg.spinleft=0
	msg.turnright=0
	msg.turnleft=0



	while not rospy.is_shutdown():###this is the in main function that will constantly run
		#this shit turns it to manuel mode when we hit something
		if collision_detected == 1:
                  set_mode_manual()
		for retry in range(10):
                  test = right_or_left()
		if test == "error":
   		  test = "right"
		if test == "right":
 		  turn_right_wall_detected()
		elif test == "left":
		  turn_left_wall_detected()
		motor_forward()
                time.sleep(3)
                motor_stop()
		main_code(test, 0)
示例#2
0
def motor_stop():
  pub=rospy.Publisher('rcout', bug2, queue_size=1)
  msg=bug2()  
  msg.forward=0
  msg.reverse=0
  msg.spinright=0
  msg.spinleft=0
  msg.turnright=0
  msg.turnleft=0
  pub.publish(msg)
示例#3
0
def motor_turn_left():
  pub=rospy.Publisher('rcout', bug2, queue_size=1)
  msg=bug2()  
  msg.turnleft=1
  pub.publish(msg)
示例#4
0
def motor_spin_right():
  pub=rospy.Publisher('rcout', bug2, queue_size=1) 
  msg=bug2()
  msg.spinright=1
  pub.publish(msg)
示例#5
0
def motor_reverse():
  pub=rospy.Publisher('rcout', bug2, queue_size=1) 
  msg=bug2()
  msg.reverse=1()
  pub.publish(msg)
示例#6
0
def motor_forward():
  pub=rospy.Publisher('rcout', bug2, queue_size=1) 
  msg=bug2()
  msg.forward=1
  pub.publish(msg)