6 _waypoint_server(
"waypoint_marker") {
17 rsm_msgs::SetWaypointRoutine>(
"setWaypointRoutine");
19 rsm_msgs::GetWaypointRoutines>(
"getWaypointRoutines");
35 const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback) {
36 rsm_msgs::MoveWaypoint srv;
37 srv.request.position = std::stoi(feedback->marker_name);
38 srv.request.pose = feedback->pose;
42 ROS_ERROR(
"Failed to call service Move Waypoint");
47 const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback) {
48 rsm_msgs::RemoveWaypoint srv;
49 srv.request.position = std::stoi(feedback->marker_name);
53 ROS_ERROR(
"Failed to call service Remove Waypoint");
58 const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback) {
59 rsm_msgs::SetWaypointRoutine srv;
60 srv.request.position = std::stoi(feedback->marker_name);
61 if (feedback->menu_entry_id == 3) {
62 srv.request.routine =
"";
67 ROS_ERROR(
"Failed to call service Move Waypoint");
73 const rsm_msgs::WaypointArray::ConstPtr& waypoint_array) {
77 for (
int i = 0; i <
_waypoints.waypoints_size; i++) {
87 visualization_msgs::InteractiveMarker waypoint_marker;
88 waypoint_marker.header.frame_id =
"map";
89 waypoint_marker.name = std::to_string(waypoint_pos);
90 if (!
_waypoints.waypoints[waypoint_pos].routine.empty()) {
92 s << waypoint_marker.name <<
": " 94 waypoint_marker.description = s.str();
96 waypoint_marker.description = waypoint_marker.name;
98 waypoint_marker.pose =
_waypoints.waypoints[waypoint_pos].pose;
101 visualization_msgs::Marker box_marker;
102 box_marker.type = visualization_msgs::Marker::MESH_RESOURCE;
103 box_marker.mesh_resource =
104 "package://rsm_rviz_plugins/media/flag.dae";
105 box_marker.mesh_use_embedded_materials =
false;
106 box_marker.scale.x = 1.0;
107 box_marker.scale.y = 1.0;
108 box_marker.scale.z = 1.0;
109 if (
_waypoints.waypoints[waypoint_pos].unreachable) {
110 box_marker.color.r = 1.0;
111 }
else if (
_waypoints.waypoints[waypoint_pos].visited) {
112 box_marker.color.g = 1.0;
114 box_marker.color.b = 1.0;
116 box_marker.color.a = 1.0;
119 visualization_msgs::InteractiveMarkerControl box_control;
120 box_control.always_visible =
true;
121 box_control.markers.push_back(box_marker);
124 waypoint_marker.controls.push_back(box_control);
126 visualization_msgs::InteractiveMarkerControl menu_control;
127 menu_control.name =
"menu_control";
128 menu_control.interaction_mode =
129 visualization_msgs::InteractiveMarkerControl::MENU;
130 menu_control.always_visible =
true;
131 menu_control.markers.push_back(box_marker);
132 waypoint_marker.controls.push_back(menu_control);
137 visualization_msgs::InteractiveMarkerControl move_control;
138 move_control.name =
"move_control";
142 move_control.interaction_mode =
143 visualization_msgs::InteractiveMarkerControl::MOVE_ROTATE;
144 waypoint_marker.controls.push_back(move_control);
145 move_control.interaction_mode =
146 visualization_msgs::InteractiveMarkerControl::MOVE_AXIS;
147 waypoint_marker.controls.push_back(move_control);
165 rsm_msgs::GetWaypointRoutines srv;
175 ROS_ERROR(
"Failed to call Get Waypoint Routines service");
180 const rsm_msgs::WaypointArray::ConstPtr& waypoint_array) {
181 if (waypoint_array->waypoints_size ==
_waypoints.waypoints_size) {
182 for (
int i = 0; i <
_waypoints.waypoints_size; i++) {
184 waypoint_array->waypoints[i].routine) != 0
186 != waypoint_array->waypoints[i].visited
188 != waypoint_array->waypoints[i].unreachable) {
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
ros::ServiceClient _remove_waypoint_client
void setWaypointRoutine(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback)
void addWaypointMarkerToServer(int waypoint_pos)
interactive_markers::InteractiveMarkerServer _waypoint_server
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
bool waypointArrayChanged(const rsm_msgs::WaypointArray::ConstPtr &waypoint_array)
ros::Subscriber _waypoint_subscriber
~WaypointFollowingVisualization()
bool call(MReq &req, MRes &res)
ros::Timer _service_call_delay_timer
ros::ServiceClient _move_waypoint_client
bool apply(InteractiveMarkerServer &server, const std::string &marker_name)
void timerCallback(const ros::TimerEvent &event)
ros::ServiceClient _set_waypoint_routine_client
bool _refresh_waypoint_markers
interactive_markers::MenuHandler _menu_handler
WaypointFollowingVisualization()
void periodicalRefreshTimerCallback(const ros::TimerEvent &event)
static void quaternionTFToMsg(const Quaternion &bt, geometry_msgs::Quaternion &msg)
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
void processFeedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback)
void waypointCallback(const rsm_msgs::WaypointArray::ConstPtr &waypoint_array)
ros::Timer _periodical_refresh_timer
std::vector< std::string > _waypoint_routines
EntryHandle insert(const std::string &title, const FeedbackCallback &feedback_cb)
INTERACTIVE_MARKERS_PUBLIC void insert(const visualization_msgs::InteractiveMarker &int_marker)
INTERACTIVE_MARKERS_PUBLIC void applyChanges()
INTERACTIVE_MARKERS_PUBLIC bool setCallback(const std::string &name, FeedbackCallback feedback_cb, uint8_t feedback_type=DEFAULT_FEEDBACK_CB)
void removeWaypoint(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback)
INTERACTIVE_MARKERS_PUBLIC void clear()
ros::ServiceClient _get_waypoint_routines_client
rsm_msgs::WaypointArray _waypoints