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

Workspace with Husky for Simulation and Real Robot Control #10

Merged
merged 66 commits into from
Jul 4, 2024

Conversation

YuZhong-Chen
Copy link
Collaborator

@YuZhong-Chen YuZhong-Chen commented Sep 23, 2023

Closes: #3 #17

Copy link
Owner

@j3soon j3soon 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 patch!

Aside from the individual comments, please:

  • Separate copying/moving/re-formatting/fixes into different commits.
  • Minor: Change the directory name from husky-ws to husky_ws (or maybe husky-sim_ws) by following the style of template_ws.

There are issues in several commits, and should be amended accordingly:

If you have any additional descriptions or references, please also include them in the commit history or file comments. Please also remove any redundant changes to prevent potential bugs. I would greatly appreciate it if this patch could include as much detail as possible.


The comments of this review may seem a bit too obsessive about maintaining a clean commit history. However, please note that this patch is based on many third-party code. It is always beneficial to take extra caution when copying/modifying third-party code. We need to maintain the ability to patch/debug these third-party code in the future. Consider the case where there seems to be a bug in the third-party code sometime in the future:

  • If we want to check whether the third-party has provided corresponding patches, we will need the latest commit id of the third-party code included in this repo to quickly determine which patches haven't been included.
  • If we want to apply the latest patches, we do not want to deal with broken file history or large changes. We would prefer minimal changes on third-party code.
  • If we are unsure about the cause of the bug, detailed commit description for each modifications can help us identify whether the bug is caused by our changes, or is due to the third-party code.
  • Etc.

In short, investing extra time in commit time can result in substantial time savings in the future. If there are any undocumented changes in this patch, there is a high chance that we will lose the ability to debug these third-party code and end up reverting this patch and re-implement it again in the future.


The comments in this review corresponds to the 7 commits within commit 352c714 and commit dbcf1a5 . I haven't reviewed the rest of the commits yet, but I believe they may contain related issues and should be fixed accordingly before re-requesting review.

Please tidy up the commit history, apply a force-push, and re-request review. Thank you!

husky-ws/.devcontainer/devcontainer.json Outdated Show resolved Hide resolved
husky-ws/docker/Dockerfile Outdated Show resolved Hide resolved
husky-ws/docker/docker-compose.yaml Outdated Show resolved Hide resolved
husky-ws/docker/docker-compose.yaml Outdated Show resolved Hide resolved
husky-ws/docker/docker-compose.yaml Outdated Show resolved Hide resolved
husky-ws/docker/docker-compose.yaml Outdated Show resolved Hide resolved
husky-ws/docker/docker-compose.yaml Outdated Show resolved Hide resolved
husky-ws/src/husky/husky_rviz/launch/rviz_launch.py Outdated Show resolved Hide resolved
husky-ws/src/husky/husky_rviz/rviz/view_model.rviz Outdated Show resolved Hide resolved
@YuZhong-Chen YuZhong-Chen force-pushed the husky_sim branch 2 times, most recently from 26037d1 to 0097270 Compare October 14, 2023 12:58
Note that there is a file named "install" in husky/husky_bringup/scripts directory,
which has the same name as the ros2 building folder.
The rule in gitignore will ignore the file, so it needs to be added alone.

Reference : https://github.com/husky/husky/tree/1e0b1d14d657f04ec3a86e73d6676a2cf7af6f79
The command finds the packages:
`rosdep install --from-paths src --ignore-src --rosdistro humble -y`

Using the command inside the container after creation will take much time. You will need to install those packages every time you create a container from the image. It is better to install these packages in the image by modifying the Dockerfile.
…sky_viz.

The change in this commit is not necessary, but it will improve code readability.
The default LiDAR of husky is LMS1xx. For testing the correction of the code, I follow the default now. It will be changed to VLP-16 later when I finish the basics.

Reference: https://github.com/clearpathrobotics/LMS1xx/tree/90001ac2849c9f6ab9ca9bbfeb816f9b66f966de
Since we won't use this LiDAR in reality, there is no need to compile the driver for it.
We only need the LiDAR model for testing.
Uncomment the settings in urdf to support laser_enabled and realsense_enabled.
The origin launch file will launch Husky's description alone, this may cause asynchronous to other repo. So I modify the code to reuse the launch file in the husky description.
The original repository only supports ROS1, and migrating it to ROS2 is too challenging.
I will create a new repository to maintain the same functionality.
Set rate to 5.

Warning Message:
[async_slam_toolbox_node-9] [INFO] [1697282044.282229935] [slam_toolbox]: Message Filter dropping message: frame 'base_laser' at time 1305.200 for reason 'discarding message because the queue is full'
Remove the setting of QoS.
In order to debug the data, I config a new rviz param.

Reference: https://navigation.ros.org/setup_guides/odom/setup_odom.html
The original repository is not designed for ROS, so the package structure differs from a typical package.
I have deleted all the CMakeLists.txt files in the repository to prepare for creating a ROS-like package in the future.
Add the CMakeLists.txt and package.xml files to the folder to indicate that it is a ROS package.
Note that I didn't compile the plugins in the CMakeLists.txt. This is because we won't be using those plugins.
Since we will be using `colcon` to build the package, there is no need for the "README.md" that explains how to build or update the package.
I have removed all files related to it.
Remove the plugins that we won't use.
Copy link
Owner

@j3soon j3soon left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the aforementioned simulation issue. The bug seems pretty tricky to catch.

I can confirm the simulation works well on my machine. I'll test the real-world control part soon.

j3soon and others added 5 commits April 14, 2024 09:03
I choose to rename `imu/data_raw` to `imu/data`. This is because data published by the gazebo imu sensor plugin includes orientation data, which means it is already post-processed.

Although `imu/data_raw` is not required in simulation, it'll be used in real-world deployment. The `imu_filter_madgwick` package is used to convert raw IMU data (without orientation) into a post-processed IMU data (with orientation).

Refs:
* husky/husky#113
* http:https://wiki.ros.org/imu_filter_madgwick

I believe this topic name mismatch issue is due to the following commit:

Ref: husky/husky@e379ee8
There is a `/odom` TF but no `/odom` topic. This fixes all typos on subscribing to the `/odom` topic.
Since husky is nonholonomic, we do not need to fuse the Y data provided by the IMU as described in the `robot_localization` document. I simply follow the odom & imu configs provided by it.

Ref: http:https://docs.ros.org/en/melodic/api/robot_localization/html/configuring_robot_localization.html#fusing-unmeasured-variables
To address the issue of pose data from slam_toolbox occasionally jumping over time, it's advisable not to directly fuse it into ekf_node.

In order to prevent the covariance from growing excessively, we can add configuration for `dynamic_process_noise_covariance` in the `robot_localization` package. This will enable the covariance to be dynamically scaled.

Reference:
- https://docs.ros.org/en/melodic/api/robot_localization/html/state_estimation_nodes.html#dynamic-process-noise-covariance

Co-authored-by: Johnson Sun <[email protected]>
Copy link
Owner

@j3soon j3soon left a comment

Choose a reason for hiding this comment

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

Simulation code works as expected; Real robot control code works well on x86 system, but currently have docker building issues on arm system (Jetson AGX Orin).

  • The docker compose command requires installing the latest docker & NVIDIA container toolkit on Jetson AGX Orin.

  • I recall that the arm system error includes the following when executing clearpath_computer_installer.sh:

    E: Unable to locate package ros-humble-clearpath-robot
    

Will continue fixing it tomorrow.


2024/05/29 Update:

The issue is due to ros-humble-clearpath-robot binaries are only available on amd64 but not on arm64.

The straightforward approach is to install package from source when on arm64: https://github.com/clearpathrobotics/clearpath_robot

Will check if this approach works.

@j3soon
Copy link
Owner

j3soon commented May 29, 2024

Current version can reliably control real husky by either amd64 or arm64 system.

@YuZhong-Chen please help review my commits or perform further changes.

Please re-request a review when no further changes are required, and I'll go ahead and merge this PR. Thanks!

… correctly.

If we intend to use a built-in global variable in a Dockerfile, such as `TARGETARCH`, we should specify it initially using `ARG TARGETARCH`. This ensures that the Docker recognizes and properly uses the variable throughout its execution.

Reference:
- https://docs.docker.com/reference/dockerfile/#automatic-platform-args-in-the-global-scope
- https://docs.docker.com/compose/compose-file/build/#platforms
@YuZhong-Chen YuZhong-Chen requested a review from j3soon June 20, 2024 16:42
@YuZhong-Chen
Copy link
Collaborator Author

Sorry for the late response.
I have tested on my laptop (amd64) and NV Orin (arm64). I found that on the laptop, the packages like gazebo plugin were not correctly installed inside the container. One reason was a mistake in the command within the 'if' condition in the Dockerfile. Another reason was that the variable TARGETARCH was not defined before its use. I have made the necessary corrections, retested on both platforms, and successfully ran them on both sides. Please review this commit again. If everything looks good to you, I think we can merge this PR. Thanks!

@j3soon
Copy link
Owner

j3soon commented Jul 3, 2024

Thanks for the fix!

Could you please help check if I missed out any code license we've included in this PR? (see the latest commit)

In addition, should the LiDAR LMS1xx be replaced with VLP-16 LiDAR in this PR? Or is it ok to defer it to another PR some time in the future?

@YuZhong-Chen
Copy link
Collaborator Author

I think one license is missing: the license for the udev rule for Husky. See commit bf09fe1, which copies the udev rule from here. Since it's a different repository, we may need to add its license as well.

@YuZhong-Chen
Copy link
Collaborator Author

Additionally, regarding the replacement of the LiDAR with the VLP-16, I think we can merge this PR first for the convenience of merging other branches. After I finish testing in a few days, I will open a new PR that includes both the VLP-16 and ZED2 to match the current configuration of the actual machine.

Copy link
Owner

@j3soon j3soon left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good to me!

@j3soon j3soon merged commit e8abad1 into j3soon:master Jul 4, 2024
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.

Setup Husky model for Gazebo and Nav2 Simulation
3 participants