Skip to content

Commit 9fbeac5

Browse files
committed
Fixes from testing
1 parent 72c8389 commit 9fbeac5

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed
Lines changed: 13 additions & 0 deletions
Loading

feedingwebapp/src/Pages/Constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ MOVING_STATE_ICON_DICT[MEAL_STATE.R_MovingFromMouth] = '/robot_state_imgs/move_t
2929
MOVING_STATE_ICON_DICT[MEAL_STATE.R_MovingToMouth] = '/robot_state_imgs/move_to_mouth_position.svg'
3030
MOVING_STATE_ICON_DICT[MEAL_STATE.R_StowingArm] = '/robot_state_imgs/stowing_arm_position.svg'
3131
export { MOVING_STATE_ICON_DICT }
32+
export const TABLE_ICON = '/robot_state_imgs/table.svg'
3233

3334
// The names of the ROS topic(s)
3435
export const CAMERA_FEED_TOPIC = '/local/camera/color/image_raw/compressed'
@@ -122,7 +123,7 @@ export const GET_PARAMETERS_SERVICE_NAME = 'ada_feeding_action_servers/get_param
122123
export const GET_PARAMETERS_SERVICE_TYPE = 'rcl_interfaces/srv/GetParameters'
123124
export const SET_PARAMETERS_SERVICE_NAME = 'ada_feeding_action_servers/set_parameters_atomically'
124125
export const SET_PARAMETERS_SERVICE_TYPE = 'rcl_interfaces/srv/SetParametersAtomically'
125-
export const PLANNING_SCENE_GET_PARAMETERS_SERVICE_NAME = 'ada_feeding_action_servers/get_parameters'
126+
export const PLANNING_SCENE_GET_PARAMETERS_SERVICE_NAME = 'ada_planning_scene/get_parameters'
126127
export const PLANNING_SCENE_GET_PARAMETERS_SERVICE_TYPE = 'rcl_interfaces/srv/GetParameters'
127128

128129
// The names of parameters users can change in the settings menu

feedingwebapp/src/Pages/Settings/Main.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import {
2020
MOVING_STATE_ICON_DICT,
2121
REGULAR_CONTAINER_ID,
2222
SET_PARAMETERS_SERVICE_NAME,
23-
SET_PARAMETERS_SERVICE_TYPE
23+
SET_PARAMETERS_SERVICE_TYPE,
24+
TABLE_ICON
2425
} from '../Constants'
2526

2627
/**
@@ -189,7 +190,7 @@ const Main = () => {
189190
},
190191
{
191192
title: 'Planning Scene',
192-
icon: null,
193+
icon: TABLE_ICON,
193194
onClick: () => onClickSettingsPage(SETTINGS_STATE.PLANNING_SCENE)
194195
}
195196
]

feedingwebapp/src/Pages/Settings/PlanningScene.jsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// React imports
22
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
3-
import { useMediaQuery } from 'react-responsive'
43
import ButtonGroup from 'react-bootstrap/ButtonGroup'
54
import Dropdown from 'react-bootstrap/Dropdown'
65
import DropdownButton from 'react-bootstrap/DropdownButton'
@@ -20,10 +19,6 @@ const PlanningScene = () => {
2019
// Get relevant global state variables
2120
const setSettingsState = useGlobalState((state) => state.setSettingsState)
2221

23-
// Flag to check if the current orientation is portrait
24-
const isPortrait = useMediaQuery({ query: '(orientation: portrait)' })
25-
// Indicator of how to arrange screen elements based on orientation
26-
let dimension = isPortrait ? 'column' : 'row'
2722
// Rendering variables
2823
let textFontSize = '3.5vh'
2924

@@ -42,19 +37,24 @@ const PlanningScene = () => {
4237
createROSService(ros.current, PLANNING_SCENE_GET_PARAMETERS_SERVICE_NAME, PLANNING_SCENE_GET_PARAMETERS_SERVICE_TYPE)
4338
)
4439
const [planningSceneNamespaces, setPlanningSceneNamespaces] = useState([])
45-
useEffect(() => {
40+
const getPlanningSceneNamespaces = useCallback(() => {
4641
let service = getParametersService.current
4742
let request = createROSServiceRequest({
4843
names: ['namespaces']
4944
})
45+
console.log('PlanningScene: Requesting planning scene namespaces', service, request)
5046
service.callService(request, (response) => {
47+
console.log('PlanningScene: Received planning scene namespaces', request, response)
5148
if (response.values.length > 0 && response.values[0].type === 9) {
5249
setPlanningSceneNamespaces(getValueFromParameter(response.values[0]))
5350
} else {
5451
console.error('PlanningScene: Error getting planning scene namespaces')
5552
}
5653
})
5754
}, [getParametersService, setPlanningSceneNamespaces])
55+
useEffect(() => {
56+
getPlanningSceneNamespaces()
57+
}, [getPlanningSceneNamespaces])
5858

5959
// Render the settings for the planning scene
6060
const renderPlanningSceneSettings = useCallback(() => {
@@ -79,13 +79,14 @@ const PlanningScene = () => {
7979
<View
8080
style={{
8181
flex: 1,
82-
flexDirection: dimension,
82+
flexDirection: 'column',
8383
justifyContent: 'center',
8484
alignItems: 'center',
8585
width: '100%',
8686
height: '100%'
8787
}}
8888
>
89+
<h5 style={{ textAlign: 'center', fontSize: textFontSize }}>Select Planning Scene:</h5>
8990
<DropdownButton
9091
as={ButtonGroup}
9192
key='planningSceneOptions'
@@ -94,6 +95,11 @@ const PlanningScene = () => {
9495
variant='secondary'
9596
title={currentParams[0]}
9697
size='lg'
98+
onClick={() => {
99+
if (planningSceneNamespaces.length === 0) {
100+
getPlanningSceneNamespaces()
101+
}
102+
}}
97103
>
98104
{planningSceneNamespaces.map((namespace) => (
99105
<Dropdown.Item key={namespace} onClick={() => setCurrentParams([namespace])} active={namespace === currentParams[0]}>
@@ -104,7 +110,7 @@ const PlanningScene = () => {
104110
</View>
105111
)
106112
}
107-
}, [currentParams, dimension, planningSceneNamespaces, setCurrentParams, textFontSize])
113+
}, [currentParams, planningSceneNamespaces, getPlanningSceneNamespaces, setCurrentParams, textFontSize])
108114

109115
return (
110116
<SettingsPageParent

0 commit comments

Comments
 (0)