import rospy from nav_msgs.msg import OccupancyGrid def callback(data): # Print the dimensions of the grid print("Grid dimensions:", data.info.height, "x", data.info.width) # Access the occupancy data for a specific cell index = 5 + 10*data.info.width # example index occupancy = data.data[index] print("Occupancy at cell", index, ":", occupancy) rospy.init_node('listener') rospy.Subscriber("map", OccupancyGrid, callback) rospy.spin()In this code, we subscribe to the "map" topic that contains the OccupancyGrid message. When a message is received, the `callback` function is called, which accesses various properties of the OccupancyGrid message, such as its dimensions and occupancy data for specific cells. The package library used in this example is the `rospy` library, which is part of the ROS (Robot Operating System) framework for robotics applications. The `nav_msgs` package is also part of ROS and contains various message types used for navigation and mapping.