Skip to content

Commit

Permalink
Configurable pickup zones
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
  • Loading branch information
aaronchongth committed Aug 30, 2023
1 parent de73d83 commit a714a74
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/dashboard/src/components/appbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ export const AppBar = React.memo(({ extraToolbarItems }: AppBarProps): React.Rea
user={username ? username : 'unknown user'}
patrolWaypoints={waypointNames}
cleaningZones={cleaningZoneNames}
pickupZones={resourceManager?.pickupZones}
pickupPoints={pickupPoints}
dropoffPoints={dropoffPoints}
favoritesTasks={favoritesTasks}
Expand Down
3 changes: 3 additions & 0 deletions packages/dashboard/src/managers/resource-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface ResourceConfigurationsType {
logos?: Record<string, LogoResource>;
helpLink?: string;
reportIssue?: string;
pickupZones?: string[];
}

export default class ResourceManager {
Expand All @@ -20,6 +21,7 @@ export default class ResourceManager {
dispensers?: DispenserResourceManager;
helpLink: string;
reportIssue: string;
pickupZones?: string[];

/**
* Gets the default resource manager using the embedded resource file (aka "assets/resources/main.json").
Expand Down Expand Up @@ -53,6 +55,7 @@ export default class ResourceManager {
*/
this.helpLink = resources.helpLink || 'https://osrf.github.io/ros2multirobotbook/rmf-core.html';
this.reportIssue = resources.reportIssue || 'https://github.com/open-rmf/rmf-web/issues';
this.pickupZones = resources.pickupZones || [];
}
}

Expand Down
42 changes: 41 additions & 1 deletion packages/react-components/lib/tasks/create-task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ interface DeliveryTaskDescription {
interface PickupActivity {
category: string;
description: {
pickup_zone: string;
cart_rfid: number;
};
}
Expand Down Expand Up @@ -279,15 +280,22 @@ function DeliveryTaskForm({

interface DeliveryHuntingProps {
taskDesc: DeliveryHuntingTaskDescription;
pickupZones: string[];
dropoffPoints: string[];
onChange(taskDesc: TaskDescription): void;
}

function DeliveryHuntingTaskForm({ taskDesc, dropoffPoints = [], onChange }: DeliveryHuntingProps) {
function DeliveryHuntingTaskForm({
taskDesc,
pickupZones = [],
dropoffPoints = [],
onChange,
}: DeliveryHuntingProps) {
const theme = useTheme();
const pickup_activity: PickupActivity = {
category: 'perform_action',
description: {
pickup_zone: '',
cart_rfid: 0,
},
};
Expand All @@ -300,6 +308,32 @@ function DeliveryHuntingTaskForm({ taskDesc, dropoffPoints = [], onChange }: Del

return (
<Grid container spacing={theme.spacing(2)} justifyContent="center" alignItems="center">
<Grid item xs={8}>
<Autocomplete
id="pickup-zone"
freeSolo
fullWidth
options={pickupZones}
onChange={(_ev, newValue) => {
if (newValue === null) {
return;
}
pickup_activity.description.pickup_zone = newValue;
onChange({
...taskDesc,
activities: [pickup_activity, dropoff_activity],
});
}}
onBlur={(ev) => {
pickup_activity.description.pickup_zone = (ev.target as HTMLInputElement).value;
onChange({
...taskDesc,
activities: [pickup_activity, dropoff_activity],
});
}}
renderInput={(params) => <TextField {...params} label="Pickup Zone" />}
/>
</Grid>
<Grid item xs={4}>
<TextField
id="cart_rfid"
Expand Down Expand Up @@ -435,6 +469,7 @@ function defaultDeliveryHuntingTask(): DeliveryHuntingTaskDescription {
{
category: 'perform_action',
description: {
pickup_zone: '',
cart_rfid: 0,
},
},
Expand Down Expand Up @@ -549,6 +584,7 @@ export interface CreateTaskFormProps
allowBatch?: boolean;
cleaningZones?: string[];
patrolWaypoints?: string[];
pickupZones?: string[];

Check warning on line 587 in packages/react-components/lib/tasks/create-task.tsx

View workflow job for this annotation

GitHub Actions / Unit Tests

'cleaningZones' is assigned a value but never used
pickupPoints?: Record<string, string>;

Check warning on line 588 in packages/react-components/lib/tasks/create-task.tsx

View workflow job for this annotation

GitHub Actions / Unit Tests

'patrolWaypoints' is assigned a value but never used
dropoffPoints?: Record<string, string>;
favoritesTasks: TaskFavorite[];
Expand All @@ -568,6 +604,7 @@ export function CreateTaskForm({
user,
cleaningZones = [],
patrolWaypoints = [],
pickupZones = [],
pickupPoints = {},
dropoffPoints = {},
favoritesTasks = [],
Expand Down Expand Up @@ -663,6 +700,7 @@ export function CreateTaskForm({
return (
<DeliveryHuntingTaskForm
taskDesc={taskRequest.description as DeliveryHuntingTaskDescription}
pickupZones={pickupZones}
dropoffPoints={Object.values(dropoffPoints)}
onChange={(desc) => handleTaskDescriptionChange('delivery_sequential_hunting', desc)}
/>
Expand All @@ -671,6 +709,7 @@ export function CreateTaskForm({
return (
<DeliveryHuntingTaskForm
taskDesc={taskRequest.description as DeliveryHuntingTaskDescription}
pickupZones={pickupZones}
dropoffPoints={Object.values(dropoffPoints)}
onChange={(desc) => handleTaskDescriptionChange('delivery_area_hunting', desc)}
/>
Expand Down Expand Up @@ -705,6 +744,7 @@ export function CreateTaskForm({
for (const t of taskRequests) {
t.requester = requester;
t.unix_millis_request_time = Date.now();
console.log(t);
}

const submittingSchedule = scheduling && scheduleEnabled;
Expand Down

0 comments on commit a714a74

Please sign in to comment.