navigate_to_position()
- 1 Minute to read
navigate_to_position()
- 1 Minute to read
Article summary
Did you find this summary helpful?
Thank you for your feedback
navigate_to_position()
This function allows you to navigate to the desired goal destination in an autonomous way.
Reference
Arguments
Arguments
Arguments | Type | Default value | |
---|---|---|---|
x | float | x coordinate on the map | |
y | float | y coordinate on the map | |
angle | float | target angle | |
pos_unit | POS_UNIT | POS_UNIT.PIXEL | ENUM 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_unit | ANG_UNIT | ANG_UNIT.DEG | ENUM to determine whether angle should be returned as radians(ANG_UNIT.RAD ) or degrees (ANG_UNIT.DEG ) |
callback_feedback | callable | None | function that is being called during the navigation process and updates about the navigation status |
callback_finish | callable | None | function that is being called when navigation finish |
wait | bool | False | blocks the application until the robot finishes its navigation to the position |
Callbacks
callback_feedback
key | Type |
---|---|
state | str |
distance_to_goal | double |
speed | double |
callback_finish
key | Type |
---|---|
error | int |
error_msg | str |
### Return |
Return
None
Exceptions
Exception | Condition |
---|---|
RayaNavNotLocated | The robot is not located in the map. |
RayaNotMoving | The 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?