I kinda gave up on finding a solution using C++, so I sticked with python, but if someone knows how to do it using C++ then I would be happy to hear.
For people interested in the same topic, then I have applied the code below for reading the parameter server and publish the values, so far only for simple data types. I am using my own message types to publish the data, which contain the name and a value, which is either int, float, bool or a string.
#!/usr/bin/env python
import roslib
roslib.load_manifest('ros_rws_plugin')
import sys
import rospy
from ros_rws_plugin.msg import *
def main(args):
rospy.init_node('read_param')
pub_int = rospy.Publisher('parameter/int', propertyInt )
pub_float = rospy.Publisher('parameter/float', propertyFloat )
pub_bool = rospy.Publisher('parameter/bool', propertyBool )
pub_str = rospy.Publisher('parameter/string', propertyString )
rospy.set_param("int", 2)
rospy.set_param("float", 2.2)
r = rospy.Rate(5)
while not rospy.is_shutdown():
names = rospy.get_param_names()
for name in names:
if type( rospy.get_param(name) ) is int :
pub_int.publish( propertyName=name, propertyValue=rospy.get_param(name) )
elif type( rospy.get_param(name) ) is float :
pub_float.publish( propertyName=name, propertyValue=rospy.get_param(name) )
elif type( rospy.get_param(name) ) is bool :
pub_bool.publish( propertyName=name, propertyValue=rospy.get_param(name) )
elif type( rospy.get_param(name) ) is str :
pub_str.publish( propertyName=name, propertyValue=rospy.get_param(name) )
r.sleep()
if __name__ == '__main__':
main(sys.argv)