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

fix(follow_trajectory_action): adapt to work with considering slopes #1226

Merged
merged 30 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
62b9867
fix(entities_update): fix update time in EntityStatus
dmoszynski Apr 4, 2024
4d92606
fix(toLaneletPose): fix matching_distance in EgoEntity, EgoEntitySimu…
dmoszynski Apr 5, 2024
e107d22
fix(follow_trajectory): fix velocity vector and setting orientation -…
dmoszynski Apr 10, 2024
42f88f5
fix(action_node): add debug_marker OutputPort
dmoszynski Apr 10, 2024
46490d6
fix(ego_entity_simulation, sim_model_interface): add overwrite positi…
dmoszynski Apr 10, 2024
dfb711f
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
dmoszynski Apr 12, 2024
4eaa23e
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
yamacir-kit Apr 19, 2024
b74c9b0
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
dmoszynski Apr 23, 2024
e3034fd
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
dmoszynski Apr 29, 2024
eb63404
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
dmoszynski May 6, 2024
49bdda5
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
yamacir-kit May 8, 2024
8563ede
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
dmoszynski May 13, 2024
51b4641
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
dmoszynski May 20, 2024
6024371
ref(ego_entity_simulation, sim_model_interface): use world_relative_p…
dmoszynski May 20, 2024
81aec5b
ref(ego_entity_simulation): apply clang reforamt
dmoszynski May 21, 2024
53980e4
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
dmoszynski May 21, 2024
95c19cd
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
dmoszynski May 22, 2024
f97f731
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
dmoszynski May 24, 2024
b0614e3
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
dmoszynski May 28, 2024
f554789
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
yamacir-kit May 30, 2024
c08a7f7
ref(traffic_simulator, behavior_tree): apply requested changes
dmoszynski Jun 3, 2024
ea34460
ref(ego_entity_simulation): use world_relative_position, use only Oz
dmoszynski Jun 3, 2024
9daa0ac
ref(ego_entity_simulation): use world_relative_position_ in getCurren…
dmoszynski Jun 3, 2024
1f72837
feat(ego_entity_simulation): develop VehicleModelState
dmoszynski Jun 3, 2024
dfffa9b
Revert "feat(ego_entity_simulation): develop VehicleModelState"
dmoszynski Jun 3, 2024
d215afd
fix(ego_entity_simulation): fix world_relative_position_ for update()
dmoszynski Jun 3, 2024
84b5dbf
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
dmoszynski Jun 3, 2024
f75bf19
fix(ego_entity_simulation): fix assignment of world_relative_position…
dmoszynski Jun 3, 2024
73dc7c6
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
dmoszynski Jun 10, 2024
178560f
Merge branch 'master' into fix/RJD-955-fix-followtrajectoryaction-nan…
yamacir-kit Jun 11, 2024
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 @@ -92,6 +92,7 @@ class ActionNode : public BT::ActionNodeBase
BT::OutputPort<std::shared_ptr<traffic_simulator::CanonicalizedEntityStatus>>("updated_status"),
BT::OutputPort<traffic_simulator_msgs::msg::WaypointsArray>("waypoints"),
BT::OutputPort<traffic_simulator::behavior::Request>("request"),
BT::OutputPort<std::vector<visualization_msgs::msg::Marker>>("debug_marker"),
// clang-format on
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ auto FollowPolylineTrajectoryAction::tick() -> BT::NodeStatus
}
};

auto getMatchingDistance = [&]() -> double {
return entity_status->getBoundingBox().dimensions.y * 0.5 + 1.0;
};

if (getBlackBoardValues();
request != traffic_simulator::behavior::Request::FOLLOW_POLYLINE_TRAJECTORY or
not getInput<decltype(polyline_trajectory)>("polyline_trajectory", polyline_trajectory) or
Expand All @@ -76,7 +80,7 @@ auto FollowPolylineTrajectoryAction::tick() -> BT::NodeStatus
} else if (
const auto updated_status = traffic_simulator::follow_trajectory::makeUpdatedStatus(
static_cast<traffic_simulator::EntityStatus>(*entity_status), *polyline_trajectory,
behavior_parameter, hdmap_utils, step_time, getTargetSpeed())) {
behavior_parameter, hdmap_utils, step_time, getMatchingDistance(), getTargetSpeed())) {
setOutput(
"updated_status",
std::make_shared<traffic_simulator::CanonicalizedEntityStatus>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ auto FollowPolylineTrajectoryAction::tick() -> BT::NodeStatus
}
};

auto getMatchingDistance = [&]() -> double {
return std::max(
vehicle_parameters.axles.front_axle.track_width,
vehicle_parameters.axles.rear_axle.track_width) *
0.5 +
1.0;
};

if (getBlackBoardValues();
request != traffic_simulator::behavior::Request::FOLLOW_POLYLINE_TRAJECTORY or
not getInput<decltype(polyline_trajectory)>("polyline_trajectory", polyline_trajectory) or
Expand All @@ -76,7 +84,7 @@ auto FollowPolylineTrajectoryAction::tick() -> BT::NodeStatus
} else if (
const auto updated_status = traffic_simulator::follow_trajectory::makeUpdatedStatus(
static_cast<traffic_simulator::EntityStatus>(*entity_status), *polyline_trajectory,
behavior_parameter, hdmap_utils, step_time, getTargetSpeed())) {
behavior_parameter, hdmap_utils, step_time, getMatchingDistance(), getTargetSpeed())) {
setOutput(
"updated_status",
std::make_shared<traffic_simulator::CanonicalizedEntityStatus>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class SimModelDelaySteerAccGeared : public SimModelInterface
VX,
STEER,
ACCX,
Z,
dmoszynski marked this conversation as resolved.
Show resolved Hide resolved
};
enum IDX_U {
ACCX_DES = 0,
Expand Down Expand Up @@ -101,6 +102,11 @@ class SimModelDelaySteerAccGeared : public SimModelInterface
*/
double getY() override;

/**
* @brief get vehicle position z
*/
double getZ() override;

/**
* @brief get vehicle angle yaw
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ class SimModelInterface
*/
virtual double getY() = 0;

/**
* @brief get vehicle position z
*/
virtual double getZ() { return 0; };

/**
* @brief get vehicle angle yaw
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ void EgoEntitySimulation::overwrite(
return convertQuaternionToEulerAngle(relative_orientation).z -
(previous_linear_velocity_ ? *previous_angular_velocity_ : 0) * step_time;
}();

switch (auto state = Eigen::VectorXd(vehicle_model_ptr_->getDimX()); vehicle_model_type_) {
case VehicleModelType::DELAY_STEER_ACC:
case VehicleModelType::DELAY_STEER_ACC_GEARED:
Expand All @@ -249,6 +248,7 @@ void EgoEntitySimulation::overwrite(
case VehicleModelType::IDEAL_STEER_ACC:
case VehicleModelType::IDEAL_STEER_ACC_GEARED:
state(3) = status.action_status.twist.linear.x;
state(6) = world_relative_position(2);
[[fallthrough]];

case VehicleModelType::IDEAL_STEER_VEL:
Expand Down Expand Up @@ -324,19 +324,23 @@ auto EgoEntitySimulation::getMatchedLaneletPoseFromEntityStatus(
/// EgoEntity::setMapPose
const auto unique_route_lanelets =
traffic_simulator::helper::getUniqueValues(autoware->getRouteLanelets());
const auto matching_length = [entity_width] { return entity_width * 0.5 + 1.0; }();
const auto matching_distance = std::max(
vehicle_parameters.axles.front_axle.track_width,
vehicle_parameters.axles.rear_axle.track_width) *
0.5 +
1.0;

std::optional<traffic_simulator_msgs::msg::LaneletPose> lanelet_pose;

if (unique_route_lanelets.empty()) {
lanelet_pose =
hdmap_utils_ptr_->toLaneletPose(status.pose, status.bounding_box, false, matching_length);
hdmap_utils_ptr_->toLaneletPose(status.pose, status.bounding_box, false, matching_distance);
} else {
lanelet_pose =
hdmap_utils_ptr_->toLaneletPose(status.pose, unique_route_lanelets, matching_length);
hdmap_utils_ptr_->toLaneletPose(status.pose, unique_route_lanelets, matching_distance);
if (!lanelet_pose) {
lanelet_pose =
hdmap_utils_ptr_->toLaneletPose(status.pose, status.bounding_box, false, matching_length);
hdmap_utils_ptr_->toLaneletPose(status.pose, status.bounding_box, false, matching_distance);
}
}
return lanelet_pose;
Expand Down Expand Up @@ -415,7 +419,7 @@ auto EgoEntitySimulation::getCurrentPose(const double pitch_angle = 0.) const
Eigen::VectorXd relative_position(3);
relative_position(0) = vehicle_model_ptr_->getX();
relative_position(1) = vehicle_model_ptr_->getY();
relative_position(2) = 0.0;
relative_position(2) = vehicle_model_ptr_->getZ();
relative_position =
quaternion_operation::getRotationMatrix(initial_pose_.orientation) * relative_position;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SimModelDelaySteerAccGeared::SimModelDelaySteerAccGeared(
double dt, double acc_delay, double acc_time_constant, double steer_delay,
double steer_time_constant, double steer_dead_band, double debug_acc_scaling_factor,
double debug_steer_scaling_factor)
: SimModelInterface(6 /* dim x */, 2 /* dim u */),
: SimModelInterface(7 /* dim x */, 2 /* dim u */),
MIN_TIME_CONSTANT(0.03),
vx_lim_(vx_lim),
vx_rate_lim_(vx_rate_lim),
Expand All @@ -41,6 +41,7 @@ SimModelDelaySteerAccGeared::SimModelDelaySteerAccGeared(

double SimModelDelaySteerAccGeared::getX() { return state_(IDX::X); }
double SimModelDelaySteerAccGeared::getY() { return state_(IDX::Y); }
double SimModelDelaySteerAccGeared::getZ() { return state_(IDX::Z); }
double SimModelDelaySteerAccGeared::getYaw() { return state_(IDX::YAW); }
double SimModelDelaySteerAccGeared::getVx() { return state_(IDX::VX); }
double SimModelDelaySteerAccGeared::getVy() { return 0.0; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ auto makeUpdatedStatus(
const traffic_simulator_msgs::msg::EntityStatus &,
traffic_simulator_msgs::msg::PolylineTrajectory &,
const traffic_simulator_msgs::msg::BehaviorParameter &,
const std::shared_ptr<hdmap_utils::HdMapUtils> &, double,
const std::shared_ptr<hdmap_utils::HdMapUtils> &, double, double,
std::optional<double> target_speed = std::nullopt)
-> std::optional<traffic_simulator_msgs::msg::EntityStatus>;
} // namespace follow_trajectory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class FollowWaypointController
There is no technical basis for this value, it was determined based on
Dawid Moszynski experiments.
*/
static constexpr double finish_distance_tolerance = 1e-4;
static constexpr double finish_distance_tolerance = 1e-2;

/*
Accuracy of the predicted arrival distance at the waypoint with the
Expand All @@ -129,7 +129,7 @@ class FollowWaypointController
There is no technical basis for this value, it was determined based on
Dawid Moszynski experiments.
*/
static constexpr std::size_t number_of_acceleration_candidates = 20;
static constexpr std::size_t number_of_acceleration_candidates = 30;

/*
This is a debugging method, it is not worth giving it much attention.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class EntityBase

/* */ auto setLinearJerk(const double liner_jerk) -> void;

virtual void startNpcLogic();
virtual void startNpcLogic(const double current_time);

/* */ void stopAtCurrentPosition();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ class EntityManager
// FIXME: this ignores V2I traffic lights
iter->second->setTrafficLightManager(conventional_traffic_light_manager_ptr_);
if (npc_logic_started_ && not is<EgoEntity>(name)) {
iter->second->startNpcLogic();
iter->second->startNpcLogic(getCurrentTime());
}
return success;
} else {
Expand All @@ -613,7 +613,7 @@ class EntityManager

void updateHdmapMarker();

void startNpcLogic();
void startNpcLogic(const double current_time);

auto isNpcLogicStarted() const { return npc_logic_started_; }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ class HdMapUtils
const double matching_distance = 1.0) const
-> std::optional<traffic_simulator_msgs::msg::LaneletPose>;

auto toLaneletPose(
const geometry_msgs::msg::Point &, const traffic_simulator_msgs::msg::BoundingBox &,
const bool include_crosswalk, const double matching_distance = 1.0) const
-> std::optional<traffic_simulator_msgs::msg::LaneletPose>;

auto toLaneletPose(
const geometry_msgs::msg::Pose &, const traffic_simulator_msgs::msg::BoundingBox &,
const bool include_crosswalk, const double matching_distance = 1.0) const
Expand Down
2 changes: 1 addition & 1 deletion simulation/traffic_simulator/src/api/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ void API::startNpcLogic()
if (isNpcLogicStarted()) {
THROW_SIMULATION_ERROR("NPC logics are already started.");
}
entity_manager_ptr_->startNpcLogic();
clock_.start();
entity_manager_ptr_->startNpcLogic(getCurrentTime());
}

void API::requestLaneChange(const std::string & name, const lanelet::Id & lanelet_id)
Expand Down
Loading
Loading