mapping.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:occ_grid_map 作者: ku-ya 项目源码 文件源码
def to_message(self):
        """ Return a nav_msgs/OccupancyGrid representation of this map. """

        grid_msg = OccupancyGrid()

        # Set up the header.
        grid_msg.header.stamp = rospy.Time.now()
        grid_msg.header.frame_id = "map"

        # .info is a nav_msgs/MapMetaData message.
        grid_msg.info.resolution = self.resolution
        grid_msg.info.width = self.width
        grid_msg.info.height = self.height

        # Rotated maps are not supported... quaternion represents no
        # rotation.
        grid_msg.info.origin = Pose(Point(self.origin_x, self.origin_y, 0.),
                               Quaternion(0., 0., 0., 1.))

        # Flatten the numpy array into a list of integers from 0-100.
        # This assumes that the grid entries are probalities in the
        # range 0-1. This code will need to be modified if the grid
        # entries are given a different interpretation (like
        # log-odds).
        flat_grid = self.grid.reshape((self.grid.size,)) * 100.
        grid_msg.data = list(np.round(flat_grid, decimals = 3))
        return grid_msg
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号