Skip to content

Commit 6591c55

Browse files
committed
sub operation status
Signed-off-by: kosuke55 <kosuke.tnp@gmail.com>
1 parent 8762c12 commit 6591c55

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

vehicle/autoware_raw_vehicle_cmd_converter/include/autoware_raw_vehicle_cmd_converter/node.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <rclcpp/rclcpp.hpp>
2828

29+
#include <autoware_adapi_v1_msgs/msg/operation_mode_state.hpp>
2930
#include <autoware_control_msgs/msg/control.hpp>
3031
#include <autoware_vehicle_msgs/msg/steering_report.hpp>
3132
#include <geometry_msgs/msg/twist_stamped.hpp>
@@ -47,6 +48,7 @@ using tier4_vehicle_msgs::msg::ActuationStatusStamped;
4748
using TwistStamped = geometry_msgs::msg::TwistStamped;
4849
using Odometry = nav_msgs::msg::Odometry;
4950
using Steering = autoware_vehicle_msgs::msg::SteeringReport;
51+
using autoware_adapi_v1_msgs::msg::OperationModeState;
5052
using geometry_msgs::msg::AccelWithCovarianceStamped;
5153
class DebugValues
5254
{
@@ -89,6 +91,8 @@ class RawVehicleCommandConverterNode : public rclcpp::Node
8991
this, "~/input/odometry"};
9092
autoware::universe_utils::InterProcessPollingSubscriber<AccelWithCovarianceStamped> sub_accel_{
9193
this, "~/input/accel"};
94+
autoware::universe_utils::InterProcessPollingSubscriber<OperationModeState> sub_operation_mode_{
95+
this, "~/input/operation_mode_state"};
9296

9397
rclcpp::TimerBase::SharedPtr timer_;
9498

vehicle/autoware_raw_vehicle_cmd_converter/include/autoware_raw_vehicle_cmd_converter/vehicle_adaptor/vehicle_adaptor.hpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#ifndef AUTOWARE_RAW_VEHICLE_CMD_CONVERTER__VEHICLE_ADAPTOR__VEHICLE_ADAPTOR_HPP_
1616
#define AUTOWARE_RAW_VEHICLE_CMD_CONVERTER__VEHICLE_ADAPTOR__VEHICLE_ADAPTOR_HPP_
1717

18+
#include <autoware_adapi_v1_msgs/msg/operation_mode_state.hpp>
1819
#include <autoware_control_msgs/msg/control.hpp>
1920
#include <autoware_vehicle_msgs/msg/steering_report.hpp>
2021
#include <geometry_msgs/msg/accel_with_covariance_stamped.hpp>
@@ -23,6 +24,7 @@
2324
namespace autoware::raw_vehicle_cmd_converter
2425
{
2526

27+
using autoware_adapi_v1_msgs::msg::OperationModeState;
2628
using autoware_control_msgs::msg::Control;
2729
using autoware_vehicle_msgs::msg::SteeringReport;
2830
using geometry_msgs::msg::AccelWithCovarianceStamped;
@@ -35,7 +37,8 @@ class VehicleAdaptor
3537
Control compensate(
3638
const Control & input_control_cmd, [[maybe_unused]] const Odometry & odometry,
3739
[[maybe_unused]] const AccelWithCovarianceStamped & accel,
38-
[[maybe_unused]] const double steering);
40+
[[maybe_unused]] const double steering,
41+
[[maybe_unused]] const OperationModeState & operation_mode);
3942

4043
private:
4144
};

vehicle/autoware_raw_vehicle_cmd_converter/launch/raw_vehicle_converter.launch.xml

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<arg name="input_accel" default="/localization/acceleration"/>
66
<arg name="input_steering" default="/vehicle/status/steering_status"/>
77
<arg name="input_actuation_status" default="/vehicle/status/actuation_status"/>
8+
<arg name="input_operation_mode_state" default="/system/operation_mode/state"/>
89
<arg name="output_actuation_cmd" default="/control/command/actuation_cmd"/>
910
<arg name="output_steering_status" default="/vehicle/status/steering_status"/>
1011
<!-- Parameter -->
@@ -17,6 +18,7 @@
1718
<remap from="~/input/accel" to="$(var input_accel)"/>
1819
<remap from="~/input/steering" to="$(var input_steering)"/>
1920
<remap from="~/input/actuation_status" to="$(var input_actuation_status)"/>
21+
<remap from="~/input/operation_mode_state" to="$(var input_operation_mode_state)"/>
2022
<remap from="~/output/actuation_cmd" to="$(var output_actuation_cmd)"/>
2123
<remap from="~/output/steering_status" to="$(var output_steering_status)"/>
2224
</node>

vehicle/autoware_raw_vehicle_cmd_converter/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<buildtool_depend>ament_cmake_auto</buildtool_depend>
2222
<buildtool_depend>autoware_cmake</buildtool_depend>
2323

24+
<depend>autoware_adapi_v1_msgs</depend>
2425
<depend>autoware_control_msgs</depend>
2526
<depend>autoware_interpolation</depend>
2627
<depend>autoware_vehicle_msgs</depend>

vehicle/autoware_raw_vehicle_cmd_converter/src/node.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,22 @@ void RawVehicleCommandConverterNode::publishActuationCmd()
139139
}
140140

141141
const auto current_accel = sub_accel_.takeData();
142+
const auto current_operation_mode = sub_operation_mode_.takeData();
142143
if (use_vehicle_adaptor_) {
143-
if (!current_accel) {
144-
RCLCPP_WARN_EXPRESSION(get_logger(), is_debugging_, "current accel is null");
144+
if (!current_accel || !current_operation_mode) {
145+
RCLCPP_WARN_EXPRESSION(
146+
get_logger(), is_debugging_, "some pointers are null: %s, %s",
147+
!current_accel ? "accel" : "", !current_operation_mode ? "operation_mode" : "");
145148
return;
146149
}
147150
}
148151

149152
/* compensate control command if vehicle adaptor is enabled */
150-
const Control control_cmd = use_vehicle_adaptor_ ? vehicle_adaptor_.compensate(
151-
*control_cmd_ptr_, *current_odometry_,
152-
*current_accel, *current_steer_ptr_)
153-
: *control_cmd_ptr_;
153+
const Control control_cmd = use_vehicle_adaptor_
154+
? vehicle_adaptor_.compensate(
155+
*control_cmd_ptr_, *current_odometry_, *current_accel,
156+
*current_steer_ptr_, *current_operation_mode)
157+
: *control_cmd_ptr_;
154158

155159
/* calculate actuation command */
156160
double desired_accel_cmd = 0.0;

vehicle/autoware_raw_vehicle_cmd_converter/src/vehicle_adaptor/vehicle_adaptor.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ namespace autoware::raw_vehicle_cmd_converter
2020
{
2121
Control VehicleAdaptor::compensate(
2222
const Control & input_control_cmd, [[maybe_unused]] const Odometry & odometry,
23-
[[maybe_unused]] const AccelWithCovarianceStamped & accel, [[maybe_unused]] const double steering)
23+
[[maybe_unused]] const AccelWithCovarianceStamped & accel, [[maybe_unused]] const double steering,
24+
[[maybe_unused]] const OperationModeState & operation_mode)
2425
{
2526
// TODO(someone): implement the control command compensation
2627
Control output_control_cmd = input_control_cmd;

0 commit comments

Comments
 (0)