Area Callback Region Handler Base

exception bosdyn.client.area_callback_region_handler_base.PathBlocked[source]

Bases: Exception

The callback reports the that path/area it’s trying to traverse is blocked and the robot should take another route or action.

exception bosdyn.client.area_callback_region_handler_base.IncorrectUsage[source]

Bases: Exception

Error raised by calling a helper function incorrectly.

Raised when a call would block forever or has otherwise been used in an incorrect manner. This exception is not intended to be caught, but indicates a programming error.

exception bosdyn.client.area_callback_region_handler_base.HandlerError[source]

Bases: Exception

Error base class for errors raised from the internals of the AreaCallbackRegionHandlerBase.

This error will be raised when the shutdown_event signal is set, or can be raised by the user to signal an error. A wrapper around the run implementation will catch this exception and report back to a client a UpdateCallbackResponse error.

exception bosdyn.client.area_callback_region_handler_base.CallbackEnded[source]

Bases: HandlerError

The callback has already been stopped, via an EndCallback call.

exception bosdyn.client.area_callback_region_handler_base.CallbackTimedOutError[source]

Bases: HandlerError

The callback has already been stopped, via passing the end time. If caught, it should be re-raised to make sure the response is set correctly.

class bosdyn.client.area_callback_region_handler_base.RouteChangedResult[source]

Bases: object

Options for how the helper class should respond to a route change.

class bosdyn.client.area_callback_region_handler_base.AreaCallbackRegionHandlerBase(config: AreaCallbackServiceConfig, robot: Robot)[source]

Bases: object

Base class for implementing a AreaCallbackRegionHandler.

A AreaCallbackRegionHandler is an object responsible for running a single instance of an AreaCallback. The AreaCallbackServiceServicer will construct an AreaCallbackRegionHandler object each time GraphNav starts an Area Callback region. The servicer will execute the run() function in a thread and read update_response to send status back to the client. After EndCallback, this object will be discarded and a new AreaCallbackRegionHandlerBase will be constructed to handle the next region.

Parameters:
  • config – The AreaCallbackServiceConfig defining the data for the AreaCallbackInformation response.

  • robot – The Robot object used to create service clients.

begin(request: BeginCallbackRequest) <google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper object at 0x72c3ce36de40>[source]

Validates that configuration passed to BeginCallback is valid.

Parameters:

request (area_callback_pb2.BeginCallbackRequest) – The BeginCallback request.

Returns:

OK when configuration_data is valid.

Return type:

area_callback_pb2.BeginCallbackResponse.Status

run()[source]

This function is run on a worker thread after BeginCallback is called.

end()[source]

This function is called after run thread has finished and client calls EndCallback.

route_changed(request: RouteChangeRequest) RouteChangedResult[source]

This function is called when Graph Nav re-routes inside the callback region. In most cases, the callback does not need to do anything for this case and can leave the default implementation

property area_callback_information: AreaCallbackInformation

Get area_callback_pb2.AreaCallbackInformation.

property config: AreaCallbackServiceConfig

Get AreaCallbackServiceConfig

stop_at_start()[source]

Tell graph nav that it should wait at the start of the region.

continue_past_start()[source]

Tell graph nav that it should continue on past the start of the region.

control_at_start()[source]

Tell graph nav that it transfer control at the start of the region.

stop_at_end()[source]

Tell graph nav that it should wait at the end of the region.

continue_past_end()[source]

Tell graph nav that it should continue on past the ends of the region.

control_at_end()[source]

Tell graph nav that it should transfer control at the end of the region.

set_complete()[source]
set_localization_at_end()[source]

Set the localization hint to the end of the callback region, indicating that graph nav that navigation should continue from this point. Robot control is required to set this. It should be called after walking to the end of the region, but before ceding control.

Raises:

IncorrectUsage – When called without robot control.

block_until_control()[source]

Block waiting for the robot to pass the sublease to this callback.

Raises:

HandlerError – When a shutdown is requested before a lease is received.

has_control()[source]

Check in a non-blocking way if the callback has been given a sublease.

Returns:

True if the callback is now in control of the robot.

block_until_arrived_at_start() bool[source]

Block until the robot arrives at the start of the area callback. If the robot is already past the start, this will return immediately.

Returns:

True if the robot is at the start, False if the robot is already beyond the start.

Raises:
  • HandlerError – When a shutdown is requested before the robot reaches the start of the

  • region.

block_until_arrived_at_end()[source]

Block until the robot arrives at the end of the area callback.

Raises:
  • HandlerError – When a shutdown is requested before the robot reaches the end of the

  • region.

property stage

Check the current stage of traversal in a non-blocking way.

Returns:

bosdyn.api.UpdateCallbackRequest.Stage enum of the current stage of crossing the region.

safe_sleep(sleep_time_secs: float)[source]

Run impl should use this sleep function to make sure thread does not hang.

Parameters:

sleep_time_secs (float) – Time to sleep, in seconds.

Raises:

HandlerError – When a shutdown is requested during the sleep time.

check()[source]

Check if callback shutdown has been requested via client call to EndCallback or passing the end time.

The run thread is responsible for checking and cleanly exiting.

Raises:

HandlerError – If the thread should shut down.

property update_response

Get current UpdateCallbackResponse.

will_get_control()[source]

Determine if the current policy and stage mean that the callback will eventually be given control without any further action on its part

internal_begin_complete()[source]

The handler finished BeginCallback and is ready to start run(). Blocking calls may now be used.

internal_set_stage(stage: <google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper object at 0x72c3ce36c0d0>)[source]

Update the stage via an incoming UpdateCallbackRequest.

internal_set_end_time(end_time: float)[source]

Update the end time from an incoming request.

internal_give_control()[source]

Set Event indicating region handler has been given control. Lease is available in wallet.

internal_run_wrapper(shutdown_event)[source]

Wrapper around the run function which catches exceptions and set update response.

Parameters:

shutdown_event (Event) – Event that signals the run thread to shut down.