12 from lslidar_c16_msgs.msg
import LslidarC16Layer
15 import matplotlib.pyplot
as plt
17 Remote_IP =
'192.168.0.138' 19 ROS_IP=
'http://'+Remote_IP+
':11311' 20 os.environ[
'ROS_MASTER_URI']=ROS_IP
21 os.system(
'echo $ROS_MASTER_URI')
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)
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.')