ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Concerning YAML and variables (your Scenario 1), you can use anchors (&) and references (*). This makes modifying YAML files easier when the same data is used multiple times in the same YAML file. In your case, this could look like:
defines:
- priority: &priority1 7
- priority: &priority2 4
subscribers:
- name: "Teleoperation"
topic: "input/teleop"
timeout: 1.0
priority: *priority1
- name: "Autonomouse Navigation"
topic: "input/move_base"
timeout: 2.0
priority: *priority2
You can check the result online. However, if you want to achieve a more complex behavior, AFAIK there is no equivalent to xacro in YAML. Also, anchors/references do not work across multiple files.
2 | No.2 Revision |
Concerning YAML and variables (your Scenario 1), you can use anchors (&) and references (*). This makes modifying YAML files easier when the same data is used multiple times in the same YAML file. In your case, this could look like:
defines:
- priority: &priority1 \&priority1 7
- priority: &priority2 \&priority2 4
subscribers:
- name: "Teleoperation"
topic: "input/teleop"
timeout: 1.0
priority: *priority1
- name: "Autonomouse Navigation"
topic: "input/move_base"
timeout: 2.0
priority: *priority2
You can check the result online. However, if you want to achieve a more complex behavior, AFAIK there is no equivalent to xacro in YAML. Also, anchors/references do not work across multiple files.
3 | No.3 Revision |
Concerning YAML and variables (your Scenario 1), you can use anchors (&) and references (*). This makes modifying YAML files easier when the same data is used multiple times in the same YAML file. In your case, this could look like:
defines:
- priority: \&priority1 &priority1 7
- priority: \&priority2 &priority2 4
subscribers:
- name: "Teleoperation"
topic: "input/teleop"
timeout: 1.0
priority: *priority1
- name: "Autonomouse Navigation"
topic: "input/move_base"
timeout: 2.0
priority: *priority2
(& is escaped for some reason)
You can check the result online. However, if you want to achieve a more complex behavior, AFAIK there is no equivalent to xacro in YAML. Also, anchors/references do not work across multiple files.
4 | No.4 Revision |
Concerning YAML and variables (your Scenario 1), you can use anchors (&) and references (*). This makes modifying YAML files easier when the same data is used multiple times in the same YAML file. In your case, this could look like:
defines: - priority: &priority1 7 - priority: &priority244 subscribers: - name: "Teleoperation" topic: "input/teleop" timeout: 1.0 priority: *priority1 - name: "Autonomouse Navigation" topic: "input/move_base" timeout: 2.0 priority: *priority2
(& is escaped to & for some reason)
You can check the result online. However, if you want to achieve a more complex behavior, AFAIK there is no equivalent to xacro in YAML. Also, anchors/references do not work across multiple files.
5 | No.5 Revision |
Concerning YAML and variables (your Scenario 1), you can use anchors (&) and references (*). This makes modifying YAML files easier when the same data is used multiple times in the same YAML file. In your case, this could look like:
defines: - priority: &priority1 7 - priority: &priority2 4subscribers: - name: "Teleoperation" topic: "input/teleop" timeout: 1.0 priority: *priority1 - name: "Autonomouse Navigation" topic: "input/move_base" timeout: 2.0 priority: *priority2
(& is escaped to & for some reason)
You can check the result online. However, if you want to achieve a more complex behavior, AFAIK there is no equivalent to xacro in YAML. Also, anchors/references do not work across multiple files.
6 | No.6 Revision |
Concerning YAML and variables (your Scenario 1), you can use anchors (&) and references (*). This makes modifying YAML files easier when the same data is used multiple times in the same YAML file. In your case, this could look like:
defines: - priority: &priority1 7 - priority: &priority2 4subscribers: - name: "Teleoperation" topic: "input/teleop" timeout: 1.0 priority: *priority1 - name: "Autonomouse Navigation" topic: "input/move_base" timeout: 2.0 priority: *priority2
You can check the result online. However, if you want to achieve a more complex behavior, AFAIK there is no equivalent to xacro in YAML. YAML, but you could generate YAML files with a Python script, it's quite simple. Also, anchors/references do not work across multiple files.
7 | No.7 Revision |
Concerning YAML and variables (your Scenario 1), you can use anchors (&) and references (*). This makes modifying YAML files easier when the same data is used multiple times in the same YAML file. file (anchors/references do not work across multiple files). In your case, this could look like:
defines: - priority: &priority1 7 - priority: &priority2 4subscribers: - name: "Teleoperation" topic: "input/teleop" timeout: 1.0 priority: *priority1 - name: "Autonomouse Navigation" topic: "input/move_base" timeout: 2.0 priority: *priority2
You can check the result online. However, if you want to achieve a more complex behavior, AFAIK there is no equivalent to xacro in YAML, but you could generate YAML files with a Python script, it's quite simple. Also, anchors/references do not work across multiple files.
import yaml
def generate_subscriber(s_name, s_topic, s_timeout, s_priority):
return dict(name = s_name,
topic = s_topic,
timeout = s_timeout,
priority = s_priority)
data = dict(
subscribers = tuple([
generate_subscriber("Teleoperation", "input/teleop", 1.0, 7),
generate_subscriber("Autonomous Navigation", "input/move_base", 2.0, 4)
])
)
with open('data.yml', 'w') as outfile:
outfile.write(yaml.safe_dump(data, default_flow_style=False))
8 | No.8 Revision |
Concerning YAML and variables (your Scenario 1), you can use anchors (&) and references (*). This makes modifying YAML files easier when the same data is used multiple times in the same YAML file (anchors/references do not work across multiple files). In your case, this could look like:
defines: - priority: &priority1 7 - priority: &priority2 4subscribers: - name: "Teleoperation" topic: "input/teleop" timeout: 1.0 priority: *priority1 - name: "Autonomouse Navigation" topic: "input/move_base" timeout: 2.0 priority: *priority2
You can check the result online. However, if you want to achieve a more complex behavior, there is no equivalent to xacro in YAML, but you could generate YAML files with a Python script, it's quite simple and you could use a modified version of this:
import yaml
def generate_subscriber(s_name, s_topic, s_timeout, s_priority):
return dict(name = s_name,
topic = s_topic,
timeout = s_timeout,
priority = s_priority)
data = dict(
subscribers = tuple([
generate_subscriber("Teleoperation", "input/teleop", 1.0, 7),
generate_subscriber("Autonomous Navigation", "input/move_base", 2.0, 4)
])
)
with open('data.yml', open('data.yaml', 'w') as outfile:
outfile.write(yaml.safe_dump(data, default_flow_style=False))
9 | No.9 Revision |
Concerning YAML and variables (your Scenario 1), you can use anchors (&) and references (*). This makes modifying YAML files easier when the same data is used multiple times in the same YAML file (anchors/references do not work across multiple files). In your case, this could look like:
defines: - priority: &priority1 7 - priority: &priority2 4subscribers: - name: "Teleoperation" topic: "input/teleop" timeout: 1.0 priority: *priority1 - name: "Autonomouse Navigation" topic: "input/move_base" timeout: 2.0 priority: *priority2
You can check the result online. However, if you want to achieve a more complex behavior, there is no equivalent to xacro in YAML, but you could generate YAML files with a Python script, it's quite simple and you could use a modified version of this:
#!/usr/bin/env python2
import yaml
def generate_subscriber(s_name, s_topic, s_timeout, s_priority):
return dict(name = s_name,
topic = s_topic,
timeout = s_timeout,
priority = s_priority)
data = dict(
subscribers = tuple([
generate_subscriber("Teleoperation", "input/teleop", 1.0, 7),
generate_subscriber("Autonomous Navigation", "input/move_base", 2.0, 4)
])
)
with open('data.yaml', 'w') as outfile:
outfile.write(yaml.safe_dump(data, default_flow_style=False))