51 CallbackReturn on_init(
52 const hardware_interface::HardwareComponentInterfaceParams & params)
override;
54 std::vector<hardware_interface::StateInterface::ConstSharedPtr> on_export_state_interfaces()
56 std::vector<hardware_interface::CommandInterface::SharedPtr> on_export_command_interfaces()
59 CallbackReturn on_activate(
const rclcpp_lifecycle::State & previous_state)
override;
60 CallbackReturn on_deactivate(
const rclcpp_lifecycle::State & previous_state)
override;
62 hardware_interface::return_type
read(
63 const rclcpp::Time & time,
const rclcpp::Duration & period)
override;
64 hardware_interface::return_type
write(
65 const rclcpp::Time & time,
const rclcpp::Duration & period)
override;
69 double param(
const std::string & name,
double fallback)
const;
70 bool param_bool(
const std::string & name,
bool fallback)
const;
75 double pendulum_accel(
double q2,
double q2_dot,
double q1_dot,
double q1_ddot)
const;
78 void integrate(
double h);
82 void publish_states(
double dt_sim);
84 static double wrap_pi(
double a);
88 double J2_pivot_{4.447e-5};
89 double J2_com_{8.06e-6};
99 double J1_nom_{0.0}, J2_com_nom_{0.0}, m2_nom_{0.0}, l2_nom_{0.0};
100 double b1_nom_{0.0}, b2_nom_{0.0}, c2_nom_{0.0};
103 double motor_limit_{2.35619449};
104 double motor_max_vel_{5.0};
105 double motor_max_accel_{200.0};
106 double motor_max_torque_{0.4};
107 bool model_step_loss_{
true};
108 double stop_restitution_{0.0};
111 double motor_steps_per_rev_{6400.0};
112 double encoder_counts_per_rev_{4096.0};
113 double encoder_noise_{0.0002};
114 double encoder_offset_{0.0};
115 bool pendulum_vel_from_encoder_{
true};
116 double vel_filter_alpha_{0.95};
117 double motor_vel_noise_{0.001};
118 double report_offset_{0.0};
121 double pendulum_accel_noise_{
123 double motor_accel_noise_{0.005};
124 double param_randomization_{0.005};
125 double initial_q2_{0.1};
126 double initial_q2_jitter_{0.002};
129 double sim_speed_{1.0};
130 double max_substep_{5.0e-4};
131 double max_cycle_dt_{0.1};
132 int max_substeps_{4000};
135 double q1_{0.0}, q1_dot_{0.0};
136 double q2_{0.0}, q2_dot_{0.0};
137 double q2_ddot_prev_{0.0};
138 double sim_time_{0.0};
139 bool at_limit_{
false};
140 bool step_loss_{
false};
143 double q2_meas_prev_{0.0};
144 double q2_dot_filt_{0.0};
145 bool have_prev_meas_{
false};
147 std::vector<double> hw_states_;
148 std::vector<double> hw_commands_;
150 std::vector<hardware_interface::StateInterface::SharedPtr> state_interfaces_;
151 std::vector<hardware_interface::CommandInterface::SharedPtr> command_interfaces_;
153 rclcpp::Clock clock_{RCL_STEADY_TIME};
156 std::normal_distribution<double> normal_{0.0, 1.0};
hardware_interface::return_type write(const rclcpp::Time &time, const rclcpp::Duration &period) override
Write the current command values to the actuator.
Definition mock_pendulum_hardware.cpp:449
hardware_interface::return_type read(const rclcpp::Time &time, const rclcpp::Duration &period) override
Read the current state values from the actuator.
Definition mock_pendulum_hardware.cpp:404