9 #include <uuid_msgs/UniqueID.h> 11 #include <ram_msgs/AdditiveManufacturingTrajectory.h> 12 #include <ram_msgs/AdditiveManufacturingPose.h> 14 #include <ram_modify_trajectory/AddToSelection.h> 15 #include <ram_modify_trajectory/EraseSelection.h> 16 #include <ram_modify_trajectory/GetPosesFromLayer.h> 17 #include <ram_modify_trajectory/GetPosesFromLayersList.h> 18 #include <ram_modify_trajectory/GetPosesFromTrajectory.h> 19 #include <ram_modify_trajectory/GetSelection.h> 20 #include <ram_modify_trajectory/InvertSelection.h> 21 #include <ram_modify_trajectory/RemoveFromSelection.h> 24 ram_msgs::AdditiveManufacturingTrajectory
layers;
27 std::vector<ram_msgs::AdditiveManufacturingPose>
selection;
39 ram_modify_trajectory::GetPosesFromTrajectory::Response &res)
46 if (req.pose_index_list.empty())
49 std::vector<unsigned> pose_index_list = req.pose_index_list;
50 std::sort(pose_index_list.begin(), pose_index_list.end());
52 if (pose_index_list.back() >=
layers.poses.size())
55 for (
auto pose_index : pose_index_list)
56 res.poses.push_back(
layers.poses[pose_index]);
62 ram_modify_trajectory::GetPosesFromLayersList::Response &res)
69 if (req.layer_level_list.empty())
72 if (req.layer_level_list.back() >
layers.poses.back().layer_level)
76 for (
auto pose :
layers.poses)
78 for (
auto current_layer_level : req.layer_level_list)
80 if (pose.layer_level != current_layer_level)
83 res.poses.push_back(pose);
91 ram_modify_trajectory::GetPosesFromLayer::Response &res)
98 if (req.index_list_relative.empty())
101 if (req.layer_level >
layers.poses.back().layer_level)
104 std::vector<unsigned> index_list_relative = req.index_list_relative;
105 std::sort(index_list_relative.begin(), index_list_relative.end());
108 std::vector<ram_msgs::AdditiveManufacturingPose> layer;
109 for (
auto &pose :
layers.poses)
110 if (pose.layer_level == req.layer_level)
111 layer.push_back(pose);
118 if (index_list_relative.back() >= layer.size())
122 for (
unsigned local_index(0); local_index < layer.size(); ++local_index)
124 if (index_list_relative.empty())
127 if (local_index == index_list_relative.front())
129 res.poses.push_back(layer[local_index]);
130 index_list_relative.erase(index_list_relative.begin());
138 ram_modify_trajectory::AddToSelection::Response &res)
142 unsigned selection_size =
selection.size();
144 for (
auto request_pose : req.poses)
146 bool is_duplicate =
false;
149 for (
unsigned i(0); i < selection_size; ++i)
152 if (request_uuid.compare(selection_uuid) != 0)
167 ram_modify_trajectory::RemoveFromSelection::Response &res)
171 for (
auto request_pose : req.poses)
175 for (
unsigned i(0); i <
selection.size(); ++i)
178 if (request_uuid.compare(selection_uuid) != 0)
190 ram_modify_trajectory::GetSelection::Response &res)
198 ram_modify_trajectory::EraseSelection::Response &res)
208 ram_modify_trajectory::InvertSelection::Response &res)
212 for (
auto request_pose : req.poses)
214 bool is_duplicate =
false;
217 for (
unsigned i(0); i <
selection.size(); ++i)
220 if (request_uuid.compare(selection_uuid) != 0)
void saveTrajectoryCallback(const ram_msgs::AdditiveManufacturingTrajectoryConstPtr &msg)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
std::vector< ram_msgs::AdditiveManufacturingPose > selection
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
std::unique_ptr< ros::NodeHandle > nh
std::mutex trajectory_mutex
ram_msgs::AdditiveManufacturingTrajectory layers
bool getPosesFromLayersListCallback(ram_modify_trajectory::GetPosesFromLayersList::Request &req, ram_modify_trajectory::GetPosesFromLayersList::Response &res)
bool removeFromSelectionCallback(ram_modify_trajectory::RemoveFromSelection::Request &req, ram_modify_trajectory::RemoveFromSelection::Response &res)
bool invertSelectionCallback(ram_modify_trajectory::InvertSelection::Request &req, ram_modify_trajectory::InvertSelection::Response &res)
static std::string toHexString(boost::uuids::uuid const &uu)
std::mutex selection_params_mutex
bool getSelectionCallback(ram_modify_trajectory::GetSelection::Request &, ram_modify_trajectory::GetSelection::Response &res)
int main(int argc, char **argv)
bool getPosesFromTrajectoryCallback(ram_modify_trajectory::GetPosesFromTrajectory::Request &req, ram_modify_trajectory::GetPosesFromTrajectory::Response &res)
bool addToSelectionCallback(ram_modify_trajectory::AddToSelection::Request &req, ram_modify_trajectory::AddToSelection::Response &res)
bool eraseSelectionCallback(ram_modify_trajectory::EraseSelection::Request &, ram_modify_trajectory::EraseSelection::Response &res)
ROSCPP_DECL void waitForShutdown()
bool getPosesFromLayerCallback(ram_modify_trajectory::GetPosesFromLayer::Request &req, ram_modify_trajectory::GetPosesFromLayer::Response &res)