Passing server parameter to private NodeHandle (AprilTags library)

asked 2016-04-11 13:20:55 -0600

wardac gravatar image

I'm trying to pass what I think is a global parameter from the parameter stack to a private NodeHandle. I searched and couldn't find anything on this, but I'm fairly new to ROS, so I may have missed something. There aren't any tutorials on the AprilTags library, so I can't find any sample projects either.

I have the following main function, which will involve a parameter called "tag_descriptions":

#include <apriltags_ros/apriltag_detector.h>
#include <ros/ros.h>
int main(int argc, char **argv){
          ros::init(argc, argv, "apriltag_detector");
          ros::NodeHandle nh;
          ros::NodeHandle pnh("~"); //Need to pass the parameter to this private NodeHandle
         apriltags_ros::AprilTagDetector detector(nh, pnh); //this function ends up using the param
         ros::spin();
}

Here's the relevant part of the function that involves the parameter

AprilTagDetector::AprilTagDetector(ros::NodeHandle& nh, ros::NodeHandle& pnh): it_(nh){
         XmlRpc::XmlRpcValue april_tag_descriptions;
         if(!pnh.getParam("tag_descriptions", april_tag_descriptions)){ //I need to set this param
                       ROS_WARN("No april tags specified"); //I keep getting this message
           }
         else{
                      try{
                                  descriptions_ = parse_tag_descriptions(april_tag_descriptions);
                            } catch(XmlRpc::XmlRpcException e)
                                {
                                ROS_ERROR_STREAM("Error loading tag descriptions: "<<e.getMessage());
                                  }

                 } //function goes on after this but it's not relevant to this question

Dat dere

I need to set it as a XmlRpc::XmlRpcValue::TypeArray Each array element will consist of a struct containing an int and a double. I know this because the following code is called later

 ROS_ASSERT(tag_description.getType() == XmlRpc::XmlRpcValue::TypeStruct);
ROS_ASSERT(tag_description["id"].getType() == XmlRpc::XmlRpcValue::TypeInt);
ROS_ASSERT(tag_description["size"].getType() == XmlRpc::XmlRpcValue::TypeDouble);

I tried to set it as the following, but it didn't work

rosparam set pnh~/tag_descriptions [[5,1.1]]
rosparam set tag_descriptions [[5, 1.1]]

How can I set this? I just want to get it working with a sample value.
Thanks

edit retag flag offensive close merge delete