예제 #1
0
                    level=logging.DEBUG)
logger = logging.getLogger(__name__)


#
#   Open up the serial port, get lidar data and write it to a file
#   every few seconds.
#
if __name__ == '__main__':

        channel = UDPChannel(remote_ip='10.10.76.100', remote_port=5880,
                              local_ip='0.0.0.0', local_port=52954)
        #channel = UDPChannel()
        range_at_heading_message = LidarRangeAtHeadingMessage()
        periodic_message = LidarPeriodicMessage()
        lidar_logger = LidarLogger(logger)
        
        lp = None
        
        # open up the serial port device connected to the lidar
        try: 	
		lp = serial.Serial('/dev/ttyUSB0',115200,timeout=1)
        except: 
                logger.error('Lidar port could not be opened.')

        # connect the port with the laser and initialize the laser object
        #lasr = OldLaser(lp)
        lasr = Laser(lp)

        #
        #
예제 #2
0
                                
 		        except IOError,e:
                                #  log and notify robot of error
                                periodic_message.status = 'error'
                                if not suppress_robot_comm:
                                        channel.send_to(periodic_message.encode_message())
                                logger.error("Failed to gather a full rotation of data.")

                        #
                        # get revised instructions from robot
                        #
                        if 0:
                                robot_data, robot_address = channel.receive_from()
                                message_from_robot = RobotMessage(robot_data)
                                if ((message_from_robot.sender == 'robot') and
                                    (message_from_robot.message == 'sweep')):
                                        Analyzer.start = message_from_robot.start
                                        Analyzer.stop = message_from_robot.stop
                        #except socket.timeout:
                        #        logger.info("No message received from robot")

                        elapsed_time = (SECONDS_PER_MINUTE/float(rotation.rpm()))
                        rotation_time = rotation_time + elapsed_time
                        logger.info("rotation time is: {:.1f}".format(rotation_time))
                        current_time = current_time + elapsed_time
                        if rotation_time > seconds_per_output:
                                fname = "data/lidar_snapshot_{:d}.dat".format(file_index)
                                LidarLogger.write_to_file(fname, rotation.polar_data())
                                file_index = file_index + 1
                                rotation_time = 0