[issue #892] Created Config library for read Yaml config files#916
Conversation
… instead of ice files
…tead of ice config files
|
Dear @aitormf, I have a quick question about the yaml config. For the components we have three constructs about ice interfaces; interface, proxyName, name. Which part of these corresponds to values of yaml values? For the following example: Motors just under demo is interface, Motors inside Proxy is proxyName, name is the Name: |
|
Hi @okanasik, yes, fields are as you say, but if you want, you can have two motor interfaces, for example kobukiViewer tool has a two camera interfaces and its config file is the following: kobukiViewer:
Motors:
Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS
Proxy: "Motors:default -h localhost -p 9001"
Topic: "/turtlebotROS/mobile_base/commands/velocity"
Name: kobukiViewerMotors
maxV: 3
maxW: 0.7
Camera1:
Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS
Proxy: "CameraL:default -h localhost -p 9001"
Format: RGB8
Topic: "/TurtlebotROS/cameraL/image_raw"
Name: kobukiViewerCamera1
Camera2:
Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS
Proxy: "CameraR:default -h localhost -p 9001"
Format: RGB8
Topic: "/TurtlebotROS/cameraR/image_raw"
Name: kobukiViewerCamera2
Pose3D:
Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS
Proxy: "Pose3D:default -h localhost -p 9001"
Topic: "//turtlebotROS/odom"
Name: kobukiViewerPose3d
Laser:
Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS
Proxy: "Laser:default -h localhost -p 9001"
Topic: "/turtlebotROS/laser/scan"
Name: kobukiViewerLaser
Vmax: 3
Wmax: 0.7
NodeName: kobukiViewer
With motors would be the same. |
|
Thanks @aitormf , The config dialog of visualStates was directly using interface to determine the type of comm client that will be instantiated. In that case, I can add indexes for every interface. Best. |
In this PR I maked 2 new libraries (config_cpp and config_py) to read Yaml config files. in their directories you can find a demo programs to show how can you use those libraries.
C++:
#include ... Config::Properties props = Config::load(argc, argv); std::cout << props << std::endl; std::cout << props.asString("Demo.Motors.Proxy")<< std::endl; std::cout << props.asStringWithDefault("Demo.Motors.Proxy2", "Proxy2")<< std::endl;Python:
import config .... cfg = config.load(sys.argv[1]) print (cfg.getProperty("Demo.Motors.Server")) print (cfg.getPropertyWithDefault("Demo.Motors.Server2", "Server2")) print cfga example of new config files is the following:
Demo: Motors: Server: 2 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS Proxy: "Motors:default -h localhost -p 9001" Topic: "/turtlebotROS/mobile_base/commands/velocity" Name: basic_component_pyCamera maxW: 0.7 maxV: 4 Camera: Server: 2 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS Proxy: "CameraL:default -h localhost -p 9001" Format: RGB8 Topic: "/TurtlebotROS/cameraL/image_raw" Name: basic_component_pyCamera NodeName: demoJdeRobotComm (py and C++) has also been modified:
Python
import config import comm ... cfg = config.load(sys.argv[1]) jdrc= comm.init(cfg, "Test") client = jdrc.getCameraClient("Test.Camera1")C++