24 from yaml
import CLoader
as Loader, CDumper
as Dumper
26 from yaml
import Loader, Dumper
32 Loads pid parameters of each controller in parameters_dict from a yaml file 40 if len(param_name) == 2:
42 tmp_dict = rospy.get_param(param_name[0])
45 for item
in tmp_dict.items():
46 param_dict[
"pos/" + item[0]] = item[1]
49 tmp_dict = rospy.get_param(param_name[1])
52 for item
in tmp_dict.items():
53 param_dict[
"vel/" + item[0]] = item[1]
56 param_dict = rospy.get_param(param_name)
65 Saves pid parameters of each controller in parameters_dict in a yaml file 72 f = open(self.
path,
'r') 74 for line
in f.readlines():
78 yaml_config = yaml.load(document)
80 for item
in parameters_dict.items():
82 yaml_config[param_path[0]][
"position_pid"][
83 item[0].split(
"pos/")[1]] = item[1]
84 elif "vel/" in item[0]:
85 yaml_config[param_path[0]][
"velocity_pid"][
86 item[0].split(
"vel/")[1]] = item[1]
88 yaml_config[param_path[0]][param_path[1]][item[0]] = item[1]
90 full_config_to_write = yaml.dump(yaml_config, default_flow_style=
False)
92 f = open(self.
path,
'w')
93 f.write(full_config_to_write)
96 if __name__ ==
'__main__':
99 path_to_config = os.path.join(
100 rospkg.RosPack().get_path(
"sr_edc_controller_configuration"))
103 path_to_config +
"/sr_edc_mixed_position_velocity_joint_controllers.yaml")
104 pid_saver.save_settings(
105 [
"sh_wrj2_mixed_position_velocity_controller",
"pid"], {
"d": 1.0})
108 "couldnt find the sr_edc_controller_configuration package")
def __init__(self, file_path)
def get_settings(self, param_name)
def save_settings(self, param_path, parameters_dict)