Skip to content

Commit

Permalink
Merge branch 'main' into feature/dynamic_map_loading
Browse files Browse the repository at this point in the history
  • Loading branch information
kminoda committed Jan 20, 2023
2 parents de0ef18 + 0305906 commit 9544d47
Show file tree
Hide file tree
Showing 172 changed files with 4,431 additions and 1,701 deletions.
92 changes: 92 additions & 0 deletions common/tier4_state_rviz_plugin/src/autoware_state_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ AutowareStatePanel::AutowareStatePanel(QWidget * parent) : rviz_common::Panel(pa
h_layout->addWidget(makeRoutingGroup());
h_layout->addWidget(makeLocalizationGroup());
h_layout->addWidget(makeMotionGroup());
h_layout->addWidget(makeFailSafeGroup());
v_layout->addLayout(h_layout);
}

Expand Down Expand Up @@ -186,6 +187,25 @@ QGroupBox * AutowareStatePanel::makeMotionGroup()
return group;
}

QGroupBox * AutowareStatePanel::makeFailSafeGroup()
{
auto * group = new QGroupBox("FalSafe");
auto * grid = new QGridLayout;

mrm_state_label_ptr_ = new QLabel("INIT");
mrm_state_label_ptr_->setAlignment(Qt::AlignCenter);
mrm_state_label_ptr_->setStyleSheet("border:1px solid black;");
grid->addWidget(mrm_state_label_ptr_, 0, 0);

mrm_behavior_label_ptr_ = new QLabel("INIT");
mrm_behavior_label_ptr_->setAlignment(Qt::AlignCenter);
mrm_behavior_label_ptr_->setStyleSheet("border:1px solid black;");
grid->addWidget(mrm_behavior_label_ptr_, 1, 0);

group->setLayout(grid);
return group;
}

void AutowareStatePanel::onInitialize()
{
raw_node_ = this->getDisplayContext()->getRosNodeAbstraction().lock()->get_raw_node();
Expand Down Expand Up @@ -234,6 +254,12 @@ void AutowareStatePanel::onInitialize()
client_accept_start_ = raw_node_->create_client<AcceptStart>(
"/api/motion/accept_start", rmw_qos_profile_services_default);

// FailSafe
sub_mrm_ = raw_node_->create_subscription<MRMState>(
"/api/fail_safe/mrm_state", rclcpp::QoS{1}.transient_local(),
std::bind(&AutowareStatePanel::onMRMState, this, _1));

// Others
sub_gear_ = raw_node_->create_subscription<autoware_auto_vehicle_msgs::msg::GearReport>(
"/vehicle/status/gear_status", 10, std::bind(&AutowareStatePanel::onShift, this, _1));

Expand Down Expand Up @@ -421,6 +447,72 @@ void AutowareStatePanel::onMotion(const MotionState::ConstSharedPtr msg)
}
}

void AutowareStatePanel::onMRMState(const MRMState::ConstSharedPtr msg)
{
// state
{
QString text = "";
QString style_sheet = "";
switch (msg->state) {
case MRMState::NONE:
text = "NONE";
style_sheet = "background-color: #00FF00;"; // green
break;

case MRMState::MRM_OPERATING:
text = "MRM_OPERATING";
style_sheet = "background-color: #FFA500;"; // orange
break;

case MRMState::MRM_SUCCEEDED:
text = "MRM_SUCCEEDED";
style_sheet = "background-color: #FFFF00;"; // yellow
break;

case MRMState::MRM_FAILED:
text = "MRM_FAILED";
style_sheet = "background-color: #FF0000;"; // red
break;

default:
text = "UNKNOWN";
style_sheet = "background-color: #FF0000;"; // red
break;
}

updateLabel(mrm_state_label_ptr_, text, style_sheet);
}

// behavior
{
QString text = "";
QString style_sheet = "";
switch (msg->state) {
case MRMState::NONE:
text = "NONE";
style_sheet = "background-color: #00FF00;"; // green
break;

case MRMState::COMFORTABLE_STOP:
text = "COMFORTABLE_STOP";
style_sheet = "background-color: #FFFF00;"; // yellow
break;

case MRMState::EMERGENCY_STOP:
text = "EMERGENCY_STOP";
style_sheet = "background-color: #FFA500;"; // orange
break;

default:
text = "UNKNOWN";
style_sheet = "background-color: #FF0000;"; // red
break;
}

updateLabel(mrm_behavior_label_ptr_, text, style_sheet);
}
}

void AutowareStatePanel::onShift(
const autoware_auto_vehicle_msgs::msg::GearReport::ConstSharedPtr msg)
{
Expand Down
12 changes: 12 additions & 0 deletions common/tier4_state_rviz_plugin/src/autoware_state_panel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <autoware_adapi_v1_msgs/msg/localization_initialization_state.hpp>
#include <autoware_adapi_v1_msgs/msg/motion_state.hpp>
#include <autoware_adapi_v1_msgs/msg/mrm_state.hpp>
#include <autoware_adapi_v1_msgs/msg/operation_mode_state.hpp>
#include <autoware_adapi_v1_msgs/msg/route_state.hpp>
#include <autoware_adapi_v1_msgs/srv/accept_start.hpp>
Expand All @@ -51,6 +52,7 @@ class AutowareStatePanel : public rviz_common::Panel
autoware_adapi_v1_msgs::msg::LocalizationInitializationState;
using MotionState = autoware_adapi_v1_msgs::msg::MotionState;
using AcceptStart = autoware_adapi_v1_msgs::srv::AcceptStart;
using MRMState = autoware_adapi_v1_msgs::msg::MrmState;

Q_OBJECT

Expand All @@ -77,6 +79,7 @@ public Q_SLOTS: // NOLINT for Qt
QGroupBox * makeRoutingGroup();
QGroupBox * makeLocalizationGroup();
QGroupBox * makeMotionGroup();
QGroupBox * makeFailSafeGroup();

void onShift(const autoware_auto_vehicle_msgs::msg::GearReport::ConstSharedPtr msg);
void onEmergencyStatus(const tier4_external_api_msgs::msg::Emergency::ConstSharedPtr msg);
Expand Down Expand Up @@ -139,6 +142,15 @@ public Q_SLOTS: // NOLINT for Qt

void onMotion(const MotionState::ConstSharedPtr msg);

// FailSafe
QLabel * mrm_state_label_ptr_{nullptr};
QLabel * mrm_behavior_label_ptr_{nullptr};

rclcpp::Subscription<MRMState>::SharedPtr sub_mrm_;

void onMRMState(const MRMState::ConstSharedPtr msg);

// Others
QPushButton * velocity_limit_button_ptr_;
QLabel * gear_label_ptr_;

Expand Down
2 changes: 1 addition & 1 deletion control/joy_controller/launch/joy_controller.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<remap from="output/vehicle_engage" to="$(var output_vehicle_engage)"/>

<remap from="service/emergency_stop" to="/api/autoware/set/emergency"/>
<remap from="service/autoware_engage" to="/api/external/set/engage"/>
<remap from="service/autoware_engage" to="/api/autoware/set/engage"/>

<param from="$(var config_file)"/>
<param name="joy_type" value="$(var joy_type)"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct Input
lanelet::LaneletMapPtr lanelet_map{};
LaneletRoute::ConstSharedPtr route{};
lanelet::ConstLanelets route_lanelets{};
lanelet::ConstLanelets shoulder_lanelets{};
Trajectory::ConstSharedPtr reference_trajectory{};
Trajectory::ConstSharedPtr predicted_trajectory{};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class LaneDepartureCheckerNode : public rclcpp::Node
geometry_msgs::msg::PoseStamped::ConstSharedPtr current_pose_;
nav_msgs::msg::Odometry::ConstSharedPtr current_odom_;
lanelet::LaneletMapPtr lanelet_map_;
lanelet::ConstLanelets shoulder_lanelets_;
lanelet::traffic_rules::TrafficRulesPtr traffic_rules_;
lanelet::routing::RoutingGraphPtr routing_graph_;
LaneletRoute::ConstSharedPtr route_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,15 @@ Output LaneDepartureChecker::update(const Input & input)
output.vehicle_passing_areas = createVehiclePassingAreas(output.vehicle_footprints);
output.processing_time_map["createVehiclePassingAreas"] = stop_watch.toc(true);

output.candidate_lanelets = getCandidateLanelets(input.route_lanelets, output.vehicle_footprints);
const auto candidate_road_lanelets =
getCandidateLanelets(input.route_lanelets, output.vehicle_footprints);
const auto candidate_shoulder_lanelets =
getCandidateLanelets(input.shoulder_lanelets, output.vehicle_footprints);
output.candidate_lanelets = candidate_road_lanelets;
output.candidate_lanelets.insert(
output.candidate_lanelets.end(), candidate_shoulder_lanelets.begin(),
candidate_shoulder_lanelets.end());

output.processing_time_map["getCandidateLanelets"] = stop_watch.toc(true);

output.will_leave_lane = willLeaveLane(output.candidate_lanelets, output.vehicle_footprints);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ void LaneDepartureCheckerNode::onLaneletMapBin(const HADMapBin::ConstSharedPtr m
{
lanelet_map_ = std::make_shared<lanelet::LaneletMap>();
lanelet::utils::conversion::fromBinMsg(*msg, lanelet_map_, &traffic_rules_, &routing_graph_);

// get all shoulder lanes
lanelet::ConstLanelets all_lanelets = lanelet::utils::query::laneletLayer(lanelet_map_);
shoulder_lanelets_ = lanelet::utils::query::shoulderLanelets(all_lanelets);
}

void LaneDepartureCheckerNode::onRoute(const LaneletRoute::ConstSharedPtr msg) { route_ = msg; }
Expand Down Expand Up @@ -313,6 +317,7 @@ void LaneDepartureCheckerNode::onTimer()
input_.lanelet_map = lanelet_map_;
input_.route = route_;
input_.route_lanelets = route_lanelets_;
input_.shoulder_lanelets = shoulder_lanelets_;
input_.reference_trajectory = reference_trajectory_;
input_.predicted_trajectory = predicted_trajectory_;
processing_time_map["Node: setInputData"] = stop_watch.toc(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
#include <iostream>
#include <vector>

namespace autoware
{
namespace motion
{
namespace control
{
namespace mpc_lateral_controller
namespace autoware::motion::control::mpc_lateral_controller
{

/**
Expand All @@ -48,8 +42,5 @@ bool linearInterpolate(
bool linearInterpolate(
const std::vector<double> & base_index, const std::vector<double> & base_value,
const double & return_index, double & return_value);
} // namespace mpc_lateral_controller
} // namespace control
} // namespace motion
} // namespace autoware
} // namespace autoware::motion::control::mpc_lateral_controller
#endif // MPC_LATERAL_CONTROLLER__INTERPOLATE_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@
#include <iostream>
#include <vector>

namespace autoware
{
namespace motion
{
namespace control
{
namespace mpc_lateral_controller
namespace autoware::motion::control::mpc_lateral_controller
{
/**
* @brief 2nd-order Butterworth Filter
Expand Down Expand Up @@ -108,8 +102,5 @@ namespace MoveAverageFilter
*/
bool filt_vector(const int num, std::vector<double> & u);
} // namespace MoveAverageFilter
} // namespace mpc_lateral_controller
} // namespace control
} // namespace motion
} // namespace autoware
} // namespace autoware::motion::control::mpc_lateral_controller
#endif // MPC_LATERAL_CONTROLLER__LOWPASS_FILTER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@
#include <string>
#include <vector>

namespace autoware
{
namespace motion
{
namespace control
{
namespace mpc_lateral_controller
namespace autoware::motion::control::mpc_lateral_controller
{

struct MPCParam
Expand Down Expand Up @@ -444,9 +438,6 @@ class MPC
*/
inline void setClock(rclcpp::Clock::SharedPtr clock) { m_clock = clock; }
}; // class MPC
} // namespace mpc_lateral_controller
} // namespace control
} // namespace motion
} // namespace autoware
} // namespace autoware::motion::control::mpc_lateral_controller

#endif // MPC_LATERAL_CONTROLLER__MPC_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@
#include <string>
#include <vector>

namespace autoware
{
namespace motion
{
namespace control
{
namespace mpc_lateral_controller
namespace autoware::motion::control::mpc_lateral_controller
{

namespace trajectory_follower = ::autoware::motion::control::trajectory_follower;
Expand Down Expand Up @@ -212,9 +206,6 @@ class MpcLateralController : public trajectory_follower::LateralControllerBase
rcl_interfaces::msg::SetParametersResult paramCallback(
const std::vector<rclcpp::Parameter> & parameters);
};
} // namespace mpc_lateral_controller
} // namespace control
} // namespace motion
} // namespace autoware
} // namespace autoware::motion::control::mpc_lateral_controller

#endif // MPC_LATERAL_CONTROLLER__MPC_LATERAL_CONTROLLER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@
#include <iostream>
#include <vector>

namespace autoware
{
namespace motion
{
namespace control
{
namespace mpc_lateral_controller
namespace autoware::motion::control::mpc_lateral_controller
{

/**
Expand Down Expand Up @@ -96,8 +90,5 @@ class MPCTrajectory
return points;
}
};
} // namespace mpc_lateral_controller
} // namespace control
} // namespace motion
} // namespace autoware
} // namespace autoware::motion::control::mpc_lateral_controller
#endif // MPC_LATERAL_CONTROLLER__MPC_TRAJECTORY_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@
#include <string>
#include <vector>

namespace autoware
{
namespace motion
{
namespace control
{
namespace mpc_lateral_controller
namespace autoware::motion::control::mpc_lateral_controller
{
namespace MPCUtils
{
Expand Down Expand Up @@ -192,8 +186,5 @@ void extendTrajectoryInYawDirection(
const double yaw, const double interval, const bool is_forward_shift, MPCTrajectory & traj);

} // namespace MPCUtils
} // namespace mpc_lateral_controller
} // namespace control
} // namespace motion
} // namespace autoware
} // namespace autoware::motion::control::mpc_lateral_controller
#endif // MPC_LATERAL_CONTROLLER__MPC_UTILS_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
#include "eigen3/Eigen/Dense"
#include "eigen3/Eigen/LU"

namespace autoware
{
namespace motion
{
namespace control
{
namespace mpc_lateral_controller
namespace autoware::motion::control::mpc_lateral_controller
{

/// Interface for solvers of Quadratic Programming (QP) problems
Expand Down Expand Up @@ -54,8 +48,5 @@ class QPSolverInterface
const Eigen::VectorXd & lb, const Eigen::VectorXd & ub, const Eigen::VectorXd & lb_a,
const Eigen::VectorXd & ub_a, Eigen::VectorXd & u) = 0;
};
} // namespace mpc_lateral_controller
} // namespace control
} // namespace motion
} // namespace autoware
} // namespace autoware::motion::control::mpc_lateral_controller
#endif // MPC_LATERAL_CONTROLLER__QP_SOLVER__QP_SOLVER_INTERFACE_HPP_
Loading

0 comments on commit 9544d47

Please sign in to comment.