Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiple frame prefixes #126

Open
wants to merge 2 commits into
base: indigo-devel
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions nodes/IndividualMarkers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ double max_track_error;
std::string cam_image_topic;
std::string cam_info_topic;
std::string output_frame;
std::string frame_prefix;
int marker_resolution = 5; // default marker resolution
int marker_margin = 2; // default marker margin

Expand Down Expand Up @@ -392,7 +393,7 @@ void getPointCloudCallback (const sensor_msgs::PointCloud2ConstPtr &msg)
tf::Transform markerPose = t * m; // marker pose in the camera frame

//Publish the transform from the camera to the marker
std::string markerFrame = "ar_marker_";
std::string markerFrame = frame_prefix + "ar_marker_";
std::stringstream out;
out << id;
std::string id_string = out.str();
Expand Down Expand Up @@ -521,6 +522,8 @@ int main(int argc, char *argv[])
marker_resolution = atoi(argv[8]);
if (argc > 9)
marker_margin = atoi(argv[9]);
if (argc > 10)
frame_prefix = argv[10];

} else {
// Get params from ros param server.
Expand All @@ -544,6 +547,13 @@ int main(int argc, char *argv[])
cam_info_topic = "camera_info";
}

if(frame_prefix == "" && pn.param("frame_prefix", frame_prefix) == "") {
ROS_ERROR("Param 'frame_prefix' has to be set to prevent ar conflicts");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why enforcing the prefix?

Many people use only one camera.

exit(EXIT_FAILURE);
} else {
ROS_INFO("frame_prefix is '%s'", frame_prefix.c_str());
}

// Set dynamically configurable parameters so they don't get replaced by default values
pn.setParam("marker_size", marker_size);
pn.setParam("max_new_marker_error", max_new_marker_error);
Expand Down Expand Up @@ -577,7 +587,7 @@ int main(int argc, char *argv[])
if (enabled == true)
{
// This always happens, as enable is true by default
ROS_INFO("Subscribing to image topic");
ROS_INFO("Subscribing to image topic: %s", cam_image_topic.c_str());
cloud_sub_ = n.subscribe(cam_image_topic, 1, &getPointCloudCallback);
}

Expand Down