예제 #1
0
    def __init__(self):
        rospy.init_node("max_sonar")
        
        self.sensor = maxSonar() 

        # start channel broadcast using SetupAnalogIn
        rospy.wait_for_service('arbotix/SetupAnalogIn')
        analog_srv = rospy.ServiceProxy('arbotix/SetupAnalogIn', SetupChannel) 
        
        req = SetupChannelRequest()
        req.topic_name = rospy.get_param("~name")
        req.pin = rospy.get_param("~pin")
        req.rate = int(rospy.get_param("~rate",10))
        analog_srv(req)

        # setup a range message to use
        self.msg = Range()
        self.msg.radiation_type = self.sensor.radiation_type
        self.msg.field_of_view = self.sensor.field_of_view
        self.msg.min_range = self.sensor.min_range
        self.msg.max_range = self.sensor.max_range

        # publish/subscribe
        self.pub = rospy.Publisher("sonar_range", Range)
        rospy.Subscriber("arbotix/"+req.topic_name, Analog, self.readingCb)

        rospy.spin()
예제 #2
0
    def __init__(self):
        rospy.init_node("ir_ranger")
        
        # sensor type: choices are A710YK (40-216"), A02YK (8-60"), A21YK (4-30")
        self.sensor_t = rospy.get_param("~type","GP2D12")
        if self.sensor_t == "A710YK" or self.sensor_t == "ultralong":
            self.sensor = gpA710YK()
        elif self.sensor_t == "A02YK" or self.sensor_t == "long":
            self.sensor = gpA02YK()
        else:
            self.sensor = gp2d12() 

        # start channel broadcast using SetupAnalogIn
        rospy.wait_for_service('arbotix/SetupAnalogIn')
        analog_srv = rospy.ServiceProxy('arbotix/SetupAnalogIn', SetupChannel) 
        
        req = SetupChannelRequest()
        req.topic_name = rospy.get_param("~name")
        req.pin = rospy.get_param("~pin")
        req.rate = int(rospy.get_param("~rate",10))
        analog_srv(req)

        # setup a range message to use
        self.msg = Range()
        self.msg.radiation_type = self.sensor.radiation_type
        self.msg.field_of_view = self.sensor.field_of_view
        self.msg.min_range = self.sensor.min_range
        self.msg.max_range = self.sensor.max_range

        # publish/subscribe
        self.pub = rospy.Publisher("ir_range", Range)
        rospy.Subscriber("arbotix/"+req.topic_name, Analog, self.readingCb)

        rospy.spin()
예제 #3
0
    def __init__(self):
        rospy.init_node("ir_ranger")

        # sensor type: choices are A710YK (40-216"), A02YK (8-60"), A21YK (4-30")
        self.sensor_t = rospy.get_param("~type", "GP2D12")
        if self.sensor_t == "A710YK" or self.sensor_t == "ultralong":
            self.sensor = gpA710YK()
        elif self.sensor_t == "A02YK" or self.sensor_t == "long":
            self.sensor = gpA02YK()
        else:
            self.sensor = gp2d12()

        # start channel broadcast using SetupAnalogIn
        rospy.wait_for_service('arbotix/SetupAnalogIn')
        analog_srv = rospy.ServiceProxy('arbotix/SetupAnalogIn', SetupChannel)

        req = SetupChannelRequest()
        req.topic_name = rospy.get_param("~name")
        req.pin = rospy.get_param("~pin")
        req.rate = int(rospy.get_param("~rate", 10))
        analog_srv(req)

        # setup a range message to use
        self.msg = Range()
        self.msg.radiation_type = self.sensor.radiation_type
        self.msg.field_of_view = self.sensor.field_of_view
        self.msg.min_range = self.sensor.min_range
        self.msg.max_range = self.sensor.max_range

        # publish/subscribe
        self.pub = rospy.Publisher("ir_range", Range, queue_size=5)
        rospy.Subscriber("arbotix/" + req.topic_name, Analog, self.readingCb)

        rospy.spin()
예제 #4
0
    def __init__(self):
        rospy.init_node("max_sonar")

        self.sensor = maxSonar()

        # start channel broadcast using SetupAnalogIn
        rospy.wait_for_service('arbotix/SetupAnalogIn')
        analog_srv = rospy.ServiceProxy('arbotix/SetupAnalogIn', SetupChannel)

        req = SetupChannelRequest()
        req.topic_name = rospy.get_param("~name")
        req.pin = rospy.get_param("~pin")
        req.rate = int(rospy.get_param("~rate", 10))
        analog_srv(req)

        # setup a range message to use
        self.msg = Range()
        self.msg.radiation_type = self.sensor.radiation_type
        self.msg.field_of_view = self.sensor.field_of_view
        self.msg.min_range = self.sensor.min_range
        self.msg.max_range = self.sensor.max_range

        # publish/subscribe
        self.pub = rospy.Publisher("sonar_range", Range, queue_size=5)
        rospy.Subscriber("arbotix/" + req.topic_name, Analog, self.readingCb)

        rospy.spin()