Exemplo n.º 1
0
        # connect the port with the laser and initialize the laser object
        #lasr = OldLaser(lp)
        lasr = Laser(lp)

        #
        #
	slice_index = 0
        file_index = 1
        rotation_time = 0
        current_time = 0
        seconds_per_output = 10
        SECONDS_PER_MINUTE = 60.0
	while 1: 
		try:
                        rotation = Rotation(lasr.gather_full_rotation())
                        # rotation = OldRotation(lasr.gather_full_rotation())
                        #
                        # For now, we just output a lidar data snapshot every 10 seconds
                        # We will want this for debugging (maybe every second instead)
                        # change the "seconds_per_output" to tune that.
                        #
                        tgt_heading, tgt_range = Analyzer.range_at_heading(rotation.polar_data(), (Analyzer.start, Analyzer.stop))
                        logger.info("{:d} points yields {:.2f} inches at {:2d} degrees)".format(len(rotation.polar_data()),tgt_range, tgt_heading))

                        # push the newly calculated data into the message
                        range_at_heading_message.heading = tgt_heading
                        range_at_heading_message.range = tgt_range
                        channel.send_to(range_at_heading_message.encode_message())

                        # push periodic message to the bot
Exemplo n.º 2
0
    # connect the port with the laser and initialize the laser object
    # lasr = OldLaser(lp)
    lasr = Laser(lp)

    #
    #
    slice_index = 0
    file_index = 1
    rotation_time = 0
    current_time = 0
    seconds_per_output = 1
    SECONDS_PER_MINUTE = 60.0
    rotations = []
    while 1:
        try:
            rotation = Rotation(lasr.gather_full_rotation())
            rotations = rotations[-4:]
            rotations.append(rotation)
            # rotation = OldRotation(lasr.gather_full_rotation())
            #
            # For now, we just output a lidar data snapshot every 10 seconds
            # We will want this for debugging (maybe every second instead)
            # change the "seconds_per_output" to tune that.
            #
            tgt_heading, tgt_range = Analyzer.range_at_heading(rotation.polar_data(), (Analyzer.start, Analyzer.stop))
            logger.info(
                "{:d} points yields {:.2f} inches at {:2d} degrees)".format(
                    len(rotation.polar_data()), tgt_range, tgt_heading
                )
            )
Exemplo n.º 3
0
		                #lp = serial.Serial('/dev/tty.wchusbserial1420',115200,timeout=1)
                                lp = serial.Serial(serial_port_name, 115200, timeout=1)
                                lasr = Laser(lp)
                        except: 
                                logger.critical('Unable to open lidar port: {}'.format(serial_port_name))
                                logger.critical('Try /dev/ttyUSB0, or maybe /dev/tty.wchusbserial1420, or maybe /dev/tty.usbserial')
                                periodic_message.status = 'down'
                                periodic_message.rpm = 0
                                if not suppress_robot_comm:
                                        channel.send_to(periodic_message.encode_message())
                                logger.error('Lidar port could not be opened.')

                if lasr is not None:
                        try:
                                # NOTE: because lidar is upside down, this needs to be reversed?
                                rotation = Rotation(lasr.gather_full_rotation(reverse_data=True))
                                
                                #
                                # For now, we just output a lidar data snapshot every 10 seconds
                                # We will want this for debugging (maybe every second instead)
                                # change the "seconds_per_output" to tune that.
                                #
                                tgt_heading, tgt_range = Analyzer.range_at_heading(rotation.polar_data(), (Analyzer.start, Analyzer.stop))
                                logger.info("{:d} points yields {:.2f} inches at {:2d} degrees)".format(len(rotation.polar_data()),tgt_range, tgt_heading))
                        
                                # push the newly calculated data into the message
                                range_at_heading_message.heading = tgt_heading
                                range_at_heading_message.range = tgt_range
                                if not suppress_robot_comm:
                                        channel.send_to(range_at_heading_message.encode_message())