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

Ali/simple planning simulator with disturbance generator #573

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
77c92de
Started to implement standalone control_toolbox.
boyali May 13, 2022
8a784c5
Reproduced the linking problem.
boyali May 13, 2022
0735ca9
Solved the linking problem.
boyali May 13, 2022
a110033
Solved fvisibility setting and will use in other packages.
boyali May 15, 2022
253ae2a
Syncronized with the other repos that uses the ACT.
boyali May 25, 2022
2e385c8
Syncronized with the other repos that uses the ACT.
boyali May 25, 2022
27cd1ec
Version txt is added.
boyali May 25, 2022
e5f404d
Tustin Bilinear discretization is added.
boyali May 30, 2022
8df1702
ACT is separated into the headers. Started balancing algorithm.
boyali May 30, 2022
4fa6606
Implemented matrix balancing.
boyali May 30, 2022
3b1197d
Balancing finished, comparing with others.
boyali May 30, 2022
0834ee9
Balancing finished: lapack diag subtraction is enabled.
boyali May 30, 2022
dfd9735
Balancing finalized:integrating into the ss methods.
boyali May 30, 2022
03f80b8
Automatic discretization is added to tf2ss.
boyali May 30, 2022
428a674
Automatic balancing is added to tf2ss.
boyali May 30, 2022
1051e5c
Balancing permutation method signature is added.
boyali May 31, 2022
410de74
Introduced the signal builder methods.
boyali May 31, 2022
031da29
Triangle wave implementation is changed.
boyali Jun 1, 2022
2ae4255
Added tffactor_zero initializaiton.
boyali Jun 1, 2022
ae7fb8e
added F inversion.
boyali Jun 1, 2022
c409aca
added TF from tf_factor construciton.
boyali Jun 1, 2022
6f2fb8c
Implementing TF*TF multiplication.
boyali Jun 1, 2022
32c4e51
Implementing TF*TF LAZY evaluation implemented.
boyali Jun 1, 2022
4578522
COmpleted TF TF multiplication.
boyali Jun 1, 2022
0939f02
std vector is overloaded. A TF multiplication bug is removed.
boyali Jun 2, 2022
135e18e
std vector is overloaded
boyali Jun 2, 2022
064b1b2
Completed: std vector is overloaded.
boyali Jun 2, 2022
8a3c933
Swapped when taking tf.inv().
boyali Jun 2, 2022
e7bbc70
Improved code * vector overloading.
boyali Jun 3, 2022
b3f3597
Improved TF * TF mult adding num den constants.
boyali Jun 3, 2022
9a32bc2
implemented ss system getter. PSSim needs to change.
boyali Jun 3, 2022
64df004
state space getters A(), B() .. are implemented.
boyali Jun 3, 2022
7f2fee2
explicit is removed from tf2ss
boyali Jun 3, 2022
9eb3435
static gain guard is put in the state space models.
boyali Jun 3, 2022
97abb49
Returning by a constant reference in tf2ss.
boyali Jun 3, 2022
721225a
Returning by a constant reference reverted in tf2ss.
boyali Jun 3, 2022
d87c450
implementing templated ss: before changing tf2ss default constructor.
boyali Jun 4, 2022
a9bc806
matrix printing improved.
boyali Jun 4, 2022
20de455
cleaning up tf2ss.
boyali Jun 4, 2022
0b6b7af
Changed tf2ss to have a single system matrix, instead of separate [A,…
boyali Jun 4, 2022
9bc87e2
Changed tf2ss after change make ups
boyali Jun 4, 2022
f15977a
Added a discrete system matrix simulation method into the tf2ss.
boyali Jun 4, 2022
e5ccddd
Added tf2ss parameter update method.
boyali Jun 5, 2022
bfd74d6
Added tf2ss simulateOneStep template for compile time eigen matrices.
boyali Jun 5, 2022
5db1153
Added tf2ss simulateOneStep template for compile time eigen matrices.…
boyali Jun 5, 2022
fe40cb8
Verifying with q-filters.
boyali Jun 5, 2022
2983dd6
Verifying with q-filters.
boyali Jun 5, 2022
4dfdc5f
Verified sinusoidal signal productions.
boyali Jun 5, 2022
9180e79
Balancing code block is changed.
boyali Jun 5, 2022
06c3d02
Another simulateOneStep method is added.
boyali Jun 5, 2022
77a30ef
Another simulateOneStep method is added.
boyali Jun 5, 2022
5829c65
Get order is fixed.
boyali Jun 5, 2022
59175a7
Get order is fixed.
boyali Jun 5, 2022
c0403f2
Get order is fixed.
boyali Jun 5, 2022
f711252
Reverting sysMATABCD -> separate A, B, C, D.
boyali Jun 6, 2022
26d1a5f
Balancing C, B part is being implemented.
boyali Jun 6, 2022
5f3822c
Balancing C, B part is being implemented.
boyali Jun 6, 2022
5039825
removed an infinite loop bug.
boyali Jun 6, 2022
9f4078d
ci: add sync-upstream.yaml (#4)
kenji-miyake Jan 29, 2022
7c73be6
ci(sync-upstream): update settings (#19)
kenji-miyake Mar 3, 2022
8abdf24
Added the autoware_control_toolbox and copied vehicle model for distu…
boyali Mar 4, 2022
ed347f1
Disturbance generator is added.
boyali Mar 4, 2022
b65c8f7
Copied vehicle model is tested.
boyali Mar 4, 2022
ffe1825
Input queue related code sections are removed from the vehicle distur…
boyali Mar 4, 2022
50af46f
Restarted.
boyali Mar 6, 2022
a1bcf10
IDisturbanceCollection disturbance_collection_ is added to the inter…
boyali Mar 6, 2022
665534f
Disturbance Parameters are added to yaml file.
boyali Mar 6, 2022
716f5ab
Disturbance collection is integrated.
boyali Mar 6, 2022
a830a2c
Fully integrated, but initially engaged.
boyali Mar 6, 2022
5939290
disturbance msg is added and tested.
boyali Mar 6, 2022
272a121
disturbance plots are completed.
boyali Mar 7, 2022
1675a74
ReadMe is updated.
boyali Mar 7, 2022
c6fe2db
ReadMe is updated.
boyali Mar 7, 2022
46e49ca
After the PR - geared_dist model header and cpp are added.
boyali Mar 7, 2022
ef5d52f
Geared Vehicle Model with disturbance is integrated with the simulator.
boyali Mar 7, 2022
a82f59e
Geared Vehicle Model is tested with the disturbance generator.
boyali Mar 7, 2022
6a38edb
Geared Vehicle Model is tested with the disturbance generator.
boyali Mar 7, 2022
b93b6bc
Slope is added to the plotjuggler and core.
boyali Mar 7, 2022
be677af
Started to implement TIME-VARYING DEADZONE disturbance.
boyali Mar 7, 2022
9c37450
progressed in Deadzon. Improved the code navigation in dist generator…
boyali Mar 8, 2022
1fa2482
progressed in Deadzone. Implemented getDeadzone
boyali Mar 8, 2022
ab0a5dc
Some clang-tidy and MISRA corrections.
boyali Mar 8, 2022
210c198
Parameters added for the deadzone.
boyali Mar 8, 2022
a0f7557
Deadzone is put in the disturbance collection. Ready to integrate wit…
boyali Mar 8, 2022
28a535a
Put use_steering_input_delay option in the parameters.
boyali Mar 9, 2022
a8adc0d
Put use_acceleration_input_delay option in the parameters.
boyali Mar 9, 2022
9b397be
Put use_road_slope_disturbance option in the parameters.
boyali Mar 9, 2022
582d240
Put use_deadzone_disturbance option in the parameters.
boyali Mar 9, 2022
c7ab167
Disturbance message structure is implemented.
boyali Mar 9, 2022
bc1052b
Deadzone is completed, will check deadzone function implementation.
boyali Mar 9, 2022
2e67ef3
Deadzone description is added to the MD file.
boyali Mar 9, 2022
8e3bfcb
Deadzone function is amended.
boyali Mar 9, 2022
a87c6ab
Autoware_Control_Toolbox is separately implemented.
boyali May 15, 2022
ee40a29
Autoware_Control_Toolbox is separately implemented.
boyali May 23, 2022
c03756c
utils in ACT changed to act_utils
boyali May 23, 2022
3637295
Rebased on to the ACT, delay model continuous time update -> discrete…
boyali May 31, 2022
7559481
Rebased on to the improved ACT.
boyali Jun 3, 2022
e6a8638
Virtual destructors added to the disturbance interfaces.
boyali Jun 6, 2022
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
Prev Previous commit
Next Next commit
progressed in Deadzon. Improved the code navigation in dist generator…
… hpp.
  • Loading branch information
boyali committed Jun 6, 2022
commit 9c37450c65ca9ad8f3290f6583828e538dc656d4
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class DelayModelSISO

void printModelTF();


private:
double meanTd_{0.0}; // !<-@brief current delay that is used to compute a transfer function.
size_t pade_order_{1}; //!<-@brief order of Pade approximation.
Expand All @@ -65,7 +64,7 @@ class DelayModelSISO

};

// -------------------- INTERFACE CLASSES ------------------------------------
// -------------------- TIME DELAY DISTURBANCE CLASSES ------------------------------------
/**
* @class IDisturbanceInterface_TimeDelay
* @brief Input Disturbance TimeDelay Interface.
Expand All @@ -76,7 +75,7 @@ class IDisturbanceInterface_TimeDelay
// virtual ~disturbanceInterface() = default;
virtual double getDisturbedInput(double const &input) = 0;

virtual double getCurrentTimeDelayValue() const = 0;
[[nodiscard]] virtual double getCurrentTimeDelayValue() const = 0;

/**
* @brief returns a pair of time-delayed and nondelayed input pairs.
Expand All @@ -94,28 +93,6 @@ class IDisturbanceInterface_TimeDelay

};

/**
* @brief Input Disturbance Deadzone Interface
* */

class IDisturbanceInterface_DeadZone
{
public:
using pair_type = std::pair<std::pair<double, double>, std::pair<double, double>>;

virtual double getDisturbedInput(double const &input) = 0;

/**
* @brief Deadzone interface.
* @return pair_type pair ([ml, bl] , [mr, br]) where m is the slope of the deadzone, and b is x-intercept of
* the deadzone boundary
* */
[[nodiscard]] virtual pair_type getCurrentDeadZoneParameters() const = 0;

};


// -------------------- IDENTITY CLASSES ------------------------------------
/**
* @brief Identity class that maps the input as is when the time-delay value is zero in the settings.
* */
Expand All @@ -138,30 +115,7 @@ class InputDisturbance_IdentityTimeDelay : public IDisturbanceInterface_TimeDela

};

/**
* @brief Identity class that maps the input as is when the time-delay value is zero in the settings.
* */
class InputDisturbance_DeadZone : public IDisturbanceInterface_DeadZone
{
public:
double getDisturbedInput(double const &input) override
{
// ns_utils::print("Identity Input Disturbance is called ...");
return input;
}

[[nodiscard]] pair_type getCurrentDeadZoneParameters() const override
{
// m = 1, b =0 for both left and right parts of a dead-zone nonlinearity graph.
auto inactive_deadzone_params = std::make_pair(1.0, 0.0);

return std::make_pair(inactive_deadzone_params, inactive_deadzone_params);
}

};


// -------------------- DISTURBANCE CLASSES ------------------------------------
/**
* @brief Input disturbance classes.
*
Expand Down Expand Up @@ -213,9 +167,93 @@ class InputDisturbance_TimeDelayPade : public IDisturbanceInterface_TimeDelay

};

// -------------------- DEADZONE DISTURBANCE CLASSES ------------------------------------

/**
* @brief Input Disturbance Deadzone Interface
* */

class IDisturbanceInterface_DeadZone
{
public:
using pair_type = std::pair<std::pair<double, double>, std::pair<double, double>>;

virtual double getDisturbedInput(double const &input) = 0;

/**
* @brief Deadzone interface.
* @return pair_type pair ([ml, bl] , [mr, br]) where m is the slope of the deadzone, and b is x-intercept of
* the deadzone boundary
* */
[[nodiscard]] virtual pair_type getCurrentDeadZoneParameters() const = 0;

protected:
double current_deadzoned_input_{};

};


/**
* @brief Identity class that maps the input as is when the time-delay value is zero in the settings.
* */
class InputDisturbance_DeadZoneIdentity : public IDisturbanceInterface_DeadZone
{
public:
double getDisturbedInput(double const &input) override
{
// ns_utils::print("Identity Input Disturbance is called ...");
current_deadzoned_input_ = input;
return current_deadzoned_input_;
}

[[nodiscard]] pair_type getCurrentDeadZoneParameters() const override
{
// m = 1, b =0 for both left and right parts of a dead-zone nonlinearity graph.
auto &&inactive_deadzone_params = std::make_pair(1.0, 0.0);

return std::make_pair(inactive_deadzone_params, inactive_deadzone_params);
}


// -------------------- OUTPUT DISTURBANCE - INTERFACE CLASSES ------------------------------------
};

/**
* @brief Identity class that maps the input as is when the time-delay value is zero in the settings.
* */
class InputDisturbance_DeadZone : public IDisturbanceInterface_DeadZone
{
public:

double getDisturbedInput(double const &input) override;

[[nodiscard]] pair_type getCurrentDeadZoneParameters() const override;


private:
/**
* @brief [m, b]_{lr} are randomized. The equation of linear part (increasing) y = m*x + a*sin(2*pi*x+phi).
* */
std::mt19937 generator_;
std::exponential_distribution<> time_delay_exp_dist_{0.0};

std::uniform_real_distribution<> sampler_b_;
std::uniform_real_distribution<> sampler_m_;
std::uniform_real_distribution<> sampler_a_;
std::uniform_real_distribution<> sampler_phi_;

//@brief linear part function variables.
double m_line_slope_{1.};
double a_sin_mag_{};
double phi_phase_{};

// @brief Deadzone threshold left and right.
double bl_threshold_{};
double br_threshold_{};

};


// -------------------- OUTPUT DISTURBANCE - ROAD SLOPE ------------------------------------
/**
* @brief Input disturbance class.
* */
Expand All @@ -233,14 +271,13 @@ class IOutputDisturbance_Interface
[[nodiscard]] virtual double getCurrentDisturbanceParameterValue() const = 0;

protected:

double current_slope_disturbance_{}; //!<@brief g*sin(theta)

private:
};


// -------------------- OUTPUT DISTURBANCE - IDENTITY CLASSES ------------------------------------

class OutputDisturbance_AdditiveIdentity : public IOutputDisturbance_Interface
{
public:
Expand All @@ -256,9 +293,7 @@ class OutputDisturbance_AdditiveIdentity : public IOutputDisturbance_Interface
return current_slope_disturbance_;
}

private:
};
// -------------------- OUTPUT DISTURBANCE CLASSES ------------------------------------

class OutputDisturbance_SlopeVariation : public IOutputDisturbance_Interface
{
Expand Down Expand Up @@ -309,7 +344,7 @@ struct IDisturbanceCollection


// Destructor
~IDisturbanceCollection() = default;
// ~IDisturbanceCollection() = default;

// Input disturbances time-varying time-delay.
std::shared_ptr<IDisturbanceInterface_TimeDelay> steering_inputDisturbance_time_delay_ptr_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,13 @@ double OutputDisturbance_SlopeVariation::getDisturbedOutput()
current_slope_disturbance_ = g_ * sin(current_road_slope_);
return current_slope_disturbance_;
}

double InputDisturbance_DeadZone::getDisturbedInput(const double &input)
{
return input;
}

IDisturbanceInterface_DeadZone::pair_type InputDisturbance_DeadZone::getCurrentDeadZoneParameters() const
{
return IDisturbanceInterface_DeadZone::pair_type();
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ namespace simulation
const float64_t steer_td_angular_speed = declare_parameter("steer_td_angular_speed", 0.1);
const size_t steer_td_pade_order = static_cast<size_t>(declare_parameter("steer_td_pade_order", 2));

double dt = timer_sampling_time_ms_ / 1000.;
double dt = static_cast<double>(this->timer_sampling_time_ms_) / 1000.;

// STEERING Time DELAY
if (std::fabs(steer_time_delay) >= EPS)
Expand Down Expand Up @@ -322,7 +322,7 @@ namespace simulation
vehicle_model_type_ = VehicleModelType::DELAY_STEER_VEL;
vehicle_model_ptr_ = std::make_shared<SimModelDelaySteerVel>(
vel_lim, steer_lim, vel_rate_lim, steer_rate_lim, wheelbase,
timer_sampling_time_ms_ / 1000.0,
static_cast<double>(this->timer_sampling_time_ms_) / 1000.0,
vel_time_delay, vel_time_constant, steer_time_delay,
steer_time_constant);

Expand All @@ -331,7 +331,7 @@ namespace simulation
vehicle_model_type_ = VehicleModelType::DELAY_STEER_ACC;
vehicle_model_ptr_ = std::make_shared<SimModelDelaySteerAcc>(
vel_lim, steer_lim, vel_rate_lim, steer_rate_lim, wheelbase,
timer_sampling_time_ms_ / 1000.0,
static_cast<double>(this->timer_sampling_time_ms_) / 1000.0,
acc_time_delay, acc_time_constant, steer_time_delay,
steer_time_constant);

Expand All @@ -353,7 +353,7 @@ namespace simulation
vehicle_model_type_ = VehicleModelType::DELAY_STEER_ACC_GEARED;
vehicle_model_ptr_ = std::make_shared<SimModelDelaySteerAccGeared>(
vel_lim, steer_lim, vel_rate_lim, steer_rate_lim, wheelbase,
timer_sampling_time_ms_ / 1000.0,
static_cast<double>(this->timer_sampling_time_ms_) / 1000.0,
acc_time_delay, acc_time_constant, steer_time_delay,
steer_time_constant);
} else if (vehicle_model_type_str == "DELAY_STEER_ACC_GEARED_DIST")
Expand Down Expand Up @@ -461,7 +461,7 @@ namespace simulation
current_disturbance_gen_.road_slope_acc = static_cast<float32_t>(vehicle_model_ptr_->getCurrentRoadSlopeAccDisturbance());

pub_dist_generator_->publish(current_disturbance_gen_);
ns_utils::print("Current engage ", current_engage_);
// ns_utils::print("Current engage ", current_engage_);
}

void SimplePlanningSimulator::on_initialpose(const PoseWithCovarianceStamped::ConstSharedPtr msg)
Expand Down Expand Up @@ -640,9 +640,10 @@ namespace simulation
vehicle_model_type_ == VehicleModelType::DELAY_STEER_ACC_GEARED_DIST)
{
state << x, y, yaw, vx, steer, accx;
}
vehicle_model_ptr_->setState(state);
} else
{}

vehicle_model_ptr_->setState(state);
is_initialized_ = true;
}

Expand Down Expand Up @@ -789,7 +790,7 @@ namespace simulation
tf.transform.rotation = odometry.pose.pose.orientation;

tf2_msgs::msg::TFMessage tf_msg{};
tf_msg.transforms.emplace_back(std::move(tf));
(void) tf_msg.transforms.emplace_back(std::move(tf));
pub_tf_->publish(tf_msg);
}
} // namespace simple_planning_simulator
Expand Down