You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The last update I made to the ROS2 stuff was incorporating a YAML config file. The yaml file is located under params_pkg/params/robot_params.yaml and a change needs to be made to the tank control package so it works in your enviornment. This line in the tank_control_pkg/tank_control_pkg/tank_control.py file needs line 88 change to your environment : self.config = self.load_yaml_config("/home/jeffh/ros2_ws/src/params_pkg/params/robot_params.yaml")
In my case you can see my home folder is jeffh, that is probably what needs to be changed on yours as well.
Looks like the same needs to be changed for the robot_peripherals_pkg.py as well. Line 19 self.config = self.load_yaml_config("/home/jeffh/ros2_ws/src/params_pkg/params/robot_params.yaml")
Is there a way for us to use a yaml config file without having to change the code to the correct user's home folder?
The text was updated successfully, but these errors were encountered:
I swear I tried that but I think ROS2 had issues with it??? I will definitely try it again because that seems easier than the other solutions I'm finding.
To effectively use ~ as a reference to the home directory in your ROS2 application, you need to manually expand it in the code that reads the YAML file. Here's how you might do it in Python:
import os
import yaml
with open('config.yaml', 'r') as file:
config = yaml.safe_load(file)
config['path'] = os.path.expanduser(config['path'])
The os.path.expanduser function is specifically designed to expand ~ to the current user's home directory. By doing this in your code, you allow ~ in your YAML file to behave as users might expect, similar to its behavior in the shell.
The last update I made to the ROS2 stuff was incorporating a YAML config file. The yaml file is located under params_pkg/params/robot_params.yaml and a change needs to be made to the tank control package so it works in your enviornment. This line in the tank_control_pkg/tank_control_pkg/tank_control.py file needs line 88 change to your environment : self.config = self.load_yaml_config("/home/jeffh/ros2_ws/src/params_pkg/params/robot_params.yaml")
In my case you can see my home folder is jeffh, that is probably what needs to be changed on yours as well.
Looks like the same needs to be changed for the robot_peripherals_pkg.py as well. Line 19 self.config = self.load_yaml_config("/home/jeffh/ros2_ws/src/params_pkg/params/robot_params.yaml")
Is there a way for us to use a yaml config file without having to change the code to the correct user's home folder?
The text was updated successfully, but these errors were encountered: