Exemple #1
0
    def robot_state_publisher(self):
        if self.current_robot_status['ready']:
            state_num = 0

        if self.current_robot_status['busy']:
            state_num = 1

        if self.current_robot_status['direct_teaching']:
            state_num = 2

        if self.current_robot_status['collision']:
            state_num = 3

        if self.current_robot_status['emergency']:
            state_num = 4

        status_msg = GoalStatusArray()
        status_msg.header.stamp = rospy.Time.now()

        status = GoalStatus()
        status.goal_id.stamp = rospy.Time.now()
        status.goal_id.id = ""
        status.status = state_num
        status.text = ROBOT_STATE[state_num]

        status_msg.status_list = [status]

        self.indy_state_pub.publish(status_msg)
Exemple #2
0
def fake_auto_demo():
    rospy.init_node('autonomous_demo23')

    #Requirements
    pub1 = rospy.Publisher('/gps/fix', NavSatFix, queue_size=10)
    pub2 = rospy.Publisher('/imu/data', Imu, queue_size=10)
    pub3 = rospy.Publisher('/odometry/wheel', Odometry, queue_size=10)
    pub4 = rospy.Publisher('/gps_waypoint_handler/status/gps/fix',
                           String,
                           queue_size=10)
    pub5 = rospy.Publisher('/pass_gate_topic', String, queue_size=10)
    #Autonomous movement
    #pub5 = rospy.Publisher('/move_base/status',GoalStatusArray,queue_size=10)

    #Image Detect
    pub6 = rospy.Publisher('/artag_detect_topic', String, queue_size=10)

    #Image Reach
    pub7 = rospy.Publisher('/artag_reach_topic', String, queue_size=10)
    pub8 = rospy.Publisher('/done_app_topic', String, queue_size=10)

    rate = rospy.Rate(10)  # 10hz
    count = 0

    while not rospy.is_shutdown():
        print("0: All sensors are good.")
        print("1: All sensors except encoder are good.")
        print("2: Damaged Sensors")
        print("3: Got Waypoint")
        print("4: Did not get any waypoint")
        print("5: Reached to way point")
        print("6: Did not Reached to way point")
        print("7: Detected AR Tag")
        print("8: Did not detect AR Tag")
        print("9: Reached AR Tag")
        print("10: Did not reached AR Tag")

        imuMsg = Imu()
        imuMsg.orientation.x = 5
        imuMsg.orientation.y = 5
        gpsMsg = NavSatFix()
        gpsMsg.latitude = 5
        gpsMsg.longitude = 5
        encoderMsg = Odometry()
        encoderMsg.pose.pose.position.x = 5
        encoderMsg.pose.pose.position.y = 5

        wpStatusMsgLow = GoalStatus()
        wpStatusMsgLow.status = 3
        wpStatusArray = []
        wpStatusArray.append(wpStatusMsgLow)
        wpStatusMsg = GoalStatusArray()
        wpStatusMsg.status_list = wpStatusArray

        userInput = raw_input()
        if userInput == "0":  #All sensors are good.

            pub1.publish(gpsMsg)
            pub2.publish(imuMsg)
            pub3.publish(encoderMsg)

        elif userInput == "1":  # All sensors except encoder are good.
            pub1.publish(gpsMsg)
            pub2.publish(imuMsg)
            #pub3.publish("0")

        elif userInput == "2":  #Damaged Sensors
            pub1.publish(gpsMsg)
            #pub2.publish("0")
            pub3.publish(encoderMsg)

        elif userInput == "3":  # Got Waypoint
            pub4.publish("1")

        elif userInput == "4":  #Did not get any waypoint
            pub4.publish("0")

        elif userInput == "5":  #Reached to way point
            #pub5.publish(wpStatusMsg)
            pub4.publish("2")

        #elif userInput == "6": #Did not reached to way point
        #pub5.publish("0")

        elif userInput == "7":  #Detected Image
            pub6.publish("1")
            #pub5.publish("1")

        elif userInput == "8":  #Did not Detect Image
            pub6.publish("0")

        elif userInput == "9":  #Reached Image
            pub7.publish("1")

        elif userInput == "10":  #Did not reached image
            pub7.publish("0")

        elif userInput == "11":
            pub5.publish("1")

        elif userInput == "12":
            pub8.publish("1")

        else:
            print("Invalid entry")

        rate.sleep()