Skip to content

Commit

Permalink
Merge pull request #79 from SJSURoboticsTeam/fix-speed-update-on-arm
Browse files Browse the repository at this point in the history
Fix speed update on arm
  • Loading branch information
starphys authored Sep 12, 2023
2 parents bb9719d + d9f12e3 commit f5ee71c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ function App() {
{system === 'science' && <ScienceSystem commands={commands} />}

<Status status={status} />
<Camera name="0" src="http://192.168.1.201:8081/" />
<Camera name="1" src="http://192.168.1.206:8081/" />
<Camera name="0" src="http://192.168.0.201:8081/" />
<Camera name="1" src="http://192.168.0.206:8081/" />
<Camera name="2" src="http://raspberrypi:8003/stream.mjpg" />
<Camera name="3" src="http://raspberrypi:8003/stream.mjpg" />
</div>
Expand Down
27 changes: 13 additions & 14 deletions src/components/ArmSystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ export default function ArmSystem({ commands }) {

useEffect(() => {
const interval = setInterval(() => {
updateController();
if(getGamePad()) {updateController();}
}, 125);
return () => clearInterval(interval);
}, []);

function updateCommands(newCommands) {
commands.current = armStringFormat(newCommands);
setArmCommands(newCommands);
setArmCommands(prev => ({...prev, ...newCommands}));
}

function handleChange(e) {
Expand All @@ -64,7 +64,7 @@ export default function ArmSystem({ commands }) {
}

function updateController() {
updateCommands({ ...getCommands(), speed: armCommands.speed });
updateCommands({ ...getCommands() });
}

function getCommands(): ArmCommandDTO {
Expand All @@ -75,17 +75,16 @@ export default function ArmSystem({ commands }) {
}

let currentCommands = commandsRef.current;
let commands = DEFAULT_ARM_COMMANDS;

commands.rotunda_angle = controller.getRotundaAngle(currentCommands);
commands.shoulder_angle = controller.getShoulderAngle(currentCommands);
commands.elbow_angle = controller.getElbowAngle(currentCommands);
commands.wrist_roll_angle = controller.getWristRollAngle(currentCommands);
commands.wrist_pitch_angle = controller.getWristPitchAngle(currentCommands);
commands.end_effector_angle = controller.getEndEffectorAngle(currentCommands);


return commands;
let newCommands = DEFAULT_ARM_COMMANDS;

newCommands.rotunda_angle = controller.getRotundaAngle(currentCommands);
newCommands.shoulder_angle = controller.getShoulderAngle(currentCommands);
newCommands.elbow_angle = controller.getElbowAngle(currentCommands);
newCommands.wrist_roll_angle = controller.getWristRollAngle(currentCommands);
newCommands.wrist_pitch_angle = controller.getWristPitchAngle(currentCommands);
newCommands.end_effector_angle = controller.getEndEffectorAngle(currentCommands);
delete newCommands.speed;
return newCommands;
}

function getGamePad() {
Expand Down

0 comments on commit f5ee71c

Please sign in to comment.