orjano-max / ORJANOS_MASTER_REPO

This is the github repo for orjano's master thesis
1 stars 0 forks source link

Husky on ROS2 Galactic #9

Closed orjano-max closed 1 year ago

orjano-max commented 1 year ago

Issues When Porting Husky to Galactic

The porting to ros2 galactic had some issues.mainly, the issues were:

  1. Build issues when building the official husky galactic packages from source
  2. Launch file used for Foxy packages not working for galactic
  3. Husky not reacting to twist commands from teleop keyboard or teleop joystick.
  4. Husky robot jumping around in the odom frame. This issue appeared when the localization parameter "publish_tf" to true. It has to be true in order to use the fused pose estimate from the ekf node(Ekstended kalman filter node). The filter fuses odometry and imu in this case.
  5. Pose estimation not "yawing" robot when "yawing" it in real life. This could be seen in Rviz as the robot wouldn't turn in rviz when turnng it irl.
  6. Nav2 packages not able to launch
orjano-max commented 1 year ago

Issue 1

Build Error Message

--- stderr: husky_base                               
In file included from /home/husky/galhusky_ws/src/husky/husky_base/src/husky_hardware.cpp:32:
/home/husky/galhusky_ws/src/husky/husky_base/include/husky_base/husky_hardware.hpp:32:23: error: ‘CallbackReturn’ in namespace ‘hardware_interface’ does not name a type
   32 |   hardware_interface::CallbackReturn on_init(const hardware_interface::HardwareInfo & info) override;
      |                       ^~~~~~~~~~~~~~
/home/husky/galhusky_ws/src/husky/husky_base/include/husky_base/husky_hardware.hpp:41:23: error: ‘CallbackReturn’ in namespace ‘hardware_interface’ does not name a type
   41 |   hardware_interface::CallbackReturn on_activate(const rclcpp_lifecycle::State & previous_state) override;
      |                       ^~~~~~~~~~~~~~
/home/husky/galhusky_ws/src/husky/husky_base/include/husky_base/husky_hardware.hpp:44:23: error: ‘CallbackReturn’ in namespace ‘hardware_interface’ does not name a type
   44 |   hardware_interface::CallbackReturn on_deactivate(const rclcpp_lifecycle::State & previous_state) override;
      |                       ^~~~~~~~~~~~~~
/home/husky/galhusky_ws/src/husky/husky_base/src/husky_hardware.cpp:194:21: error: ‘CallbackReturn’ in namespace ‘hardware_interface’ does not name a type
  194 | hardware_interface::CallbackReturn HuskyHardware::on_init(const hardware_interface::HardwareInfo & info)
      |                     ^~~~~~~~~~~~~~
/home/husky/galhusky_ws/src/husky/husky_base/src/husky_hardware.cpp:313:21: error: ‘CallbackReturn’ in namespace ‘hardware_interface’ does not name a type
  313 | hardware_interface::CallbackReturn HuskyHardware::on_activate(const rclcpp_lifecycle::State & /*previous_state*/)
      |                     ^~~~~~~~~~~~~~
/home/husky/galhusky_ws/src/husky/husky_base/src/husky_hardware.cpp:332:21: error: ‘CallbackReturn’ in namespace ‘hardware_interface’ does not name a type
  332 | hardware_interface::CallbackReturn HuskyHardware::on_deactivate(const rclcpp_lifecycle::State & /*previous_state*/)
      |                     ^~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/husky_hardware.dir/build.make:63: CMakeFiles/husky_hardware.dir/src/husky_hardware.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/husky_hardware.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
---
Failed   <<< husky_base [18.3s, exited with code 2]

Solution Part 1

Compilet can't seem to find CallBackReturn in the namespace defined in the code. This therefore has to be changed to the standard call. From

hardware_interface::CallbackReturn

To

rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn

This change has to be done in two files:

line 32, 41 and 44 in the file: _husky/husky_base/include/husky_base/huskyhardware.hpp

and line 194 313 and 332 in the file: _husky/husky_base/src/huskyhardware.cpp

Solution Part 2

The return values of the functions using CallBackReturn also has to be rewritten. For example: Line 196 in _husky/husky_base/src/huskyhardware.cpp is rewritten from:

if (hardware_interface::SystemInterface::on_init(info) != hardware_interface::CallbackReturn::SUCCESS)

to

if (hardware_interface::SystemInterface::on_init(info) != rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS)

This applies to line 196, 198, 231, 240, 249, 259, 268, 272, 329 and 336 in _husky/husky_base/src/huskyhardware.cpp. Some lines call for "hardware_interface::CallbackReturn::SUCCESS" as above and some call for "hardware_interface::CallbackReturn::ERROR".

orjano-max commented 1 year ago

Issue 2

Problem

The launch file used to launch the husky in ROS2 Foxy and all attached sensors. Does not work for the galactic packages as well. This is due to changes in files in the ROS2 packages from Foxy to Galactic, specifically, the launch files.

Solution

The solution is to make a new launch file based on the husky_base launch file provided in the source code from clearpath. The differences can be seen by comparing the file _code/src/huskygroup/launch/husky1.launch.py from the main branch(Foxy) to the galactic branch in this repo.

orjano-max commented 1 year ago

Issue 3

Problem

The husky did not respond to controller input.

Solution

In ROS2 Foxy, the launch file for husky_base launches the husky controllers as well as joy teleop nodes. This is not the case for the husky_base launch file in ROS2 Galactic. Additionally, the way the controller and keyboard interacts with the husky is completely different in galactic, as the Galactic debian library is missing a package called interactive_marker_twist_server for ARM CPU's. interactive_marker_twist_server is therefore added to this repo and built from source along with the other packages. Adding the interactive_marker_twist_serverpackage, allowed me to use similar teleop configuration for joy teleop and teleop base as in foxy. These nodes are added to the launch description in the _code/src/huskygroup/launch/husky1.launch.py file.

orjano-max commented 1 year ago

Issue 4

Problem

Husky jerking around in odom frame.

Solution

This happens since both the ekf_node and the husky_velocity_controlleris publishing odom tf. Set a parameter for the husky velocity controller configuration file "control.yaml" to false:

enable_odom_tf: false

Now, only the ekf_node publishes this transform.

orjano-max commented 1 year ago

Issue 5

Problem

Pose estimation not "yawing" robot when "yawing" it in real life

Solution

Apparently, imu_link is not placed at base_link anymore. But it can be set by environment variables. Added the following lines to line 12 in the file code/src/husky_group/launch/husky1.launch.py:

os.environ["HUSKY_IMU_XYZ"] = "0 0 0"
os.environ["HUSKY_IMU_RPY"] = "0 0 0"
orjano-max commented 1 year ago

Issue 6

Problem

Even though the Nav2 packages was installed through debian, they were not able to launch when passing our parameter files into the launch argument.

Solution

The parameter files for Nav2 Foxy and Nav2 Galactic have differences. Updated parameter files for Galactic were therefore made. This was then done for all packages where we pass our own parameter files. to prevent future bugs caused by parameter incompatibility

orjano-max commented 1 year ago

Issues solved