navigate_to_position()
  • 1 Minute to read

navigate_to_position()


Article Summary

This function allows you to navigate to the desired goal destination in an autonomous way.

Reference

Arguments

Arguments

ArgumentsTypeDefault value
xfloatx coordinate on the map
yfloaty coordinate on the map
anglefloattarget angle
pos_unitPOS_UNITPOS_UNIT.PIXELENUM to determine whether the x,y values should be returned as pixels of the map image (POS_UNIT.PIXEL) or Cartesian position in meters (POS_UNIT.METERS)
ang_unitANG_UNITANG_UNIT.DEGENUM to determine whether angle should be returned as radians(ANG_UNIT.RAD) or degrees (ANG_UNIT.DEG)
callback_feedbackcallableNonefunction that is being called during the navigation process and updates about the navigation status
callback_finishcallableNonefunction that is being called when navigation finish
waitboolFalseblocks the application until the robot finishes its navigation to the position

Callbacks

callback_feedback

keyType
statestr
distance_to_goaldouble
speeddouble

callback_finish

keyType
errorint
error_msgstr
### Return

Return

None

Exceptions

ExceptionCondition
RayaNavNotLocatedThe robot is not located in the map.
RayaNotMovingThe robot is already moving.

Example

Important note!

Please pay attention to enable_navigation(map_name) function under the setup() section. Without that function, navigation will not be allowed.

Code:

...
class RayaApplication(RayaApplicationBase):

    async def setup(self):
        self.navigation = await self.enable_controller('navigation')
       
        # You must enable navigation first by passing the map name. Without this line, navigation will not be allowed.
        await self.navigation.enable_navigation('unity_apartment')
        ...

    async def loop(self):
        ...
            try:
                await self.navigation.navigate_to_position( x=5, 
                                                            y=20, 
                                                            angle=50,
                                                            pos_unit = POS_UNIT.PIXEL, 
                                                            ang_unit = ANG_UNIT.DEG
                                                        )
            except:
                self.log.error('Cancel current navigation before request a new one...')

    async def finish(self):
       ...

Was this article helpful?