get_map()
  • 1 Minute to read

get_map()


Article summary

get_map()

Get a specific map.

Reference

Arguments

String - Name of the map.

Return

Returns an array representing the map and a dictionary describing the map meta data (like resolution of the map).

Exceptions

ExceptionCondition
RayaNavNotLocatedThe robot is not located on the map.
RayaNavUnkownErrorAn unknown error occurs.

See the complete list of Raya Exceptions.

Example

In this example, we are showing the position of the robot over the chosen map.

...

class RayaApplication(RayaApplicationBase):

    async def setup(self):
        self.flag = False
        self.navigation = await self.enable_controller('navigation')
        self.map_image, self.map_info = await self.navigation.get_map('unity_apartment')
        ....
    async def loop(self):
       robot_position = self.navigation.get_position(pos_unit = POS_UNIT.PIXEL, ang_unit = ANG_UNIT.RAD)
       img = self.map_image.copy()
        x_pixel  = robot_position["x"]
        y_pixel  = robot_position["y"]
        rotation = robot_position["angle"]
        x_line   =  x_pixel + int(7 * math.cos(-rotation))
        y_line   =  y_pixel + int(7 * math.sin(-rotation))
        cv2.circle(img, (x_pixel, y_pixel), 8, (255,0,0), 2)      
        cv2.line(img, (x_pixel, y_pixel), (x_line, y_line), (0,0,255), 4)

        #Show the map, with the position of the robot
        cv2.imshow("map", img)
      ...   
    async def finish(self):
      ...

Was this article helpful?

What's Next