Skip to content
Snippets Groups Projects
Commit 2d2cf7cc authored by Johannes Mey's avatar Johannes Mey
Browse files

also publish drop-off locations

parent 836694ff
No related branches found
No related tags found
No related merge requests found
...@@ -80,6 +80,7 @@ int main(int argc, char **argv) { ...@@ -80,6 +80,7 @@ int main(int argc, char **argv) {
n.subscribe<std_msgs::String>(prefix + "/select", 1000, [&](auto &m) { sendSelection(m->data); }); n.subscribe<std_msgs::String>(prefix + "/select", 1000, [&](auto &m) { sendSelection(m->data); });
ros::Publisher pub_objects = n.advertise<std_msgs::String>(prefix + "/objects", 1); ros::Publisher pub_objects = n.advertise<std_msgs::String>(prefix + "/objects", 1);
ros::Publisher pub_bins = n.advertise<std_msgs::String>(prefix + "/bins", 1); ros::Publisher pub_bins = n.advertise<std_msgs::String>(prefix + "/bins", 1);
ros::Publisher pub_locations = n.advertise<std_msgs::String>(prefix + "/locations", 1);
while (ros::ok()) { while (ros::ok()) {
...@@ -106,12 +107,15 @@ int main(int argc, char **argv) { ...@@ -106,12 +107,15 @@ int main(int argc, char **argv) {
// collect all object names // collect all object names
std::vector<std::string> objects{}; std::vector<std::string> objects{};
std::vector<std::string> bins{}; std::vector<std::string> bins{};
std::vector<std::string> locs{};
for (const auto &object: scene.objects()) { for (const auto &object: scene.objects()) {
ROS_DEBUG_STREAM("found object " << object.id() << " of type " << Object_Type_Name(object.type())); ROS_DEBUG_STREAM("found object " << object.id() << " of type " << Object_Type_Name(object.type()));
if (object.type() == Object_Type_BOX) { if (object.type() == Object_Type_BOX) {
objects.push_back(object.id()); objects.push_back(object.id());
} else if (object.type() == Object_Type_BIN) { } else if (object.type() == Object_Type_BIN) {
bins.push_back(object.id()); bins.push_back(object.id());
} else if (object.type() == Object_Type_DROP_OFF_LOCATION) {
locs.push_back(object.id());
} }
} }
...@@ -133,6 +137,15 @@ int main(int argc, char **argv) { ...@@ -133,6 +137,15 @@ int main(int argc, char **argv) {
pub_bins.publish(bins_msg); pub_bins.publish(bins_msg);
std_msgs::String locs_msg;
bins_msg.data = locs.empty() ? "" :
std::accumulate(
++locs.begin(), locs.end(),
*locs.begin(),
[](auto &a, auto &b) { return a + "," + b; });
pub_locations.publish(locs_msg);
if (autoselect) { if (autoselect) {
if (objects.empty()) { if (objects.empty()) {
ROS_INFO("No objects to select in a scene without boxes!"); ROS_INFO("No objects to select in a scene without boxes!");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment