diff --git a/src/InitSettings.jsx b/src/InitSettings.jsx index 276250c..c291339 100644 --- a/src/InitSettings.jsx +++ b/src/InitSettings.jsx @@ -23,7 +23,7 @@ const Item = styled(Paper)(({ theme }) => ({ function InitSettings() { const { - GRPC_WEB_API_URL, published, setPublished, setKinematic, setWalking, + GRPC_WEB_API_URL, published, setPublished, setKinematicValue, setWalkingValue, } = useContext(WalkContext); const client = new aruku_interfaces.ConfigClient(GRPC_WEB_API_URL, null, null); @@ -34,8 +34,21 @@ function InitSettings() { if (err) { console.log(`Unexpected error: code = ${err.code}, message = "${err.message}"`); } else { - setKinematic(JSON.parse(response.array[0])); - setWalking(JSON.parse(response.array[1])); + const kinematic = JSON.parse(response.array[0]); + const walking = JSON.parse(response.array[1]); + + Object.keys(kinematic).forEach(name => { + Object.entries(kinematic[name]).forEach(([key, value]) => { + console.log(typeof value); + setKinematicValue(name, key, value); + }); + }) + + Object.keys(walking).forEach(name => { + Object.entries(walking[name]).forEach(([key, value]) => { + setWalkingValue(name, key, value); + }); + }) } }); }; diff --git a/src/WalkSettings.jsx b/src/WalkSettings.jsx index c0b8f7c..1f6faeb 100644 --- a/src/WalkSettings.jsx +++ b/src/WalkSettings.jsx @@ -26,7 +26,7 @@ const Item = styled(Paper)(({ theme }) => ({ function WalkSettings() { const { - GRPC_WEB_API_URL, published, walking, kinematic, setPublished, setKinematic, setWalking, + GRPC_WEB_API_URL, published, walking, kinematic, setPublished, setKinematicValue, setWalkingValue, } = useContext(WalkContext); const client = new aruku_interfaces.ConfigClient(GRPC_WEB_API_URL, null, null); @@ -37,8 +37,21 @@ function WalkSettings() { if (err) { console.log(`Unexpected error: code = ${err.code}, message = "${err.message}"`); } else { - setKinematic(JSON.parse(response.array[0])); - setWalking(JSON.parse(response.array[1])); + const kinematic = JSON.parse(response.array[0]); + const walking = JSON.parse(response.array[1]); + + Object.keys(kinematic).forEach(name => { + Object.entries(kinematic[name]).forEach(([key, value]) => { + console.log(typeof value); + setKinematicValue(name, key, value); + }); + }) + + Object.keys(walking).forEach(name => { + Object.entries(walking[name]).forEach(([key, value]) => { + setWalkingValue(name, key, value); + }); + }) } }); }; diff --git a/src/components/ReloadButton.jsx b/src/components/ReloadButton.jsx index ed609d1..50f4e16 100644 --- a/src/components/ReloadButton.jsx +++ b/src/components/ReloadButton.jsx @@ -7,7 +7,7 @@ import WalkContext from '../context/WalkContext'; function ReloadButton() { const { - GRPC_WEB_API_URL, setPublished, setKinematic, setWalking, + GRPC_WEB_API_URL, setPublished, setKinematicValue, setWalkingValue, } = useContext(WalkContext); const client = new aruku_interfaces.ConfigClient(GRPC_WEB_API_URL, null, null); @@ -21,8 +21,21 @@ function ReloadButton() { if (err) { console.log(`Unexpected error: code = ${err.code}, message = "${err.message}"`); } else { - setKinematic(JSON.parse(response.array[0])); - setWalking(JSON.parse(response.array[1])); + const kinematic = JSON.parse(response.array[0]); + const walking = JSON.parse(response.array[1]); + + Object.keys(kinematic).forEach(name => { + Object.entries(kinematic[name]).forEach(([key, value]) => { + console.log(typeof value); + setKinematicValue(name, key, value); + }); + }) + + Object.keys(walking).forEach(name => { + Object.entries(walking[name]).forEach(([key, value]) => { + setWalkingValue(name, key, value); + }); + }) } });