Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hammer/generic alerts without location #951

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 0 additions & 122 deletions packages/api-client/lib/openapi/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9131,64 +9131,6 @@ export const TasksApiAxiosParamCreator = function (configuration?: Configuration
options: localVarRequestOptions,
};
},
/**
* Warning: This endpoint is still actively being worked on and could be subjected to modifications.
* @summary Location Complete
* @param {string} taskId
* @param {string} location
* @param {boolean} success
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
locationCompleteTasksLocationCompletePost: async (
taskId: string,
location: string,
success: boolean,
options: AxiosRequestConfig = {},
): Promise<RequestArgs> => {
// verify required parameter 'taskId' is not null or undefined
assertParamExists('locationCompleteTasksLocationCompletePost', 'taskId', taskId);
// verify required parameter 'location' is not null or undefined
assertParamExists('locationCompleteTasksLocationCompletePost', 'location', location);
// verify required parameter 'success' is not null or undefined
assertParamExists('locationCompleteTasksLocationCompletePost', 'success', success);
const localVarPath = `/tasks/location_complete`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;

if (taskId !== undefined) {
localVarQueryParameter['task_id'] = taskId;
}

if (location !== undefined) {
localVarQueryParameter['location'] = location;
}

if (success !== undefined) {
localVarQueryParameter['success'] = success;
}

setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers,
};

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Post Activity Discovery
Expand Down Expand Up @@ -10236,30 +10178,6 @@ export const TasksApiFp = function (configuration?: Configuration) {
);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
* Warning: This endpoint is still actively being worked on and could be subjected to modifications.
* @summary Location Complete
* @param {string} taskId
* @param {string} location
* @param {boolean} success
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async locationCompleteTasksLocationCompletePost(
taskId: string,
location: string,
success: boolean,
options?: AxiosRequestConfig,
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<any>> {
const localVarAxiosArgs =
await localVarAxiosParamCreator.locationCompleteTasksLocationCompletePost(
taskId,
location,
success,
options,
);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @summary Post Activity Discovery
Expand Down Expand Up @@ -10764,25 +10682,6 @@ export const TasksApiFactory = function (
.getTaskStateTasksTaskIdStateGet(taskId, options)
.then((request) => request(axios, basePath));
},
/**
* Warning: This endpoint is still actively being worked on and could be subjected to modifications.
* @summary Location Complete
* @param {string} taskId
* @param {string} location
* @param {boolean} success
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
locationCompleteTasksLocationCompletePost(
taskId: string,
location: string,
success: boolean,
options?: any,
): AxiosPromise<any> {
return localVarFp
.locationCompleteTasksLocationCompletePost(taskId, location, success, options)
.then((request) => request(axios, basePath));
},
/**
*
* @summary Post Activity Discovery
Expand Down Expand Up @@ -11247,27 +11146,6 @@ export class TasksApi extends BaseAPI {
.then((request) => request(this.axios, this.basePath));
}

/**
* Warning: This endpoint is still actively being worked on and could be subjected to modifications.
* @summary Location Complete
* @param {string} taskId
* @param {string} location
* @param {boolean} success
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof TasksApi
*/
public locationCompleteTasksLocationCompletePost(
taskId: string,
location: string,
success: boolean,
options?: AxiosRequestConfig,
) {
return TasksApiFp(this.configuration)
.locationCompleteTasksLocationCompletePost(taskId, location, success, options)
.then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary Post Activity Discovery
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/lib/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { version as rmfModelVer } from 'rmf-models';

export const version = {
rmfModels: rmfModelVer,
rmfServer: 'b7c04a5019c749e898e3f59af95e43db1087a70d',
rmfServer: 'eb83039e43d7caee62ea130adf1f73b24d8465e6',
openapiGenerator: '6.2.1',
};
41 changes: 0 additions & 41 deletions packages/api-client/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1380,47 +1380,6 @@ export default {
},
},
},
'/tasks/location_complete': {
post: {
tags: ['Tasks'],
summary: 'Location Complete',
description:
'Warning: This endpoint is still actively being worked on and could be\nsubjected to modifications.',
operationId: 'location_complete_tasks_location_complete_post',
parameters: [
{
required: true,
schema: { title: 'Task Id', type: 'string' },
name: 'task_id',
in: 'query',
},
{
required: true,
schema: { title: 'Location', type: 'string' },
name: 'location',
in: 'query',
},
{
required: true,
schema: { title: 'Success', type: 'boolean' },
name: 'success',
in: 'query',
},
],
responses: {
'200': {
description: 'Successful Response',
content: { 'application/json': { schema: {} } },
},
'422': {
description: 'Validation Error',
content: {
'application/json': { schema: { $ref: '#/components/schemas/HTTPValidationError' } },
},
},
},
},
},
'/scheduled_tasks': {
get: {
tags: ['Tasks'],
Expand Down
49 changes: 27 additions & 22 deletions packages/api-server/api_server/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from .models import (
AlertParameter,
AlertRequest,
AlertResponse,
BeaconState,
BuildingMap,
DeliveryAlert,
Expand All @@ -51,14 +52,7 @@
LiftState,
)
from .models.delivery_alerts import action_from_msg, category_from_msg, tier_from_msg
from .repositories import (
CachedFilesRepository,
LocationAlertFailResponse,
LocationAlertSuccessResponse,
cached_files_repo,
is_final_location_alert_check,
task_id_to_all_locations_success_cache,
)
from .repositories import CachedFilesRepository, cached_files_repo
from .rmf_io import alert_events, rmf_events
from .ros import ros_node

Expand Down Expand Up @@ -297,20 +291,6 @@ def convert_fleet_alert(fleet_alert: RmfFleetAlert):
def handle_fleet_alert(fleet_alert: AlertRequest):
logging.info("Received fleet alert:")
logging.info(fleet_alert)

# Handle request for checking all location completion success for
# this task
is_final_check = is_final_location_alert_check(fleet_alert)
if is_final_check:
successful_so_far = task_id_to_all_locations_success_cache.lookup(
fleet_alert.task_id
)
if successful_so_far is None or not successful_so_far:
self.respond_to_alert(fleet_alert.id, LocationAlertFailResponse)
else:
self.respond_to_alert(fleet_alert.id, LocationAlertSuccessResponse)
return

alert_events.alert_requests.on_next(fleet_alert)

fleet_alert_sub = ros_node().create_subscription(
Expand All @@ -326,6 +306,31 @@ def handle_fleet_alert(fleet_alert: AlertRequest):
)
self._subscriptions.append(fleet_alert_sub)

def convert_fleet_alert_response(fleet_alert_response: RmfFleetAlertResponse):
return AlertResponse(
id=fleet_alert_response.id,
unix_millis_response_time=round(datetime.now().timestamp() * 1000),
response=fleet_alert_response.response,
)

def handle_fleet_alert_response(alert_response: AlertResponse):
logging.info("Received alert response:")
logging.info(alert_response)
alert_events.alert_responses.on_next(alert_response)

fleet_alert_response_sub = ros_node().create_subscription(
RmfFleetAlertResponse,
"fleet_alert_response",
lambda msg: handle_fleet_alert_response(convert_fleet_alert_response(msg)),
rclpy.qos.QoSProfile(
history=rclpy.qos.HistoryPolicy.KEEP_LAST,
depth=10,
reliability=rclpy.qos.ReliabilityPolicy.RELIABLE,
durability=rclpy.qos.DurabilityPolicy.TRANSIENT_LOCAL,
),
)
self._subscriptions.append(fleet_alert_response_sub)

def handle_fire_alarm_trigger(fire_alarm_trigger_msg: BoolMsg):
if fire_alarm_trigger_msg.data:
logging.info("Fire alarm triggered")
Expand Down
8 changes: 8 additions & 0 deletions packages/api-server/api_server/models/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ class AlertResponse(BaseModel):
def from_tortoise(tortoise: ttm.AlertResponse) -> "AlertResponse":
return AlertResponse(**tortoise.data)

async def save(self) -> None:
await ttm.AlertResponse.update_or_create(
{
"data": self.json(),
},
id=self.id,
)


class AlertRequest(BaseModel):
class Tier(str, Enum):
Expand Down
8 changes: 1 addition & 7 deletions packages/api-server/api_server/repositories/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
from .alerts import (
AlertRepository,
LocationAlertFailResponse,
LocationAlertSuccessResponse,
is_final_location_alert_check,
task_id_to_all_locations_success_cache,
)
from .alerts import AlertRepository
from .cached_files import CachedFilesRepository, cached_files_repo
from .fleets import FleetRepository
from .rmf import RmfRepository
Expand Down
Loading
Loading