Skip to content

Commit

Permalink
Merge pull request #190 from utiasASRL/waypoint_improvement
Browse files Browse the repository at this point in the history
Waypoint improvement
  • Loading branch information
nthiyag committed Aug 10, 2023
2 parents e58efef + edf4523 commit 47fac2a
Show file tree
Hide file tree
Showing 28 changed files with 517 additions and 128 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ ENV VTRROOT=${HOMEDIR}/ASRL/vtr3
ENV VTRSRC=${VTRROOT}/src \
VTRDATA=${VTRROOT}/data \
VTRTEMP=${VTRROOT}/temp \
GRIZZLY=${VTRROOT}/grizzly
GRIZZLY=${VTRROOT}/grizzly \
VTRUI=${VTRSRC}/main/src/vtr_gui/vtr_gui/vtr-gui

RUN echo "alias build_ui='npm --prefix ${VTRUI} install ${VTRUI}; npm --prefix ${VTRUI} run build'" >> ~/.bashrc
RUN echo "alias build_vtr='source /opt/ros/humble/setup.bash; cd ${VTRSRC}/main; colcon build --symlink-install'" >> ~/.bashrc

## Switch to root to install dependencies
USER 0:0
Expand All @@ -42,6 +46,7 @@ RUN apt update && apt install -q -y freeglut3-dev
RUN apt update && apt install -q -y python3 python3-distutils python3-pip
RUN apt update && apt install -q -y libeigen3-dev
RUN apt update && apt install -q -y libsqlite3-dev sqlite3
RUN apt install -q -y libc6-dbg gdb valgrind

## Install PROJ (8.2.0) (this is for graph_map_server in vtr_navigation)
RUN apt update && apt install -q -y cmake libsqlite3-dev sqlite3 libtiff-dev libcurl4-openssl-dev
Expand Down Expand Up @@ -108,7 +113,6 @@ RUN apt install ros-humble-velodyne -q -y

# Install vim
RUN apt update && apt install -q -y vim
RUN apt install -q -y libc6-dbg gdb valgrind

## Switch to specified user
USER ${USERID}:${GROUPID}
2 changes: 1 addition & 1 deletion launch/offline_honeycomb_grizzly.launch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ windows:
shell_command_before:
- source /opt/ros/humble/setup.bash
panes:
- ros2 run rviz2 rviz2 -d ${VTRSRC}/rviz/lidar.rviz
- ros2 run rviz2 rviz2 -d ${VTRSRC}/rviz/honeycomb.rviz
# - ros2 run rqt_reconfigure rqt_reconfigure
2 changes: 1 addition & 1 deletion main/src/deps/steam
Submodule steam updated 55 files
+1 −2 .gitignore
+0 −1 include/steam.hpp
+4 −77 include/steam/evaluable/stereo/stereo_error_evaluator.hpp
+1 −1 include/steam/problem/loss_func/dcs_loss_func.hpp
+0 −4 include/steam/problem/noise_model/base_noise_model.hpp
+0 −153 include/steam/problem/noise_model/dynamic_noise_model.hpp
+2 −0 include/steam/problem/noise_model/static_noise_model.hpp
+0 −41 include/steam/trajectory/const_acc/acceleration_extrapolator.hpp
+0 −50 include/steam/trajectory/const_acc/acceleration_interpolator.hpp
+43 −79 include/steam/trajectory/const_acc/helper.hpp
+2 −29 include/steam/trajectory/const_acc/interface.hpp
+0 −41 include/steam/trajectory/const_acc/pose_extrapolator.hpp
+3 −4 include/steam/trajectory/const_acc/pose_interpolator.hpp
+6 −6 include/steam/trajectory/const_acc/prior_factor.hpp
+0 −42 include/steam/trajectory/const_acc/velocity_extrapolator.hpp
+3 −4 include/steam/trajectory/const_acc/velocity_interpolator.hpp
+58 −9 include/steam/trajectory/const_vel/helper.hpp
+6 −8 include/steam/trajectory/const_vel/interface.hpp
+11 −8 include/steam/trajectory/const_vel/pose_extrapolator.hpp
+2 −3 include/steam/trajectory/const_vel/pose_interpolator.hpp
+4 −0 include/steam/trajectory/const_vel/prior_factor.hpp
+2 −3 include/steam/trajectory/const_vel/velocity_interpolator.hpp
+0 −36 include/steam/trajectory/singer/acceleration_extrapolator.hpp
+0 −49 include/steam/trajectory/singer/acceleration_interpolator.hpp
+6 −41 include/steam/trajectory/singer/helper.hpp
+30 −63 include/steam/trajectory/singer/interface.hpp
+0 −35 include/steam/trajectory/singer/pose_extrapolator.hpp
+28 −25 include/steam/trajectory/singer/pose_interpolator.hpp
+31 −20 include/steam/trajectory/singer/prior_factor.hpp
+52 −0 include/steam/trajectory/singer/variable.hpp
+0 −36 include/steam/trajectory/singer/velocity_extrapolator.hpp
+28 −28 include/steam/trajectory/singer/velocity_interpolator.hpp
+1 −1 samples/RadialVelMeasWithConstVelTraj.cpp
+18 −99 src/evaluable/stereo/stereo_error_evaluator.cpp
+0 −58 src/trajectory/const_acc/acceleration_extrapolator.cpp
+0 −269 src/trajectory/const_acc/acceleration_interpolator.cpp
+22 −280 src/trajectory/const_acc/interface.cpp
+0 −82 src/trajectory/const_acc/pose_extrapolator.cpp
+48 −128 src/trajectory/const_acc/pose_interpolator.cpp
+70 −94 src/trajectory/const_acc/prior_factor.cpp
+ src/trajectory/const_acc/se3_wnoj_interp_jacs.pdf
+0 −67 src/trajectory/const_acc/velocity_extrapolator.cpp
+57 −165 src/trajectory/const_acc/velocity_interpolator.cpp
+3 −2 src/trajectory/const_vel/evaluable/j_velocity_evaluator.cpp
+3 −2 src/trajectory/const_vel/evaluable/jinv_velocity_evaluator.cpp
+34 −40 src/trajectory/const_vel/interface.cpp
+28 −38 src/trajectory/const_vel/pose_extrapolator.cpp
+45 −99 src/trajectory/const_vel/pose_interpolator.cpp
+49 −51 src/trajectory/const_vel/prior_factor.cpp
+ src/trajectory/const_vel/se3_wnoa_interp_jacs.pdf
+46 −108 src/trajectory/const_vel/velocity_interpolator.cpp
+248 −0 src/trajectory/singer/interface.cpp
+110 −0 src/trajectory/singer/pose_interpolator.cpp
+144 −0 src/trajectory/singer/prior_factor.cpp
+113 −0 src/trajectory/singer/velocity_interpolator.cpp
1 change: 1 addition & 0 deletions main/src/vtr_common/vtr_include.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ add_compile_options(-march=native -O3 -pthread -Wall -Wextra)
# address sanitizer
# add_compile_options(-fsanitize=address)
# set(CMAKE_CXX_STANDARD_LIBRARIES -lasan)
# add_compile_options(-g -Og)


## Common packages setup
Expand Down
20 changes: 19 additions & 1 deletion main/src/vtr_gui/vtr_gui/socket_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from vtr_navigation.vtr_ui_builder import build_master

from vtr_tactic_msgs.msg import EnvInfo
from vtr_navigation_msgs.msg import MoveGraph, AnnotateRoute
from vtr_navigation_msgs.msg import MoveGraph, AnnotateRoute, UpdateWaypoint
from vtr_navigation_msgs.msg import MissionCommand, ServerState, GoalHandle

# socket io server address and port
Expand All @@ -41,6 +41,7 @@ def graph_state_from_ros(ros_graph_state):
'lat': v.lat,
'theta': v.theta,
'type': v.type,
'name': v.name
} for v in ros_graph_state.vertices],
'fixed_routes': [{
'ids': [id for id in r.ids],
Expand All @@ -64,6 +65,7 @@ def graph_update_from_ros(ros_graph_update):
'lat': vf.lat,
'theta': vf.theta,
'type': vf.type,
'name': vf.name
},
'vertex_to': {
'id': vt.id,
Expand All @@ -72,6 +74,7 @@ def graph_update_from_ros(ros_graph_update):
'lat': vt.lat,
'theta': vt.theta,
'type': vt.type,
'name': vt.name
},
}

Expand Down Expand Up @@ -244,6 +247,11 @@ def cancel_goal(self, data):
ros_command.type = MissionCommand.CANCEL_GOAL
ros_command.goal_handle.id = [int(id) for id in data['id']]
return super().cancel_goal(ros_command)

def begin_goals(self):
ros_command = MissionCommand()
ros_command.type = MissionCommand.BEGIN_GOALS
return super().begin_goals(ros_command)

def move_robot(self, data):
ros_command = MissionCommand()
Expand All @@ -266,6 +274,16 @@ def continue_teach(self, _):
ros_command = MissionCommand()
ros_command.type = MissionCommand.CONTINUE_TEACH
return super().continue_teach(ros_command)

def update_waypoint(self, data):
ros_waypoint_update = UpdateWaypoint()
ros_waypoint_update.vertex_id = int(data['vertex_id'])
ros_waypoint_update.type = int(data['type'])
if int(data['type']) == UpdateWaypoint.ADD:
ros_waypoint_update.name = data['name']
else:
ros_waypoint_update.name = ""
return super().update_waypoint(ros_waypoint_update)

def annotate_route(self, data):
ros_annotate_route = AnnotateRoute()
Expand Down
14 changes: 13 additions & 1 deletion main/src/vtr_gui/vtr_gui/socket_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def on_disconnect():

@socketio.on('command/set_pause')
def handle_set_pause(data):
logger.info('Received add goal command', data)
logger.info('Received set pause command', data)
build_remote().set_pause(data)


Expand All @@ -82,6 +82,12 @@ def handle_cancel_goal(data):
build_remote().cancel_goal(data)


@socketio.on('command/begin_goals')
def handle_begin_goals():
logger.info('Received begin goals command')
build_remote().begin_goals()


@socketio.on('command/merge')
def handle_merge(data):
logger.info('Received merge command', data)
Expand All @@ -100,6 +106,12 @@ def handle_continue_teach(data):
build_remote().continue_teach(data)


@socketio.on('command/update_waypoint')
def handle_update_waypoint(data):
logger.info('Received update waypoint command', data)
build_remote().update_waypoint(data)


@socketio.on('command/annotate_route')
def handle_annotate_route(data):
logger.info('Received annotate route command', data)
Expand Down
4 changes: 2 additions & 2 deletions main/src/vtr_gui/vtr_gui/vtr-gui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ class GoalCard extends React.Component {
</Typography>
<Button
sx={{ width: 100, m: 1 }}
color={"primary"}
color={"secondary"}
disableElevation={true}
fullWidth={true}
size="small"
startIcon={<ClearIcon />}
variant={"contained"}
onClick={() => cancelGoal(goal)}
>
Cancel
CANCEL
</Button>
</Box>
{expand && goal.type === "repeat" && (
Expand Down
72 changes: 41 additions & 31 deletions main/src/vtr_gui/vtr_gui/vtr-gui/src/components/goal/GoalForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ class GoalForm extends React.Component {

componentDidUpdate(prevProps) {
// Update goal_waypoints_str if goalWaypoints is changed by either this or GraphMap.
if (prevProps.goalWaypoints !== this.props.goalWaypoints) this.convertGoalWaypoints(this.props.goalWaypoints);
if (prevProps.goalWaypoints !== this.props.goalWaypoints || prevProps.waypointsMap !== this.props.waypointsMap)
this.updateGoalWaypointsStr(this.props.goalWaypoints);
}

render() {
const { goalType, goalWaypoints, setGoalWaypoints } = this.props;
const { waypointsMap, goalType, goalWaypoints, setNewGoalWaypoints } = this.props;
const { goal_form_open, goal_waypoints_str, goal_waypoints_invalid, pause_after, pause_before } = this.state;
return (
<>
Expand Down Expand Up @@ -115,8 +116,10 @@ class GoalForm extends React.Component {
variant="standard"
size="small"
error={goal_waypoints_invalid}
onChange={(e) => this.setState({ goal_waypoints_str: e.target.value })}
onKeyPress={this.parseGoalWaypoints.bind(this)}
onChange={(e) => {
this.setState({ goal_waypoints_str: e.target.value });
this.parseGoalWaypoints(e);
}}
value={goal_waypoints_str}
/>
<IconButton
Expand All @@ -125,13 +128,13 @@ class GoalForm extends React.Component {
onClick={() => {
if (goalWaypoints.length > 0) {
let new_goal_waypoints = goalWaypoints.slice(0, goalWaypoints.length - 1);
setGoalWaypoints(new_goal_waypoints.map((p) => p.id));
setNewGoalWaypoints(new_goal_waypoints);
}
}}
>
<ArrowBackIcon />
</IconButton>
<IconButton color="secondary" size="small" onClick={() => setGoalWaypoints([])}>
<IconButton color="secondary" size="small" onClick={() => setNewGoalWaypoints([])}>
<ClearIcon />
</IconButton>
</Box>
Expand All @@ -147,7 +150,7 @@ class GoalForm extends React.Component {
size="small"
startIcon={<CheckIcon />}
variant={"contained"}
onClick={this.submitGoal.bind(this)}
onClick={this.addGoal.bind(this)}
>
Confirm
</Button>
Expand Down Expand Up @@ -186,7 +189,7 @@ class GoalForm extends React.Component {
toggleGoalForm(enable) {
// clear existing goal
this.props.setGoalType("");
this.props.setGoalWaypoints([]);
this.props.setNewGoalWaypoints([]);
this.setState({
goal_form_open: enable ? true : false,
goal_waypoints_invalid: false,
Expand All @@ -202,7 +205,7 @@ class GoalForm extends React.Component {
*/
selectGoalType(type) {
this.props.setGoalType(type);
this.props.setGoalWaypoints([]);
this.props.setNewGoalWaypoints([]);
this.setState({ goal_waypoints_invalid: false, goal_waypoints_str: "", pause_after: "", pause_before: "" });
}

Expand All @@ -220,32 +223,39 @@ class GoalForm extends React.Component {

/** @brief Selects repeat waypoints. */
parseGoalWaypoints(e) {
if (e.key === "Enter") {
let input = e.target.value;
let ids_str = input.replace(/ /g, "").split(",");
let ids = [];
for (let id of ids_str) {
let idpair = id.split("-");
for (let i of idpair) if (isNaN(i)) continue;
let input = e.target.value;
let names_lst = input.split(", ");
let ids = [];

if (idpair.length === 1) ids.push(parseInt(idpair[0]));
else if (idpair.length === 2) ids.push(parseInt(idpair[0]) * Math.pow(2, 32) + parseInt(idpair[1]));
}
this.props.setGoalWaypoints(ids);
if (input == "") {
this.props.setNewGoalWaypoints([]);
this.setState({ goal_waypoints_invalid: false });
e.preventDefault();
} else {
this.setState({ goal_waypoints_invalid: true });
return;
}

for (let name of names_lst) {
if (Array.from(this.props.waypointsMap.values()).includes(name)){
ids.push(
Array.from(this.props.waypointsMap.keys()).find(
(key) => this.props.waypointsMap.get(key) === name
)
);
}
else {
this.setState({ goal_waypoints_invalid: true });
return;
}
}

this.props.setNewGoalWaypoints(ids);
this.setState({ goal_waypoints_invalid: false });
}

/** @brief Parses repeat waypoints and generate a user readable string. */
convertGoalWaypoints(goal_waypoints) {
updateGoalWaypointsStr(goal_waypoints) {
let s = "";
goal_waypoints.forEach((id) => {
let vl = parseInt(id % Math.pow(2, 32));
let vh = parseInt((id - vl) / Math.pow(2, 32));
s += vh.toString() + "-" + vl.toString() + ", ";
if (this.props.waypointsMap.has(id)) s += this.props.waypointsMap.get(id) + ", ";
});
s = s.slice(0, s.length - 2);
this.setState({
Expand All @@ -254,22 +264,22 @@ class GoalForm extends React.Component {
}

/** @brief Calls GoalManager to submit the goal */
submitGoal() {
addGoal() {
this.setState(
(state, props) => {
let goal = {
type: props.goalType,
pause_before: Number(state.pause_before),
pause_after: Number(state.pause_after),
waypoints: props.goalWaypoints,
waypoints: props.goalWaypoints
};
console.debug("Submit new goal:", goal);
console.debug("Create new goal:", goal);
props.socket.emit("command/add_goal", goal);
return { goal_waypoints_invalid: false, goal_waypoints_str: "", pause_after: "", pause_before: "" };
},
() => {
this.props.setGoalType("");
this.props.setGoalWaypoints([]);
this.props.setNewGoalWaypoints([]);
}
);
}
Expand Down
Loading

0 comments on commit 47fac2a

Please sign in to comment.