Skip to content

Commit

Permalink
chore(twist2accel): rework parameters (autowarefoundation#6266)
Browse files Browse the repository at this point in the history
* Added twist2accel.param.yaml

Signed-off-by: Shintaro SAKODA <[email protected]>

* Added twist2accel.schema.json

Signed-off-by: Shintaro SAKODA <[email protected]>

* Fixed README.md and description

Signed-off-by: Shintaro SAKODA <[email protected]>

* style(pre-commit): autofix

* Removed default parameters

Signed-off-by: Shintaro SAKODA <[email protected]>

---------

Signed-off-by: Shintaro SAKODA <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and karishma1911 committed Jun 3, 2024
1 parent 6e38a96 commit ff867c7
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

<group>
<include file="$(find-pkg-share twist2accel)/launch/twist2accel.launch.xml">
<arg name="use_odom" value="true"/>
<arg name="in_odom" value="/localization/kinematic_state"/>
<arg name="in_twist" value="/localization/twist_estimator/twist_with_covariance"/>
<arg name="out_accel" value="/localization/acceleration"/>
<arg name="param_file" value="$(var twist2accel_param_path)"/>
</include>
</group>

Expand Down
1 change: 1 addition & 0 deletions localization/twist2accel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ ament_target_dependencies(twist2accel)
ament_auto_package(
INSTALL_TO_SHARE
launch
config
)
5 changes: 1 addition & 4 deletions localization/twist2accel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ This package is responsible for estimating acceleration using the output of `ekf

## Parameters

| Name | Type | Description |
| -------------------- | ------ | ------------------------------------------------------------------------- |
| `use_odom` | bool | use odometry if true, else use twist input (default: true) |
| `accel_lowpass_gain` | double | lowpass gain for lowpass filter in estimating acceleration (default: 0.9) |
{{ json_to_markdown("localization/twist2accel/schema/twist2accel.schema.json") }}

## Future work

Expand Down
4 changes: 4 additions & 0 deletions localization/twist2accel/config/twist2accel.param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**:
ros__parameters:
use_odom: true
accel_lowpass_gain: 0.9
7 changes: 3 additions & 4 deletions localization/twist2accel/launch/twist2accel.launch.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<launch>
<arg name="use_odom" default="true"/>
<arg name="accel_lowpass_gain" default="0.9"/>
<arg name="param_file" default="$(find-pkg-share twist2accel)/config/twist2accel.param.yaml"/>

<arg name="in_odom" default="in_odom"/>
<arg name="in_twist" default="in_twist"/>
<arg name="out_accel" default="out_accel"/>
<node pkg="twist2accel" exec="twist2accel" name="twist2accel" output="screen">
<remap from="input/odom" to="$(var in_odom)"/>
<remap from="input/twist" to="$(var in_twist)"/>
<remap from="output/accel" to="$(var out_accel)"/>
<param name="accel_lowpass_gain" value="$(var accel_lowpass_gain)"/>
<param name="use_odom" value="$(var use_odom)"/>
<param from="$(var param_file)"/>
</node>
</launch>
36 changes: 36 additions & 0 deletions localization/twist2accel/schema/twist2accel.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Parameters for twist2accel Nodes",
"type": "object",
"definitions": {
"twist2accel": {
"type": "object",
"properties": {
"use_odom": {
"type": "boolean",
"default": true,
"description": "use odometry if true, else use twist input."
},
"accel_lowpass_gain": {
"type": "number",
"default": 0.9,
"minimum": 0.0,
"description": "lowpass gain for lowpass filter in estimating acceleration."
}
},
"required": ["use_odom", "accel_lowpass_gain"]
}
},
"properties": {
"/**": {
"type": "object",
"properties": {
"ros__parameters": {
"$ref": "#/definitions/twist2accel"
}
},
"required": ["ros__parameters"]
}
},
"required": ["/**"]
}
4 changes: 2 additions & 2 deletions localization/twist2accel/src/twist2accel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Twist2Accel::Twist2Accel(const std::string & node_name, const rclcpp::NodeOption
pub_accel_ = create_publisher<geometry_msgs::msg::AccelWithCovarianceStamped>("output/accel", 1);

prev_twist_ptr_ = nullptr;
accel_lowpass_gain_ = declare_parameter("accel_lowpass_gain", 0.5);
use_odom_ = declare_parameter("use_odom", true);
accel_lowpass_gain_ = declare_parameter<double>("accel_lowpass_gain");
use_odom_ = declare_parameter<bool>("use_odom");

lpf_alx_ptr_ = std::make_shared<LowpassFilter1d>(accel_lowpass_gain_);
lpf_aly_ptr_ = std::make_shared<LowpassFilter1d>(accel_lowpass_gain_);
Expand Down

0 comments on commit ff867c7

Please sign in to comment.