NodeHandle::getParam() is unable to resolve Environmental variables
I have a launchfile in which I want to specify the path to a specific file, e.g. haarcascade_frontalface_alt.xml
. Normally, I would just use the <param>
tag like this:
<param name="haarcascade_filename" type="string" value="$(env ROS_ROOT)/../OpenCV/haarcascades/haarcascade_frontalface_alt.xml" />
and try to load it during initialization using NodeHandle::param()
:
ros::NodeHandle local_nh("~");
local_nh.param("haarcascade_filename", name_, std::string(""));
This is the way it is done for example in the face_detector
stack. Assume that I now want to specify multiple files using a <rosparam>
list:
<rosparam param="haarcascade_filename_list">["$(env ROS_ROOT)/../OpenCV/haarcascades/haarcascade_frontalface_alt.xml", "morestrings.."]</rosparam>
This is the way I'm trying to load all the entries of the list:
XmlRpc::XmlRpcValue my_xmlrpc_haarlist;
local_nh.getParam("haarcascade_filename_list", my_xmlrpc_haarlist);
ROS_ASSERT(my_xmlrpc_haarlist.getType() == XmlRpc::XmlRpcValue::TypeArray);
for (int32_t i = 0; i < my_xmlrpc_haarlist.size(); ++i) {
ROS_ASSERT(my_xmlrpc_haarlist[i].getType() == XmlRpc::XmlRpcValue::TypeString);
haar_filename_list_.push_back(static_cast<std::string> (my_xmlrpc_haarlist[i]));
}
The problem is if I now do ROS_INFO_STREAM("Filename: " << supername_);
and ROS_INFO_STREAM("Filename list: " << haar_filename_list_.at(0));
the results are not the same:
[ INFO] [1354712164.859028413]: Filename: /opt/ros/fuerte/share/ros/../OpenCV/haarcascades/haarcascade_frontalface_alt.xml
[ INFO] [1354712164.859087292]: Filename list: $(env ROS_ROOT)/../OpenCV/haarcascades/haarcascade_frontalface_alt.xml
How do I solve this issue?