Skip to content

Commit

Permalink
refactor(dummy_infrastructure): rework parameters (#5275)
Browse files Browse the repository at this point in the history
Signed-off-by: Yuntianyi Chen <[email protected]>
  • Loading branch information
yuntianyi-chen authored Jul 11, 2024
1 parent 9f41bf1 commit b038006
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 14 deletions.
4 changes: 2 additions & 2 deletions system/dummy_infrastructure/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ rclcpp_components_register_node(dummy_infrastructure_node_component

ament_auto_package(
INSTALL_TO_SHARE
config
launch
launch
config
)
3 changes: 2 additions & 1 deletion system/dummy_infrastructure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ ros2 run rqt_reconfigure rqt_reconfigure

| Name | Type | Default Value | Explanation |
| ------------------- | ------ | ------------- | ------------------------------------------------- |
| `update_rate` | int | `10` | Timer callback period [Hz] |
| `update_rate` | double | `10.0` | Timer callback period [Hz] |
| `use_first_command` | bool | `true` | Consider instrument id or not |
| `use_command_state` | bool | `false` | Consider command state or not |
| `instrument_id` | string | `` | Used as command id |
| `approval` | bool | `false` | set approval filed to ros param |
| `is_finalized` | bool | `false` | Stop at stop_line if finalization isn't completed |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**:
ros__parameters:
update_rate_hz: 10.0
use_first_command: false
use_command_state: true
instrument_id: '0'
approval: true
is_finalized: true
use_first_command: true
use_command_state: false
instrument_id: ""
approval: false
is_finalized: false
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<launch>
<!-- Input -->
<arg name="input/command_array" default="/planning/scenario_planning/status/infrastructure_commands"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Parameters for Dummy Infrastructure Node",
"type": "object",
"definitions": {
"dummy_infrastructure": {
"type": "object",
"properties": {
"update_rate_hz": {
"type": "number",
"default": "10.0",
"description": "Timer callback period [Hz]"
},
"use_first_command": {
"type": "boolean",
"default": "true",
"description": "Consider instrument id or not"
},
"use_command_state": {
"type": "boolean",
"default": "false",
"description": "Consider command state or not"
},
"instrument_id": {
"type": "string",
"default": "",
"description": "Used as command id"
},
"approval": {
"type": "boolean",
"default": "false",
"description": "set approval filed to ros param"
},
"is_finalized": {
"type": "boolean",
"default": "false",
"description": "Stop at stop_line if finalization isn't completed"
}
},
"required": [
"update_rate_hz",
"use_first_command",
"use_command_state",
"instrument_id",
"approval",
"is_finalized"
],
"additionalProperties": false
}
},
"properties": {
"/**": {
"type": "object",
"properties": {
"ros__parameters": {
"$ref": "#/definitions/dummy_infrastructure"
}
},
"required": ["ros__parameters"],
"additionalProperties": false
}
},
"required": ["/**"],
"additionalProperties": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ DummyInfrastructureNode::DummyInfrastructureNode(const rclcpp::NodeOptions & nod
this->add_on_set_parameters_callback(std::bind(&DummyInfrastructureNode::onSetParam, this, _1));

// Parameter
node_param_.update_rate_hz = declare_parameter<double>("update_rate_hz", 10.0);
node_param_.use_first_command = declare_parameter<bool>("use_first_command", true);
node_param_.use_command_state = declare_parameter<bool>("use_command_state", false);
node_param_.instrument_id = declare_parameter<std::string>("instrument_id", "");
node_param_.approval = declare_parameter<bool>("approval", false);
node_param_.is_finalized = declare_parameter<bool>("is_finalized", false);
node_param_.update_rate_hz = declare_parameter<double>("update_rate_hz");
node_param_.use_first_command = declare_parameter<bool>("use_first_command");
node_param_.use_command_state = declare_parameter<bool>("use_command_state");
node_param_.instrument_id = declare_parameter<std::string>("instrument_id");
node_param_.approval = declare_parameter<bool>("approval");
node_param_.is_finalized = declare_parameter<bool>("is_finalized");

// Subscriber
sub_command_array_ = create_subscription<InfrastructureCommandArray>(
Expand Down

0 comments on commit b038006

Please sign in to comment.