43 #include <geometry_msgs/Twist.h> 45 #include <nav_msgs/Path.h> 47 #include <trajectory_tracker_msgs/ChangePath.h> 48 #include <trajectory_tracker_msgs/TrajectoryServerStatus.h> 49 #include <visualization_msgs/InteractiveMarkerUpdate.h> 72 trajectory_tracker_msgs::ChangePath::Request
req_path_;
81 bool change(trajectory_tracker_msgs::ChangePath::Request& req,
82 trajectory_tracker_msgs::ChangePath::Response& res);
84 const visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback);
107 pub_path_ = neonavigation_common::compat::advertise<nav_msgs::Path>(
110 pub_status_ = pnh_.advertise<trajectory_tracker_msgs::TrajectoryServerStatus>(
"status", 2);
123 std::ifstream ifs(
req_path_.filename.c_str());
126 ifs.seekg(0, ifs.end);
128 ifs.seekg(0, ifs.beg);
130 ifs.read(reinterpret_cast<char*>(
buffer_.get()), serial_size_);
138 const visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback)
140 int id = std::atoi(feedback->marker_name.c_str());
141 switch (feedback->event_type)
143 case visualization_msgs::InteractiveMarkerFeedback::POSE_UPDATE:
144 path_.poses[id].pose = feedback->pose;
146 case visualization_msgs::InteractiveMarkerFeedback::MOUSE_UP:
150 case visualization_msgs::InteractiveMarkerFeedback::MENU_SELECT:
151 switch (feedback->menu_entry_id)
168 visualization_msgs::InteractiveMarkerUpdate viz;
169 viz.type = viz.KEEP_ALIVE;
171 viz.server_id =
"Path";
174 for (
auto& p :
path_.poses)
176 visualization_msgs::InteractiveMarker mark;
177 visualization_msgs::Marker marker;
178 visualization_msgs::InteractiveMarkerControl ctl;
179 visualization_msgs::MenuEntry menu;
180 mark.header =
path_.header;
183 std::stringstream ss;
185 mark.name = ss.str();
188 marker.scale.x = 0.2;
189 marker.scale.y = 0.05;
190 marker.scale.z = 0.05;
195 marker.type = marker.ARROW;
199 ctl.interaction_mode = ctl.MOVE_ROTATE;
200 ctl.orientation_mode = ctl.INHERIT;
201 ctl.always_visible =
true;
202 ctl.markers.push_back(marker);
204 mark.controls.push_back(ctl);
207 ctl.interaction_mode = ctl.MENU;
209 marker.type = marker.SPHERE;
212 marker.scale.x = 0.08;
213 marker.scale.y = 0.08;
214 marker.scale.z = 0.08;
215 ctl.markers[0] = marker;
216 mark.controls.push_back(ctl);
220 menu.title =
"Delete";
221 menu.command_type = menu.FEEDBACK;
222 mark.menu_entries.push_back(menu);
227 mark.menu_entries.push_back(menu);
229 viz.markers.push_back(mark);
235 trajectory_tracker_msgs::ChangePath::Response& res)
254 for (
size_t i = 0; i <
path_.poses.size(); i++)
256 path_.poses[i].pose.position.x =
lpf_[0]->
in(
path_.poses[i].pose.position.x);
257 path_.poses[i].pose.position.y =
lpf_[1]->
in(
path_.poses[i].pose.position.y);
272 path_.header.frame_id =
"map";
280 trajectory_tracker_msgs::TrajectoryServerStatus status;
284 status.header =
path_.header;
293 int main(
int argc,
char** argv)
295 ros::init(argc, argv,
"trajectory_server");
void processFeedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback)
bool change(trajectory_tracker_msgs::ChangePath::Request &req, trajectory_tracker_msgs::ChangePath::Response &res)
void publish(const boost::shared_ptr< M > &message) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
ros::ServiceServer srv_change_path_
ros::ServiceServer advertiseService(ros::NodeHandle &nh_new, const std::string &service_new, ros::NodeHandle &nh_old, const std::string &service_old, bool(T::*srv_func)(MReq &, MRes &), T *obj)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
boost::shared_array< uint8_t > buffer_
void insert(const visualization_msgs::InteractiveMarker &int_marker)
interactive_markers::InteractiveMarkerServer srv_im_fb_
trajectory_tracker::Filter * lpf_[2]
ros::Publisher pub_status_
trajectory_tracker_msgs::ChangePath::Request req_path_
ROSCPP_DECL void spinOnce()
void deprecatedParam(const ros::NodeHandle &nh, const std::string &key, T ¶m, const T &default_value)
void deserialize(Stream &stream, T &t)