• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python msg.Range类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sensor_msgs.msg.Range的典型用法代码示例。如果您正苦于以下问题:Python Range类的具体用法?Python Range怎么用?Python Range使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Range类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

def main():
    global NUM_SENSORS, BAUD_RATE, DEVICE_ADDRESS
    rospy.loginfo("Launching arduino analog reader")
    rospy.init_node("arduinoReader")

    ser = serial.Serial(DEVICE_ADDRESS)
    ser.baudrate = BAUD_RATE

    pubs = []
    for index in range(NUM_SENSORS):
        pubs.append(rospy.Publisher(("/sonar/" + str(index)), Range))

    while not rospy.is_shutdown():
        data = ser.readline().split("\t")
        data.pop() # last element is garbage
        rospy.loginfo("Read line: " + str(data))
        for reading in data:
            #construct message
            msg = Range()
            try:
                msg.range = float(reading)
            except ValueError:
                msg.range = -1.0

            pubIndex = data.index(reading)
            if pubIndex < NUM_SENSORS :
                pubs[pubIndex].publish(msg)
开发者ID:gunncs,项目名称:gunncs_navigation,代码行数:27,代码来源:arduinoReader.py


示例2: __init__

    def __init__(self):
        #初始化节点
        rospy.init_node("talkerUltraSound", anonymous = True)        
        #超声波数据发布节点
        ultrasound_pub = rospy.Publisher("UltraSoundPublisher", Range, queue_size = 20)
        
        ran_broadcaster = tf.TransformBroadcaster()
        
        rate=rospy.Rate(1)
        
        while not rospy.is_shutdown():
			ran_quat = Quaternion()
			ran_quat = quaternion_from_euler(0, 0, 0)	
			#发布TF关系
			ran_broadcaster.sendTransform((0.2,0.0,0.2),ran_quat,rospy.Time.now(),"ultrasound","base_link")
			#定义一个超声波消息
			ran = Range()
			ran.header.stamp = rospy.Time.now()
			ran.header.frame_id = "/ultrasound"
			ran.field_of_view = 1;
			ran.min_range = 0;
			ran.max_range = 5;
			ran.range = 0.5;
			ultrasound_pub.publish(ran)
			rate.sleep()
开发者ID:wingzer,项目名称:MOI_Robot_Winter,代码行数:25,代码来源:fake_ultro.py


示例3: Publish

    def Publish(self):
		#初始化节点
        rospy.init_node("talkerUltraSound", anonymous = True)        
        #超声波数据发布节点
        self.ultrasound_pub = rospy.Publisher("UltraSoundPublisher", Range, queue_size = 20)
        
        ran_broadcaster = tf.TransformBroadcaster()
        
        rate=rospy.Rate(10)
        #print "Input distance('+' is the end of the number):"
        while not rospy.is_shutdown():
			#ch=self.getKey()
			#self.addChar(ch)
			ran_quat = Quaternion()
			ran_quat = quaternion_from_euler(0, 0, 0)	
			#发布TF关系
			ran_broadcaster.sendTransform((0.2,0.0,0.2),ran_quat,rospy.Time.now(),"ultrasound","base_link")
			#定义一个超声波消息
			ran = Range()
			ran.header.stamp = rospy.Time.now()
			ran.header.frame_id = "/ultrasound"
			ran.field_of_view = 1;
			ran.min_range = 0;
			ran.max_range = 5;
			ran.range = self.dist;
			#ultrasound_pub.publish(ran)
			rate.sleep()		
开发者ID:wingzer,项目名称:MOI_Robot_Winter,代码行数:27,代码来源:fake_ultro_withInput.py


示例4: altitude_pub

 def altitude_pub(self, alt):
     rng = Range()
     rng.field_of_view = math.pi * 0.1
     rng.max_range = 300
     rng.header.frame_id = "sonar_link"
     rng.header.stamp = rospy.Time.now()
     rng.range = alt
     return rng
开发者ID:wallarelvo,项目名称:decawave_localization,代码行数:8,代码来源:localize.py


示例5: prepareArray

 def prepareArray(self):
     for i in range(0, len(self.sensors)):
         r = Range()
         r.header.frame_id = "ir{}_link".format(i + 1)
         r.min_range = self.sensors[i].min_range
         r.max_range = self.sensors[i].max_range
         r.radiation_type = r.INFRARED
         self.msg.array += [r]
开发者ID:DD2425-2015-Group7,项目名称:catkin_ws,代码行数:8,代码来源:ir_publish.py


示例6: sendMessage

def sendMessage(sonarId, distance):
	sonarDictionary = {'1':"frontLeftSonar", '2':"diagLeftSonar", '3':"sideLeftSonar", '4':"frontRightSonar", '5':"diagRightSonar", '6':"sideRightSonar"}
	sonarName = sonarDictionary[sonarId]
	sonar = Range()
	sonar.header.stamp = rospy.Time.now()
	sonar.header.frame_id = sonarName
	sonar.range = float(distance)
	sonar.field_of_view = .3489
	sonar.max_range = 6.45
	sonar.min_range = .1524
	return sonar
开发者ID:ablasdel,项目名称:smart_wheelchair,代码行数:11,代码来源:sonarReader.py


示例7: random_sonar

def random_sonar(delay=1):
    print('Starting random sonar...')
    pub = Publisher('/sensors/range', Range)
    msg = Range()
    while not rospy.is_shutdown():
        msg.header = rospy.Header(frame_id='right_sonar_frame')
        msg.range = random.random() * 20
        pub.publish(msg)
        sleep(delay)
        msg.header = rospy.Header(frame_id='left_sonar_frame')
        msg.range = random.random() * 20
        pub.publish(msg)
开发者ID:pandora-auth-ros-pkg,项目名称:dashboard,代码行数:12,代码来源:mock.py


示例8: talker

def talker():
    pub = rospy.Publisher("sensor1", Range, queue_size=50)
    rospy.init_node("robot", anonymous=True)
    rate = rospy.Rate(1) # 10hz
    while not rospy.is_shutdown():
        msg = Range()
        msg.header.stamp = rospy.Time.now()
        msg.header.frame_id = "/sensor1"
        msg.min_range = 0
        msg.max_range = 2
        msg.radiation_type = Range.ULTRASOUND

        rospy.loginfo(msg)
        pub.publish(msg)
        rate.sleep()
开发者ID:ayeganov,项目名称:tank_roboto,代码行数:15,代码来源:sensor_proxy.py


示例9: getDistance

    def getDistance(self):
		while True:
			self.dist=input("plase input dis:") 
			try:
				print "you have input:"+str(self.dist)
			except:
				print "you have input nothing"
			ran = Range()
			ran.header.stamp = rospy.Time.now()
			ran.header.frame_id = "/ultrasound"
			ran.field_of_view = 1;
			ran.min_range = 0;
			ran.max_range = 5;
			ran.range = self.dist;
			self.ultrasound_pub.publish(ran)
开发者ID:wingzer,项目名称:MOI_Robot_Winter,代码行数:15,代码来源:fake_ultro_withInput.py


示例10: range_test

def range_test():
	from sensor_msgs.msg import Range 
	sensor = RangeSensor()
	print sensor

	m = Range()
	m.range = 2000.0
	m.max_range = 3000.0
	m.min_range = 2.01

	sensor.min_safe = 500

	sensor.measure(m)

	print sensor 
	print sensor.isNear()
	print sensor.isFar()

	m.range = 4000
	sensor.measure(m)
	print sensor 
	print sensor.isNear()
	print sensor.isFar()

	m.range = -2000
	sensor.measure(m)
	print sensor 
	print sensor.isNear()
	print sensor.isFar()

	m.range = 300
	sensor.measure(m)
	print sensor 
	print sensor.isNear()
	print sensor.isFar()
开发者ID:sebascuri,项目名称:QUACS,代码行数:35,代码来源:Sensors.py


示例11: test_range

	def test_range(self):
		sensor = Sensors.Range(min_safe=10)
		msg = Range()
		msg.max_range = 3000
		msg.min_range = 5
		msg.range = 2500

		sensor.measure(msg)

		self.assertEquals(sensor.max_range, msg.max_range)
		self.assertEquals(sensor.min_range, msg.min_range)
		self.assertEquals(sensor.range , msg.range)
		self.assertFalse(sensor.isFar())
		self.assertFalse(sensor.isNear())

		msg.range = 4001
		sensor.measure(msg)
		self.assertTrue(sensor.isFar())
		self.assertFalse(sensor.isNear())

		msg.range = 3
		sensor.measure(msg)
		self.assertFalse(sensor.isFar())
		self.assertTrue(sensor.isNear())

		msg.range = 8
		sensor.measure(msg)
		self.assertFalse(sensor.isFar())
		self.assertTrue(sensor.isNear())
开发者ID:sebascuri,项目名称:ITBA_QUACS,代码行数:29,代码来源:test_sensors.py


示例12: talker

def talker():
    pub = rospy.Publisher('lidar_data', Range, queue_size=10)
    rospy.init_node('lidar_node')
    rate = rospy.Rate(1000) # 10hz
    ser=serial.Serial('/dev/ttyUSB1',115200)
    msg=Range()
    
    while not rospy.is_shutdown():
	p=ser.readline()
	if p!='\n' and p!='':
	   try:
	      msg.range=int(p)
	      msg.header.stamp = rospy.Time.now()
	      print msg.range
	      pub.publish(msg)
	   except:
	      pass   
	rate.sleep()
开发者ID:vivekprayakarao,项目名称:lidar_node,代码行数:18,代码来源:lidar_node.py


示例13: publish

 def publish(self, data):
     msg = Range()
     msg.header.stamp = rospy.get_rostime()
     msg.header.frame_id = self._frameId
     if self._urfType == URF_HRLV:
         msg.min_range = MIN_RANGE_URF_HRLV_MaxSonar
         msg.max_range = MAX_RANGE_URF_HRLV_MaxSonar
         msg.field_of_view = FIELD_OF_VIEW_URF_HRLV_MaxSonar
     else:
         msg.min_range = MIN_RANGE_URF_LV_MaxSonar
         msg.max_range = MAX_RANGE_URF_LV_MaxSonar
         msg.field_of_view = FIELD_OF_VIEW_URF_LV_MaxSonar
     msg.radiation_type = Range.ULTRASOUND
     msg.range = data
     self._pub.publish(msg)
开发者ID:Itamare4,项目名称:robotican,代码行数:15,代码来源:RiCURF.py


示例14: node

def node():
    rospy.init_node('sonar_node', anonymous=True)
    range_msg = Range()
    range_msg.radiation_type = range_msg.ULTRASOUND
    pub = rospy.Publisher("/msg_from_sonar", Range, queue_size=10)
    r = rospy.Rate(20)
    rospy.loginfo("reading sonar range")
    while not rospy.is_shutdown():
        #trigger sonar to measure
        cmd = chr(0x22)+chr(0x00)+chr(0x00)+chr(0x22)
        ser.write(cmd)
        data = ser.read(4)
        if len(data)==4 and (ord(data[0])+ord(data[1])+ord(data[2]))&255 == ord(data[3]):
            sonar_range = ord(data[1])*256+ord(data[2])
            range_msg.range = sonar_range
            pub.publish(range_msg)
            rospy.loginfo("distance : %d", sonar_range)
        else:
            rospy.logwarn("sonar error!")
        r.sleep()
开发者ID:taogashi,项目名称:smith,代码行数:20,代码来源:sonar.py


示例15: callback

def callback(event):
	value = ADC.read("P9_39")
	outvoltage = 3.3 * value
	#minimum range
	if outvoltage > 2.75:
		rangevalue = 15
	elif outvoltage < .4:
		rangevalue = 150
	else:
		#exponential fit function, derived from data sheet
		rangevalue = 61.7 * math.pow(outvoltage, -1.2)

	#assign values and publish
	pub = rospy.Publisher('/range', Range, queue_size=10)
	rangeout = Range()
	rangeout.min_range = 15
	rangeout.max_range = 150
	rangeout.range = rangevalue
	rospy.loginfo(rangeout)
	pub.publish(rangeout)
开发者ID:ccc395,项目名称:test,代码行数:20,代码来源:rangenode.py


示例16: callDist

def callDist(data):

		#reads voltage value
        voltage = ADC.read("P9_40")
		#converts voltage values into distance(meters)
        distance = (voltage**-.8271732796)
        distance = distance*.1679936709
    	#checks and discards data outside of accurate range
        if distance>2:
            distance = 2
        elif distance<.15:
            distance = .15

    	#Writes data to Range message
        msg = Range()
        header = Header()
        #creates header
        msg.header.stamp.secs = rospy.get_time()
        msg.header.frame_id = "/base_link"
        msg.radiation_type = 1
        msg.field_of_view = .15	#about 8.5 degrees
        msg.min_range = .15
        msg.max_range = 2
        msg.range = distance
        pub.publish(msg)
开发者ID:mdykshorn,项目名称:mapBot,代码行数:25,代码来源:irOutput.py


示例17: talker

def talker():
    signal.signal(signal.SIGINT, signal_handler)
    time.sleep(1)
    setup_servo()
    pub = rospy.Publisher('servo_ulta', Range, queue_size=10)
    rospy.init_node('servo_ultra', anonymous=True, disable_signals=False )
    rate = rospy.Rate(10) # 10hz
    ultrasonic_number = 1
    
    pause_time = 0.1
    delay_ultrasonic = 0.11
    STEP_ANGLE = 10

    CURR_ANGLE = (90.0 * math.pi) / 180.0

    mindt = 0.65
    maxdt = 2.48
    dt = [mindt, maxdt]
    extremes = [int(x * 1024.0 / 20.0) for x in dt]

    dt_range = extremes[1] - extremes[0]
    dt_step = int((dt_range / 180.0) * STEP_ANGLE)

    br = tf.TransformBroadcaster()

    while not rospy.is_shutdown():
        #broadcast_transforms()

        # Move servo to counter-clockwise extreme.
        wiringpi.pwmWrite(18, extremes[1])
        sleep(0.2)
        CURR_ANGLE = (90.0 * math.pi) / 180.0

        for i in range(extremes[1],extremes[0],-dt_step):         # 1025 because it stops at 1024
            wiringpi.pwmWrite(18,i)
            sleep(pause_time)
            br.sendTransform((0.15, 0.0, 0.0),tf.transformations.quaternion_about_axis(CURR_ANGLE, (0, 0, 1)), rospy.Time.now(), "1", "base_link")
            data = Range()
            data.header.frame_id = "1"
            data.header.stamp = rospy.Time.now()
            data.radiation_type = 0
            data.min_range = 0.05 
            data.max_range = 2.0
            data.field_of_view = 0.164
            try :
                data.range = float(get_us_data_from(ultrasonic_number)) /100.0
            except IOError:
                subprocess.call(['i2cdetect', '-y', '1'])
                data.range = 0.0
            pub.publish(data)
            CURR_ANGLE -= (STEP_ANGLE * math.pi) / 180.0
开发者ID:digvijay7,项目名称:botpi,代码行数:51,代码来源:servo_ultra.py


示例18: default

    def default(self, ci='unused'):
        msg = Range()
        msg.header = self.get_ros_header()
        msg.radiation_type = Range.INFRARED
        msg.field_of_view = 20
        msg.min_range = 0
        msg.max_range = self.component_instance.bge_object['laser_range']
        tmp = msg.max_range
        for ray in self.data['range_list']:
            if tmp > ray:
                tmp = ray
        msg.range = tmp

        self.publish(msg)
开发者ID:HorvathJo,项目名称:morse,代码行数:14,代码来源:infrared.py


示例19: send_range

	def send_range(self, msg, current_time):
		# ultra sonic range finder
		scan = Range()
		scan.header.stamp = current_time
		scan.header.frame_id = "forward_sensor"
		scan.radiation_type = 0
		scan.field_of_view = 60*pi/180
		scan.min_range = 0.0
		scan.max_range = 4.0
		scan.range = msg.d1/100.0
		self.pub_sonar.publish(scan)
开发者ID:bsmr-misc-forks,项目名称:ros_roboint,代码行数:11,代码来源:robo_explorer.py


示例20: _msg

    def _msg(self, frame_id, distance):
        msg = Range()
        msg.header.frame_id = frame_id
        msg.header.stamp = rospy.Time.now()
        msg.radiation_type = self._type
        msg.field_of_view = self._fov
        msg.min_range = self._min
        msg.max_range = self._max
        msg.range = min(max(distance, msg.min_range), msg.max_range)

        return msg
开发者ID:tslator,项目名称:arlobot_rpi,代码行数:11,代码来源:range_array_sensor.py



注:本文中的sensor_msgs.msg.Range类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python point_cloud2.read_points函数代码示例发布时间:2022-05-27
下一篇:
Python msg.NavSatFix类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap