Test_MultiChannel.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # @Time : 18-4-23 下午5:25
4 # @Author : Yutong
5 # @Email : 416178264@qq.com
6 # @Site :
7 # @File : Test_MultiChannel.py
8 # @Software: PyCharm
9 # @Desc :
10 
11 import rospy
12 from lslidar_c16_msgs.msg import LslidarC16Layer
13 import os
14 import numpy as np
15 import matplotlib.pyplot as plt
16 
17 Remote_IP = '192.168.0.138'
18 
19 ROS_IP='http://'+Remote_IP+':11311'
20 os.environ['ROS_MASTER_URI']=ROS_IP #environ的键值必须是字符串
21 os.system('echo $ROS_MASTER_URI')
22 
23 
24 if __name__ == '__main__':
25  rospy.init_node("multi_channel")
26  msg = rospy.wait_for_message("scan_channel", LslidarC16Layer)
27  data_len = len(msg.scan_channel)
28 
29  for i in range(data_len):
30  laser_msg = msg.scan_channel[i]
31  laser_distance = np.array(laser_msg.ranges)
32  counter = len(laser_distance)
33  laser_distance[laser_distance == np.inf] = 0.0
34  laser_angle = np.linspace(laser_msg.angle_min, laser_msg.angle_max, counter)
35  intensity = np.array(laser_msg.intensities)
36  x_laser = np.multiply(laser_distance, np.cos(laser_angle))
37  y_laser = np.multiply(laser_distance, np.sin(laser_angle))
38  plt.plot(x_laser, y_laser, 'b.')
39  plt.show()


lslidar_c16_decoder
Author(s): Yutong
autogenerated on Thu Aug 22 2019 03:51:41