ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Check out the rospy parameter API:
http://wiki.ros.org/rospy/Overview/Parameter%20Server

Example (note, I have not tried running this code):

import rospy


urdf_filename = robot.urdf  
urdf_string = None
with open(urdf_filename) as urdf_file:  
    urdf_string = urdf_file.read()  

if urdf_string is not None:
    rospy.set_param('robot_description', urdf_filename)

# Check
if not rospy.has_param('robot_description'):
    rospy.login("Cannot find 'robot_description' on parameter server")
else:
    urdf_string_param = rospy.get_param('robot_description')
    rospy.login(urdf_string_param )

Check out the rospy parameter API:
http://wiki.ros.org/rospy/Overview/Parameter%20Server

Example (note, I have not tried running this code):

import rospy


rospy.init_node('my_node_name')

# Open .urdf and save contents as str
urdf_filename = robot.urdf  
"robot.urdf"
urdf_string = None
with open(urdf_filename) as urdf_file:  
    urdf_string = urdf_file.read()  

# Load urdf_string onto parameter server
if urdf_string is not None:
    rospy.set_param('robot_description', urdf_filename)

# Check
if not rospy.has_param('robot_description'):
    rospy.login("Cannot find 'robot_description' on parameter server")
else:
    urdf_string_param = rospy.get_param('robot_description')
    rospy.login(urdf_string_param )

Check out the rospy parameter API:
http://wiki.ros.org/rospy/Overview/Parameter%20Server

Example roscpp parameter API:
http://wiki.ros.org/roscpp/Overview/Parameter%20Server


rospy example (note, I have not tried running this code):

import rospy


rospy.init_node('my_node_name')

# Open .urdf and save contents as str
urdf_filename = "robot.urdf"
urdf_string = None
with open(urdf_filename) as urdf_file:  
    urdf_string = urdf_file.read()  

# Load urdf_string onto parameter server
if urdf_string is not None:
    rospy.set_param('robot_description', urdf_filename)

# Check
if not rospy.has_param('robot_description'):
    rospy.login("Cannot find 'robot_description' on parameter server")
else:
    urdf_string_param = rospy.get_param('robot_description')
    rospy.login(urdf_string_param )