Skip to content

[#64] Add parameter to enable the OI mode reporting bug workaround #95

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

Merged
merged 2 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ $ ros2 launch create_bringup create_2.launch config:=/abs/path/to/config.yaml de
`publish_tf` | Publish the transform from `odom_frame` to `base_frame` | `true`
`robot_model` | The type of robot being controlled (supported values: `ROOMBA_400`, `CREATE_1` and `CREATE_2`) | `CREATE_2`
`baud` | Serial baud rate | Inferred based on robot model, but is overwritten upon providing a value
`oi_mode_workaround` | Some Roomba models incorrectly report the current OI mode in their sensor streams. Setting this to `true` will cause `libcreate` to decrement the OI mode received in the sensor stream by `1` | `false`

### Publishers

Expand Down Expand Up @@ -242,6 +243,8 @@ Contributing to the development and maintenance of _create\_autonomy_ is encoura
- Added Create 1 description ([#27](https://github.com/AutonomyLab/create_autonomy/pull/27)).
* [Pedro Grojsgold](https://github.com/pgold)
- Ported to ROS 2 ([commit](https://github.com/AutonomyLab/create_robot/commit/198345071aa8a9df154d8490feabf5784b78da16)).
* [Josh Gadeken](https://github.com/process1183)
- Added parameter for [libcreate's OI Mode reporting workaround](https://github.com/AutonomyLab/libcreate/pull/67) ([#95](https://github.com/AutonomyLab/create_robot/pull/95))

[libcreate]: https://github.com/AutonomyLab/libcreate
[oi_spec]: https://www.adafruit.com/datasheets/create_2_Open_Interface_Spec.pdf
Expand Down
1 change: 1 addition & 0 deletions create_driver/include/create_driver/create_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class CreateDriver : public rclcpp::Node
double loop_hz_;
bool publish_tf_;
int baud_;
bool oi_mode_workaround_;

void cmdVelCallback(geometry_msgs::msg::Twist::UniquePtr msg);
void debrisLEDCallback(std_msgs::msg::Bool::UniquePtr msg);
Expand Down
5 changes: 5 additions & 0 deletions create_driver/src/create_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ CreateDriver::CreateDriver()
latch_duration_ = declare_parameter<double>("latch_cmd_duration", 0.2);
loop_hz_ = declare_parameter<double>("loop_hz", 10.0);
publish_tf_ = declare_parameter<bool>("publish_tf", true);
oi_mode_workaround_ = declare_parameter<bool>("oi_mode_workaround", false);

auto robot_model_name = declare_parameter<std::string>("robot_model", "CREATE_2");
if (robot_model_name == "ROOMBA_400")
Expand Down Expand Up @@ -75,6 +76,10 @@ CreateDriver::CreateDriver()
// Disable signal handler; let rclcpp handle them
robot_ = new create::Create(model_, false);

// Enable/disable the OI mode reporting workaround in libcreate.
// https://github.com/AutonomyLab/create_robot/issues/64
robot_->setModeReportWorkaround(oi_mode_workaround_);

if (!robot_->connect(dev_, baud_))
{
RCLCPP_FATAL(get_logger(), "[CREATE] Failed to establish serial connection with Create.");
Expand Down