Skip to content

Commit 1202859

Browse files
authored
Merge pull request #3135 from JdeRobot/issue-3041
Follow Person teleop mode resolved and working
2 parents f9fe5b6 + d41074c commit 1202859

File tree

4 files changed

+31
-185
lines changed

4 files changed

+31
-185
lines changed

exercises/static/exercises/follow_person/react-components/MapSelectorPerson.js

Lines changed: 0 additions & 147 deletions
This file was deleted.

exercises/static/exercises/follow_person/react-components/ImgCanvas.js renamed to exercises/static/exercises/follow_person/react-components/SpecificFollowPerson.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import * as React from "react";
2-
import PropTypes from "prop-types";
1+
import React, { useEffect, useState } from "react";
32
import noImage from "../../assets/img/noImage.png";
43
import "./css/GUICanvas.css";
4+
import PropTypes from "prop-types";
55

6-
export default function ImgCanvas() {
6+
function SpecificFollowPerson(props) {
77
const [image, setImage] = React.useState(
88
noImage
99
);
@@ -36,13 +36,38 @@ export default function ImgCanvas() {
3636
);
3737
};
3838
}, []);
39+
40+
41+
42+
useEffect(() => {
43+
listen_key();
44+
}, []);
45+
46+
function listen_key() {
47+
window.addEventListener("keypress", function (event) {
48+
if (event.code === "KeyS") {
49+
window.RoboticsExerciseComponents.commsManager.send("gui", "key_s");
50+
} else if (event.code === "KeyW") {
51+
window.RoboticsExerciseComponents.commsManager.send("gui", "key_w");
52+
} else if (event.code === "KeyA") {
53+
window.RoboticsExerciseComponents.commsManager.send("gui", "key_a");
54+
} else if (event.code === "KeyD") {
55+
window.RoboticsExerciseComponents.commsManager.send("gui", "key_d");
56+
} else if (event.code === "KeyX") {
57+
window.RoboticsExerciseComponents.commsManager.send("gui", "key_x");
58+
}
59+
});
60+
}
61+
3962
return (
4063
<div style={{display: "flex", width: "100%", height: "100%", position:"relative", justifyContent: "center"}}>
4164
<img className="image" id="gui_canvas" src={image}/>
4265
</div>
4366
);
67+
4468
}
4569

46-
ImgCanvas.propTypes = {
70+
SpecificFollowPerson.propTypes = {
4771
context: PropTypes.any,
4872
};
73+
export default SpecificFollowPerson;

exercises/static/exercises/follow_person/react-components/TeleopLogic.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

exercises/templates/exercises/follow_person/exercise.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{% react_component components/visualizers/VncConsoleViewer%}{% end_react_component %}
2121
{% end_react_component%}
2222
{% react_component components/containers/FlexContainer%}
23-
{% react_component exercise/follow_person/ImgCanvas %}{% end_react_component %}
23+
{% react_component exercise/follow_person/SpecificFollowPerson %}{% end_react_component %}
2424
{% react_component components/visualizers/GazeboViewer%}{% end_react_component %}
2525
{% end_react_component %}
2626
{% end_react_component %}
@@ -45,7 +45,7 @@
4545
{% react_component components/visualizers/ConsoleViewer%}{% end_react_component %}
4646
{% end_react_component%}
4747
{% react_component components/wrappers/FlexContainer%}
48-
{% react_component exercise/follow_person/ImgCanvas %}{% end_react_component %}
48+
{% react_component exercise/follow_person/SpecificFollowPerson %}{% end_react_component %}
4949
{% react_component components/visualizers/GazeboViewer%}{% end_react_component %}
5050
{% end_react_component %}
5151
{% end_react_component %}

0 commit comments

Comments
 (0)