Skip to content

Commit

Permalink
Allow users to customize the stow configuration (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
amalnanavati authored Aug 14, 2024
1 parent 2dc2dfe commit 1d295fc
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
1 change: 1 addition & 0 deletions feedingwebapp/src/Pages/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export const STAGING_PARAM_ORIENTATION = 'MoveFromMouth.tree_kwargs.staging_conf
export const RESTING_PARAM_JOINTS_1 = 'AcquireFood.tree_kwargs.resting_joint_positions'
// TODO: We may need to remove the orientation constraint from the below action.
export const RESTING_PARAM_JOINTS_2 = 'MoveToRestingPosition.tree_kwargs.goal_configuration'
export const STOW_PARAM_JOINTS = 'MoveToStowLocation.tree_kwargs.joint_positions'

// Parameters for modifying the force threshold
export const FORCE_THRESHOLD_PARAM = 'wrench_threshold.fMag'
Expand Down
17 changes: 13 additions & 4 deletions feedingwebapp/src/Pages/GlobalState.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,24 @@ export { NON_MOVING_STATES }
/**
* SETTINGS_STATE controls which settings page to display.
* - MAIN: The main page, with options to navigate to the other pages.
* - BITE_TRANSFER: The bite transfer page, where the user can configure
* parameters for bite transfer.
* - DISTANCE_TO_MOUTH: Allow the user to customize how close the robot gets
* to their mouth.
* - ABOVE_PLATE: Allow the user to customize how high the fixed above plate
* arm configuration.
* - RESTING_CONFIGURATION: Allow the user to customize the fixed resting
* arm configuration.
* - STAGING_CONFIGURATION: Allow the user to customize the fixed staging
* arm configuration.
* - STOW_CONFIGURATION: Allow the user to customize the fixed stow arm
* configuration.
*/
export const SETTINGS_STATE = {
MAIN: 'MAIN',
BITE_TRANSFER: 'BITE_TRANSFER',
DISTANCE_TO_MOUTH: 'DISTANCE_TO_MOUTH',
ABOVE_PLATE: 'ABOVE_PLATE',
RESTING_CONFIGURATION: 'RESTING_CONFIGURATION',
STAGING_CONFIGURATION: 'STAGING_CONFIGURATION'
STAGING_CONFIGURATION: 'STAGING_CONFIGURATION',
STOW_CONFIGURATION: 'STOW_CONFIGURATION'
}

// The name of the default parameter namespace
Expand Down
12 changes: 9 additions & 3 deletions feedingwebapp/src/Pages/Settings/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,14 @@ const Main = () => {
let moveAbovePlateConfigurationImage = MOVING_STATE_ICON_DICT[MEAL_STATE.R_MovingAbovePlate]
let moveToRestingConfigurationImage = MOVING_STATE_ICON_DICT[MEAL_STATE.R_MovingToRestingPosition]
let moveToStagingConfigurationImage = MOVING_STATE_ICON_DICT[MEAL_STATE.R_MovingToStagingConfiguration]
let moveToStowConfigurationImage = MOVING_STATE_ICON_DICT[MEAL_STATE.R_StowingArm]

// Configure the different options in the settings menu
let settingsConfig = [
{
title: 'Bite Transfer',
title: 'Distance to Mouth',
icon: moveToMouthConfigurationImage,
onClick: () => onClickSettingsPage(SETTINGS_STATE.BITE_TRANSFER)
onClick: () => onClickSettingsPage(SETTINGS_STATE.DISTANCE_TO_MOUTH)
},
{
title: 'Above Plate',
Expand All @@ -180,6 +181,11 @@ const Main = () => {
title: 'Staging Position',
icon: moveToStagingConfigurationImage,
onClick: () => onClickSettingsPage(SETTINGS_STATE.STAGING_CONFIGURATION)
},
{
title: 'Stow Position',
icon: moveToStowConfigurationImage,
onClick: () => onClickSettingsPage(SETTINGS_STATE.STOW_CONFIGURATION)
}
]

Expand Down Expand Up @@ -239,7 +245,7 @@ const Main = () => {
<Button
variant='outline-dark'
style={{
fontSize: '30px',
fontSize: '25px',
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
Expand Down
26 changes: 23 additions & 3 deletions feedingwebapp/src/Pages/Settings/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
RESTING_PARAM_JOINTS_2,
STAGING_PARAM_JOINTS,
STAGING_PARAM_ORIENTATION,
STAGING_PARAM_POSITION
STAGING_PARAM_POSITION,
STOW_PARAM_JOINTS
} from '../Constants'

/**
Expand All @@ -34,13 +35,14 @@ const Settings = (props) => {
const abovePlateParamNames = useMemo(() => [ABOVE_PLATE_PARAM_JOINTS], [])
const restingParamNames = useMemo(() => [RESTING_PARAM_JOINTS_1, RESTING_PARAM_JOINTS_2], [])
const stagingParamNames = useMemo(() => [STAGING_PARAM_JOINTS, STAGING_PARAM_POSITION, STAGING_PARAM_ORIENTATION], [])
const stowParamNames = useMemo(() => [STOW_PARAM_JOINTS], [])

const getComponentBySettingsState = useCallback(() => {
console.log('getComponentBySettingsState', settingsState)
switch (settingsState) {
case SETTINGS_STATE.MAIN:
return <Main />
case SETTINGS_STATE.BITE_TRANSFER:
case SETTINGS_STATE.DISTANCE_TO_MOUTH:
return <BiteTransfer webrtcURL={props.webrtcURL} />
case SETTINGS_STATE.ABOVE_PLATE:
return (
Expand Down Expand Up @@ -118,11 +120,29 @@ const Settings = (props) => {
webrtcURL={props.webrtcURL}
/>
)
case SETTINGS_STATE.STOW_CONFIGURATION:
return (
<CustomizeConfiguration
startingMealState={MEAL_STATE.R_StowingArm}
paramNames={stowParamNames}
getEndEffectorPose={false}
getParamValues={[getJointPositionsFromRobotStateResponse]}
configurationName='Stow Position'
buttonName='Stow Arm'
otherButtonConfigs={[
{
name: 'Move Above Plate',
mealState: MEAL_STATE.R_MovingAbovePlate
}
]}
webrtcURL={props.webrtcURL}
/>
)
default:
console.log('Invalid settings state', settingsState)
return <Main />
}
}, [abovePlateParamNames, restingParamNames, stagingParamNames, props.webrtcURL, settingsState])
}, [abovePlateParamNames, restingParamNames, stagingParamNames, stowParamNames, props.webrtcURL, settingsState])

// Render the component
return (
Expand Down

0 comments on commit 1d295fc

Please sign in to comment.