Modified FindAnchors.srv to specify multiple IDs using a vector.
This commit is contained in:
Родитель
00363c67f6
Коммит
5e692014f1
|
@ -1,6 +1,10 @@
|
|||
cmake_minimum_required(VERSION 2.8.3)
|
||||
project(asa_ros)
|
||||
|
||||
# Deprecation Warning
|
||||
message(DEPRECATION "The anchor_id member of FindAnchor.srv is deprecated and will be \
|
||||
removed in a future release. Use the anchor_ids vector member instead.")
|
||||
|
||||
add_definitions(-std=c++1z)
|
||||
|
||||
find_package(catkin_simple REQUIRED)
|
||||
|
|
|
@ -62,6 +62,11 @@ class AsaRosNode {
|
|||
bool resetCallback(std_srvs::EmptyRequest& req, std_srvs::EmptyResponse& res);
|
||||
bool resetCompletelyCallback(std_srvs::EmptyRequest& req,
|
||||
std_srvs::EmptyResponse& res);
|
||||
|
||||
// Helper function which converts a vector of IDs into a
|
||||
// single comma-separated string, of the sort expected by
|
||||
// AsaRosNode::queryAnchors()
|
||||
std::string convertIdVectorToString(const std::vector<std::string>& vec) const;
|
||||
|
||||
// Wrappers for commonly-used calls to the interface.
|
||||
// Queries COMMA-SEPARATED list of anchor IDs, and caches them in case the
|
||||
|
|
|
@ -279,7 +279,18 @@ bool AsaRosNode::createAnchorCallback(asa_ros_msgs::CreateAnchorRequest& req,
|
|||
|
||||
bool AsaRosNode::findAnchorCallback(asa_ros_msgs::FindAnchorRequest& req,
|
||||
asa_ros_msgs::FindAnchorResponse& res) {
|
||||
queryAnchors(req.anchor_id);
|
||||
// anchor_id is deprecated but still supported for now
|
||||
// if the client leaves it empty, use the new vector member instead
|
||||
if (req.anchor_id.empty()) {
|
||||
queryAnchors(convertIdVectorToString(req.anchor_ids));
|
||||
}
|
||||
else {
|
||||
ROS_WARN_ONCE("The anchor_id member of FindAnchor.srv is deprecated and will be "
|
||||
"removed in a future release. Use the anchor_ids vector member instead.");
|
||||
|
||||
queryAnchors(req.anchor_id);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -302,6 +313,25 @@ void AsaRosNode::anchorCreatedCallback(bool success,
|
|||
}
|
||||
}
|
||||
|
||||
std::string AsaRosNode::convertIdVectorToString(const std::vector<std::string>& vec) const
|
||||
{
|
||||
std::stringstream output;
|
||||
|
||||
const size_t last_index = vec.size() - 1;
|
||||
const char separator = ',';
|
||||
|
||||
for (int i = 0; i < vec.size(); ++i) {
|
||||
output << vec.at(i);
|
||||
|
||||
// if this is not the last element, add the separator
|
||||
if (i != last_index) {
|
||||
output << separator;
|
||||
}
|
||||
}
|
||||
|
||||
return output.str();
|
||||
}
|
||||
|
||||
bool AsaRosNode::queryAnchors(const std::string& anchor_ids) {
|
||||
anchor_ids_ = anchor_ids;
|
||||
if (interface_->queryAnchorWithCallback(
|
||||
|
|
|
@ -2,5 +2,9 @@
|
|||
# created on the same Azure Spatial Anchors account as used in this ROS node.
|
||||
# Found anchors will be published on the /found_anchor topic.
|
||||
# Note that you can be searching for multiple anchors at once.
|
||||
string[] anchor_ids
|
||||
|
||||
# DEPRECATED: The anchor_id member is deprecated and will be removed in a future release.
|
||||
# Use the anchor_ids vector member instead.
|
||||
string anchor_id
|
||||
---
|
||||
|
|
Загрузка…
Ссылка в новой задаче