Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(twist2accel): rework parameters #6266

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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");

Check warning on line 39 in localization/twist2accel/src/twist2accel.cpp

View check run for this annotation

Codecov / codecov/patch

localization/twist2accel/src/twist2accel.cpp#L38-L39

Added lines #L38 - L39 were not covered by tests

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