Skip to content

Commit

Permalink
Added label editing to frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
philippewarren committed Jan 25, 2022
1 parent 4e6f652 commit 03426ce
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
6 changes: 2 additions & 4 deletions opentera_webrtc_ros/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ Manages labels.
The stored labels are dependent on the `map` transform and the database needs to be cleaned if the map changes.
A label represents a name grouped with an associated pose and a description.
This node relies on a service provided by the `map_image_generator` package to convert the labels from image coordinates to map coordinates.

<!-- This node can also send a label as a goal to `move_base` by its name. -->
This node can also send a label as a goal to `move_base` by its name.

## Subscribed topics

Expand All @@ -175,6 +174,5 @@ This node relies on a service provided by the `map_image_generator` package to c
## Published topics

- stored_labels (`opentera_webrtc_ros_msgs/LabelArray`): Array of labels currently stored
- stored_labels_names (`std_msgs/String`): JSON message with an array of string which are the stored labels names. Used by the frontend to display a list of labels.
- stored_labels_text (`std_msgs/String`): JSON message with an array of maps `{name: string, description: string}` labels names and descriptions. Used by the frontend to display a list of labels.
- All published topics of `libnavigation`
<!-- - stored_labels_simple (`openterat_webrtc_ros_msgs/LabelSimpleArray`): Version of `stored_labels` which contains `opentera_webrtc_ros_msgs/Waypoint` instead of `geometry_msgs/PoseStamped` for frontend communication. -->
6 changes: 4 additions & 2 deletions opentera_webrtc_ros/scripts/labels_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ def edit_label_simple_callback(self, msg: LabelSimpleEdit) -> None:
if msg.current_name != msg.updated.name:
self.db.rename(msg.current_name, msg.updated.name)

self.db.replace(msg.updated.name, LabelData(
self.simple2label(msg.updated)))
updated = self.simple2label(msg.updated)
if msg.ignore_waypoint is True:
updated.pose = self.db[msg.updated.name].label.pose
self.db.replace(msg.updated.name, LabelData(updated))

self.db.commit()
except (IndexError, ConversionError) as e:
Expand Down
5 changes: 4 additions & 1 deletion opentera_webrtc_ros/scripts/libnavigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self, stop_cb: Optional[Callable[..., Generator]] = None, stop_toke

self.stop_cb = stop_cb or WaypointNavigationClient.__noop
self.stop_token = stop_token or WaypointNavigationClient.__false
self.stop = False

self.cancel_all_goals()

Expand All @@ -45,10 +46,11 @@ def add_to_image(self, pose_goal):
def navigate_to_goal(self, pose_goal, reached_index):
goal = MoveBaseGoal()
goal.target_pose = pose_goal
self.stop = False
self.move_base_client.send_goal(goal)
self.move_base_client.wait_for_result()
state = self.move_base_client.get_state()
if not self.stop_token(state):
if not self.stop and not self.stop_token(state):
self._publish_waypoint_reached(reached_index, pose_goal)

def cancel_all_goals(self, clear_goals=True):
Expand Down Expand Up @@ -80,6 +82,7 @@ def _publish_waypoint_reached(self, waypoint_index, goal_pose):

def _stop_callback(self, msg):
if msg.data == True:
self.stop = True
cb = self.stop_cb(msg)
next(cb)
self.cancel_all_goals()
Expand Down
11 changes: 10 additions & 1 deletion opentera_webrtc_ros/src/RosJsonDataHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,16 @@ void RosJsonDataHandler::onWebRTCDataReceived(
labelEdit.current_name = serializedData["currentLabel"];
labelEdit.updated.name = data["name"];
labelEdit.updated.description = data["description"];
labelEdit.updated.waypoint = getWpFromData(data);
if (data["coordinate"].is_null())
{
labelEdit.ignore_waypoint = true;
labelEdit.updated.waypoint = opentera_webrtc_ros_msgs::Waypoint();
}
else
{
labelEdit.ignore_waypoint = false;
labelEdit.updated.waypoint = getWpFromData(data);
}

m_editLabelPub.publish(labelEdit);
}
Expand Down
1 change: 1 addition & 0 deletions opentera_webrtc_ros_msgs/msg/LabelEdit.msg
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
string current_name
opentera_webrtc_ros_msgs/Label updated
bool ignore_pose
1 change: 1 addition & 0 deletions opentera_webrtc_ros_msgs/msg/LabelSimpleEdit.msg
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
string current_name
opentera_webrtc_ros_msgs/LabelSimple updated
bool ignore_waypoint

0 comments on commit 03426ce

Please sign in to comment.