Hello,
I am trying to read the Parameters from file for Exercise 6.1, but I dont understand how that should be done. I’d appreciate some help so I can proceed.
I’ve manually fixed the params in: /home/simulations/public_sim_ws/src/all/openai_ros/openai_ros/src/openai_ros/task_envs/cartpole_stay_up/stay_up.py
but I’d like a better solution for the furutre obviously. So I’d still ike to know.
stay healthy
Hi,
So paramateres are normally loaded like this:
self.min_pole_angle = rospy.get_param(‘/cartpole_v0/min_pole_angle’)
This is loading form the parame server. And these values are loaded in tah param server with a yaml file like so:
def LoadYamlFileParamsTest(rospackage_name, rel_path_from_package_to_file, yaml_file_name):
rospack = rospkg.RosPack()
pkg_path = rospack.get_path(rospackage_name)
config_dir = os.path.join(pkg_path, rel_path_from_package_to_file)
path_config_file = os.path.join(config_dir, yaml_file_name)
paramlist=rosparam.load_file(path_config_file)
for params, ns in paramlist:
rosparam.upload_params(ns,params)
In your file
LoadYamlFileParamsTest(
rospackage_name="openai_ros",
rel_path_from_package_to_file="src/openai_ros/task_envs/cartpole_stay_up/config",
yaml_file_name="stay_up.yaml")
You can also load the yaml file directly when launching the launch file
As you wish 
1 Like
Thank you for your reply.
In the current module I’m not using a launch file, but directly executing a python script, so doing it this way isn’t an option.
Should the file that I specify in the code given above include the example you gave under “In your file” or should it be the yaml file to read the params from?