Skip to content
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

ROS2 version #3

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

mzahana
Copy link

@mzahana mzahana commented Mar 28, 2024

I modified this package to work with ROS2. It was tested successfully on ROS humble on raspberry pi 4B with OS Bookworm.
I removed the dependency on the i2c package by including the source code in this package so it can be self contained.

I hope this is useful for others.

Thank you.

Copy link
Contributor

@mateusmenezes95 mateusmenezes95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this port. I am pleased that we are providing a valuable package for the open-source community.

I would like to express some concerns about the potential merger of i2c_device_ros into this package, as I mentioned in the header file. In light of these concerns, I have decided to pause my current revision and would like to propose further discussion on this matter after I have had the opportunity to continue with my review.

# add_definitions(-Wall -Werror)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we put C++17 here to comply with the REP 2000 for Humble release

Comment on lines +29 to +32
# Link against ROS 2 libraries
# target_link_libraries(mpu6050_node_lib
# ${rclcpp_LIBRARIES}
# )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove commented lines

Comment on lines +51 to +56
# Install targets
# install(TARGETS
# mpu6050_node
# mpu6050_calibration_node
# mpu6050_node_lib
# DESTINATION lib/${PROJECT_NAME})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove commented lines

**Maintainer:** Mateus Meneses, [email protected]

The MPU6050 Driver package has been tested under [ROS] Kinetic and [Raspbian Jessie].
The barnch `ros2_humble` has been tested under [ROS] `humble` and [Raspberry Pi Bookworm] .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The barnch `ros2_humble` has been tested under [ROS] `humble` and [Raspberry Pi Bookworm] .
The branch `ros2_humble` has been tested under [ROS] `Humble Hawksbill` and [Raspberry Pi Bookworm] .

```sh
$ cd <YOUR_WS>/src
$ git clone https://github.com/mateusmenezes95/mpu6050_driver.git
$ git clone -b ros2_humble https://github.com/mateusmenezes95/mpu6050_driver.git
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this PR target the master branch, I suggest remove the branch option from this command

Comment on lines +59 to +71
// void MPU6050Node::loadParameters() {
// this->declare_parameter("bus_uri", "/dev/i2c-1");
// this->declare_parameter("mpu_address", 0x68);
// this->declare_parameter("pub_rate", 30.0f);
// this->declare_parameter("frame_id", "imu_link");
// this->declare_parameter("axes_offsets", std::vector<int>{0, 0, 0, 0, 0, 0});

imu_data.linear_acceleration.x = mpu_data.accel.x * gravity_value;
imu_data.linear_acceleration.y = mpu_data.accel.y * gravity_value;
imu_data.linear_acceleration.z = mpu_data.accel.z * gravity_value;
// this->get_parameter("bus_uri", i2c_bus_uri_);
// this->get_parameter("mpu_address", mpu6050_addr_);
// this->get_parameter("pub_rate", pub_rate_);
// this->get_parameter("frame_id", imu_frame_id_);
// this->get_parameter("axes_offsets", axes_offsets_);
// }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the commented code

Comment on lines +35 to +37
add_executable(mpu6050_node src/main.cpp)
ament_target_dependencies(mpu6050_node rclcpp sensor_msgs)
target_link_libraries(mpu6050_node mpu6050_node_lib)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
add_executable(mpu6050_node src/main.cpp)
ament_target_dependencies(mpu6050_node rclcpp sensor_msgs)
target_link_libraries(mpu6050_node mpu6050_node_lib)
add_executable(mpu6050_node
src/main.cpp
)
ament_target_dependencies(mpu6050_node
rclcpp
sensor_msgs
)
target_link_libraries(mpu6050_node
mpu6050_node_lib
)

Nitpick to comply with what we do in our internal repositories. Please apply this to the following lines, too.

Comment on lines +58 to +59
install(DIRECTORY include/
DESTINATION include)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
install(DIRECTORY include/
DESTINATION include)
install(
DIRECTORY include/
DESTINATION include
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is almost the same for the node. Why should we have both of these two files?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I'm afraid I have to disagree with bringing this library to this package. The i2c_device_ros library is intended to be used in devices beyond the MPU6050, e, g. to be a generic class for I2C devices connected to Raspberries. Hence, if the package for this library receives improvements, it will not enjoy these improvements unless we bring it manually, which is undesirable. Could you please evaluate if you can port the i2c_device_ros to ROS 2 thus, we use here ament_target_dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants