Exemplo n.º 1
0
            #
            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
            periodic_message.status = "ok"
            periodic_message.rpm = rotation.rpm()
            channel.send_to(periodic_message.encode_message())

        except IOError, e:
            #  log and notify robot of error
            periodic_message.status = "error"
            channel.send_to(periodic_message.encode_message())
            logger.error("Failed to gather a full rotation of data.")

        #
        # get revised instructions from robot
        #
        try:
            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"):
Exemplo n.º 2
0
                                # 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())
                                
                                # push periodic message to the bot
                                periodic_message.status = 'ok'
                                periodic_message.rpm = rotation.rpm()
                                if not suppress_robot_comm:
                                        channel.send_to(periodic_message.encode_message())
                                logger.info("reported rpm is {:d}".format(rotation.rpm()))

                                #
                                # send out the wall heading and distance report  (disabled)
                                #
                                if 0:
                                        (wall_heading, wall_distance, wall_orientation) = find_wall_midpoint(rotation.cartesian_data())
                                        logger.info("find_wall_midpoint => heading {:.1f}, range {:.1f}, orientation {:.1f})".format(wall_heading, wall_distance, wall_orientation))
                                        if (wall_heading, wall_distance, wall_orientation) == (0, 0, 0):
                                                wall_message.status = 'error'
                                        else:
                                                wall_message.status = 'ok'
                                                wall_message.range = wall_distance