Skip to content

feat(autoware_default_adapi): release adapi v1.6.0 #9704

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

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct VehicleStatus
using Message = autoware_adapi_v1_msgs::msg::VehicleStatus;
static constexpr char name[] = "/api/vehicle/status";
static constexpr size_t depth = 1;
static constexpr auto reliability = RMW_QOS_POLICY_RELIABILITY_RELIABLE;
static constexpr auto reliability = RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT;
static constexpr auto durability = RMW_QOS_POLICY_DURABILITY_VOLATILE;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
ros__parameters:
require_accept_start: false
stop_check_duration: 1.0

/adapi/node/vehicle_door:
ros__parameters:
check_autoware_control: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<launch>
<arg name="vehicle_model" default="sample_vehicle"/>
<include file="$(find-pkg-share autoware_global_parameter_loader)/launch/global_params.launch.py"/>
<include file="$(find-pkg-share autoware_default_adapi)/launch/default_adapi.launch.py"/>
</launch>
2 changes: 1 addition & 1 deletion system/autoware_default_adapi/src/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ InterfaceNode::InterfaceNode(const rclcpp::NodeOptions & options) : Node("interf
{
const auto on_interface_version = [](auto, auto res) {
res->major = 1;
res->minor = 5;
res->minor = 6;
res->patch = 0;
};

Expand Down
11 changes: 10 additions & 1 deletion system/autoware_default_adapi/src/routing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
adaptor.init_cli(cli_operation_mode_, group_cli_);
adaptor.init_sub(sub_operation_mode_, this, &RoutingNode::on_operation_mode);

is_autoware_control_ = false;
is_auto_mode_ = false;
state_.state = State::Message::UNKNOWN;
}
Expand All @@ -85,6 +86,7 @@

void RoutingNode::on_operation_mode(const OperationModeState::Message::ConstSharedPtr msg)
{
is_autoware_control_ = msg->is_autoware_control_enabled;

Check warning on line 89 in system/autoware_default_adapi/src/routing.cpp

View check run for this annotation

Codecov / codecov/patch

system/autoware_default_adapi/src/routing.cpp#L89

Added line #L89 was not covered by tests
is_auto_mode_ = msg->mode == OperationModeState::Message::AUTONOMOUS;
}

Expand Down Expand Up @@ -119,7 +121,14 @@
const autoware::adapi_specs::routing::ClearRoute::Service::Request::SharedPtr req,
const autoware::adapi_specs::routing::ClearRoute::Service::Response::SharedPtr res)
{
change_stop_mode();
// For safety, do not clear the route while it is in use.
// https://autowarefoundation.github.io/autoware-documentation/main/design/autoware-interfaces/ad-api/list/api/routing/clear_route/
if (is_auto_mode_ && is_autoware_control_) {
res->status.success = false;
res->status.code = ResponseStatus::UNKNOWN;
res->status.message = "The route cannot be cleared while it is in use.";
return;

Check warning on line 130 in system/autoware_default_adapi/src/routing.cpp

View check run for this annotation

Codecov / codecov/patch

system/autoware_default_adapi/src/routing.cpp#L127-L130

Added lines #L127 - L130 were not covered by tests
}
res->status = conversion::convert_call(cli_clear_route_, req);
}

Expand Down
1 change: 1 addition & 0 deletions system/autoware_default_adapi/src/routing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class RoutingNode : public rclcpp::Node
Cli<autoware::component_interface_specs::planning::ClearRoute> cli_clear_route_;
Cli<autoware::component_interface_specs::system::ChangeOperationMode> cli_operation_mode_;
Sub<autoware::component_interface_specs::system::OperationModeState> sub_operation_mode_;
bool is_autoware_control_;
bool is_auto_mode_;
State::Message state_;

Expand Down
46 changes: 39 additions & 7 deletions system/autoware_default_adapi/src/vehicle_door.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,50 @@
{
const auto adaptor = autoware::component_interface_utils::NodeAdaptor(this);
group_cli_ = create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
adaptor.relay_service(cli_command_, srv_command_, group_cli_, 3.0);
adaptor.relay_service(cli_layout_, srv_layout_, group_cli_, 3.0);
adaptor.relay_service(cli_layout_, srv_layout_, group_cli_);
adaptor.init_cli(cli_command_, group_cli_);
adaptor.init_srv(srv_command_, this, &VehicleDoorNode::on_command);
adaptor.init_pub(pub_status_);
adaptor.init_sub(sub_status_, this, &VehicleDoorNode::on_status);
adaptor.init_sub(sub_operation_mode_, this, &VehicleDoorNode::on_operation_mode);

check_autoware_control_ = declare_parameter<bool>("check_autoware_control");
is_autoware_control_ = false;
is_stop_mode_ = false;
}

void VehicleDoorNode::on_operation_mode(const OperationModeState::Message::ConstSharedPtr msg)

Check warning on line 39 in system/autoware_default_adapi/src/vehicle_door.cpp

View check run for this annotation

Codecov / codecov/patch

system/autoware_default_adapi/src/vehicle_door.cpp#L39

Added line #L39 was not covered by tests
{
is_autoware_control_ = msg->is_autoware_control_enabled;
is_stop_mode_ = msg->mode == OperationModeState::Message::STOP;
}
void VehicleDoorNode::on_status(InternalDoorStatus::Message::ConstSharedPtr msg)

Check warning on line 44 in system/autoware_default_adapi/src/vehicle_door.cpp

View check run for this annotation

Codecov / codecov/patch

system/autoware_default_adapi/src/vehicle_door.cpp#L41-L44

Added lines #L41 - L44 were not covered by tests
{
utils::notify(pub_status_, status_, *msg, utils::ignore_stamp<InternalDoorStatus::Message>);

Check warning on line 46 in system/autoware_default_adapi/src/vehicle_door.cpp

View check run for this annotation

Codecov / codecov/patch

system/autoware_default_adapi/src/vehicle_door.cpp#L46

Added line #L46 was not covered by tests
}

void VehicleDoorNode::on_status(
autoware::component_interface_specs::vehicle::DoorStatus::Message::ConstSharedPtr msg)
void VehicleDoorNode::on_command(

Check warning on line 49 in system/autoware_default_adapi/src/vehicle_door.cpp

View check run for this annotation

Codecov / codecov/patch

system/autoware_default_adapi/src/vehicle_door.cpp#L49

Added line #L49 was not covered by tests
const ExternalDoorCommand::Service::Request::SharedPtr req,
const ExternalDoorCommand::Service::Response::SharedPtr res)
{
utils::notify(
pub_status_, status_, *msg,
utils::ignore_stamp<autoware::component_interface_specs::vehicle::DoorStatus::Message>);
// For safety, do not open the door if the vehicle is not stopped.
// https://autowarefoundation.github.io/autoware-documentation/main/design/autoware-interfaces/ad-api/list/api/vehicle/doors/command/
if (!is_stop_mode_ || (!is_autoware_control_ && check_autoware_control_)) {

Check warning on line 55 in system/autoware_default_adapi/src/vehicle_door.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Conditional

VehicleDoorNode::on_command has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
bool is_open = false;
for (const auto & door : req->doors) {
if (door.command == autoware_adapi_v1_msgs::msg::DoorCommand::OPEN) {
is_open = true;
break;
}
}
if (is_open) {
res->status.success = false;
res->status.code = autoware_adapi_v1_msgs::msg::ResponseStatus::UNKNOWN;
res->status.message = "Doors cannot be opened if the vehicle is not stopped.";
return;

Check warning on line 67 in system/autoware_default_adapi/src/vehicle_door.cpp

View check run for this annotation

Codecov / codecov/patch

system/autoware_default_adapi/src/vehicle_door.cpp#L64-L67

Added lines #L64 - L67 were not covered by tests
}
}
autoware::component_interface_utils::status::copy(cli_command_->call(req), res);
}

} // namespace autoware::default_adapi
Expand Down
37 changes: 28 additions & 9 deletions system/autoware_default_adapi/src/vehicle_door.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#define VEHICLE_DOOR_HPP_

#include <autoware/adapi_specs/vehicle.hpp>
#include <autoware/component_interface_specs/system.hpp>
#include <autoware/component_interface_specs/vehicle.hpp>
#include <autoware/component_interface_utils/status.hpp>
#include <rclcpp/rclcpp.hpp>

#include <optional>
Expand All @@ -33,16 +35,33 @@ class VehicleDoorNode : public rclcpp::Node
explicit VehicleDoorNode(const rclcpp::NodeOptions & options);

private:
void on_status(
autoware::component_interface_specs::vehicle::DoorStatus::Message::ConstSharedPtr msg);
using OperationModeState = autoware::component_interface_specs::system::OperationModeState;
using InternalDoorStatus = autoware::component_interface_specs::vehicle::DoorStatus;
using InternalDoorLayout = autoware::component_interface_specs::vehicle::DoorLayout;
using InternalDoorCommand = autoware::component_interface_specs::vehicle::DoorCommand;
using ExternalDoorStatus = autoware::adapi_specs::vehicle::DoorStatus;
using ExternalDoorLayout = autoware::adapi_specs::vehicle::DoorLayout;
using ExternalDoorCommand = autoware::adapi_specs::vehicle::DoorCommand;

void on_operation_mode(const OperationModeState::Message::ConstSharedPtr msg);
void on_status(InternalDoorStatus::Message::ConstSharedPtr msg);
void on_command(
const ExternalDoorCommand::Service::Request::SharedPtr req,
const ExternalDoorCommand::Service::Response::SharedPtr res);

rclcpp::CallbackGroup::SharedPtr group_cli_;
Srv<autoware::adapi_specs::vehicle::DoorCommand> srv_command_;
Srv<autoware::adapi_specs::vehicle::DoorLayout> srv_layout_;
Pub<autoware::adapi_specs::vehicle::DoorStatus> pub_status_;
Cli<autoware::component_interface_specs::vehicle::DoorCommand> cli_command_;
Cli<autoware::component_interface_specs::vehicle::DoorLayout> cli_layout_;
Sub<autoware::component_interface_specs::vehicle::DoorStatus> sub_status_;
std::optional<autoware::component_interface_specs::vehicle::DoorStatus::Message> status_;
Srv<ExternalDoorCommand> srv_command_;
Srv<ExternalDoorLayout> srv_layout_;
Pub<ExternalDoorStatus> pub_status_;
Cli<InternalDoorCommand> cli_command_;
Cli<InternalDoorLayout> cli_layout_;
Sub<InternalDoorStatus> sub_status_;
std::optional<InternalDoorStatus::Message> status_;

bool check_autoware_control_;
bool is_autoware_control_;
bool is_stop_mode_;
Sub<OperationModeState> sub_operation_mode_;
};

} // namespace autoware::default_adapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

if response.major != 1:
exit(1)
if response.minor != 5:
if response.minor != 6:
exit(1)
if response.patch != 0:
exit(1)
Expand Down
Loading