Skip to content

Commit 94e2d9c

Browse files
BorgesJVTdestogl
authored andcommitted
velocity and position models to simulate read hardware
1 parent cd92509 commit 94e2d9c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ros2_control_demo_hardware/src/diffbot_system.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,14 @@ hardware_interface::return_type DiffBotSystemHardware::read()
177177
rclcpp::get_logger("DiffBotSystemHardware"),
178178
"Reading...");
179179

180-
for (uint i = 0; i < hw_states_.size(); i++) {
180+
for (uint i = 0; i < hw_commands_.size(); i++) {
181181
// Simulate DiffBot's movement
182-
hw_states_[i] = hw_commands_[i] + (hw_states_[i] - hw_commands_[i]) / hw_slowdown_;
182+
hw_states_[1] = hw_commands_[i] + (hw_states_[1] - hw_commands_[i]) / hw_slowdown_;
183+
hw_states_[0] += hw_states_[1] / 2;
183184
RCLCPP_INFO(
184185
rclcpp::get_logger("DiffBotSystemHardware"),
185-
"Got state %.5f for '%s'!", hw_states_[i], info_.joints[i].name.c_str());
186+
"Got position state %.5f and velocity state %.5f for '%s'!",
187+
hw_states_[0], hw_states_[1], info_.joints[i].name.c_str());
186188
}
187189
RCLCPP_INFO(
188190
rclcpp::get_logger("DiffBotSystemHardware"),

0 commit comments

Comments
 (0)