Skip to content

Commit 2c531d9

Browse files
BorgesJVTdestogl
authored andcommitted
wheels first-order dynamics
1 parent b6d1d24 commit 2c531d9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ros2_control_demo_hardware/src/diffbot_system.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,12 @@ hardware_interface::return_type DiffBotSystemHardware::read()
176176
rclcpp::get_logger("DiffBotSystemHardware"),
177177
"Reading...");
178178

179+
double tau = 0.2;
180+
double a = tau/(tau+1);
181+
double b = 1/(tau+1);
179182
for (uint i = 0; i < hw_commands_.size(); i++) {
180-
// Simulate DiffBot's movement
181-
hw_states_[1] = hw_commands_[i] + (hw_states_[1] - hw_commands_[i]) / hw_slowdown_;
183+
// Simulate DiffBot wheels's movement as a first-order system
184+
hw_states_[1] = a*hw_states_[1] + b*hw_commands_[i];
182185
hw_states_[0] += hw_states_[1] / 2;
183186
RCLCPP_INFO(
184187
rclcpp::get_logger("DiffBotSystemHardware"),

0 commit comments

Comments
 (0)