Skip to content

Commit

Permalink
feat(joy_controller): allow to control without odometry (#6000)
Browse files Browse the repository at this point in the history
* feat(joy_controller): allow to control without odometry

Signed-off-by: amadeuszsz <[email protected]>

* style(pre-commit): autofix

---------

Signed-off-by: amadeuszsz <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
amadeuszsz and pre-commit-ci[bot] authored Dec 31, 2023
1 parent 3b6dad3 commit ed8ffea
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions control/joy_controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
| `steering_angle_velocity` | double | steering angle velocity for operation |
| `accel_sensitivity` | double | sensitivity to calculate acceleration for external API (commanded acceleration is pow(operation, 1 / sensitivity)) |
| `brake_sensitivity` | double | sensitivity to calculate deceleration for external API (commanded acceleration is pow(operation, 1 / sensitivity)) |
| `raw_control` | bool | skip input odometry if true |
| `velocity_gain` | double | ratio to calculate velocity by acceleration |
| `max_forward_velocity` | double | absolute max velocity to go forward |
| `max_backward_velocity` | double | absolute max velocity to go backward |
Expand Down
1 change: 1 addition & 0 deletions control/joy_controller/config/joy_controller.param.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
accel_sensitivity: 1.0
brake_sensitivity: 1.0
control_command:
raw_control: false
velocity_gain: 3.0
max_forward_velocity: 20.0
max_backward_velocity: 3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class AutowareJoyControllerNode : public rclcpp::Node
double brake_sensitivity_;

// ControlCommand Parameter
bool raw_control_;
double velocity_gain_;
double max_forward_velocity_;
double max_backward_velocity_;
Expand Down
6 changes: 6 additions & 0 deletions control/joy_controller/schema/joy_controller.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
"control_command": {
"type": "object",
"properties": {
"raw_control": {
"type": "boolean",
"description": "Whether to skip input odometry",
"default": false
},
"velocity_gain": {
"type": "number",
"description": "Ratio to calculate velocity by acceleration",
Expand All @@ -79,6 +84,7 @@
}
},
"required": [
"raw_control",
"velocity_gain",
"max_forward_velocity",
"max_backward_velocity",
Expand Down
15 changes: 10 additions & 5 deletions control/joy_controller/src/joy_controller/joy_controller_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ bool AutowareJoyControllerNode::isDataReady()
}

// Twist
{
if (!raw_control_) {
if (!twist_) {
RCLCPP_WARN_THROTTLE(
get_logger(), *get_clock(), std::chrono::milliseconds(5000).count(),
Expand Down Expand Up @@ -461,6 +461,7 @@ AutowareJoyControllerNode::AutowareJoyControllerNode(const rclcpp::NodeOptions &
steering_angle_velocity_ = declare_parameter<double>("steering_angle_velocity");
accel_sensitivity_ = declare_parameter<double>("accel_sensitivity");
brake_sensitivity_ = declare_parameter<double>("brake_sensitivity");
raw_control_ = declare_parameter<bool>("control_command.raw_control");
velocity_gain_ = declare_parameter<double>("control_command.velocity_gain");
max_forward_velocity_ = declare_parameter<double>("control_command.max_forward_velocity");
max_backward_velocity_ = declare_parameter<double>("control_command.max_backward_velocity");
Expand All @@ -480,10 +481,14 @@ AutowareJoyControllerNode::AutowareJoyControllerNode(const rclcpp::NodeOptions &
sub_joy_ = this->create_subscription<sensor_msgs::msg::Joy>(
"input/joy", 1, std::bind(&AutowareJoyControllerNode::onJoy, this, std::placeholders::_1),
subscriber_option);
sub_odom_ = this->create_subscription<nav_msgs::msg::Odometry>(
"input/odometry", 1,
std::bind(&AutowareJoyControllerNode::onOdometry, this, std::placeholders::_1),
subscriber_option);
if (!raw_control_) {
sub_odom_ = this->create_subscription<nav_msgs::msg::Odometry>(
"input/odometry", 1,
std::bind(&AutowareJoyControllerNode::onOdometry, this, std::placeholders::_1),
subscriber_option);
} else {
twist_ = std::make_shared<geometry_msgs::msg::TwistStamped>();
}

// Publisher
pub_control_command_ =
Expand Down

0 comments on commit ed8ffea

Please sign in to comment.