Added new arduino code

This commit is contained in:
Tim Korjakow
2023-06-15 15:09:34 +02:00
parent 5d0513a073
commit 6276b632ef
6 changed files with 55 additions and 27 deletions

View File

@ -101,7 +101,6 @@ return_type DiffDriveArduino::read(const rclcpp::Time & /* time */, const rclcpp
double deltaSeconds = diff.count();
time_ = new_time;
if (!arduino_.connected())
{
return return_type::ERROR;
@ -112,31 +111,17 @@ return_type DiffDriveArduino::read(const rclcpp::Time & /* time */, const rclcpp
// Force the wheel position
l_wheel_.pos = l_wheel_.pos + l_wheel_.vel * deltaSeconds;
r_wheel_.pos = r_wheel_.pos + r_wheel_.vel * deltaSeconds;
return return_type::OK;
return return_type::OK;
}
return_type DiffDriveArduino::write(const rclcpp::Time & /* time */, const rclcpp::Duration & /* period */)
{
if (!arduino_.connected())
{
return return_type::ERROR;
}
arduino_.setMotorValues(l_wheel_.cmd, r_wheel_.cmd);
return return_type::OK;
return return_type::OK;
}
} // namespace diffdrive_arduino