First download the source code on github
, remember to select the corresponding version
and put it under the src file in the workspace
1. Solve the dependency problem
rosdep install -i --from-path src --rosdistro eloquent -y
An error message appears:
gym@gym:~/wheeltec_robot_ros2$ rosdep install -i --from-path src --rosdistro eloquen -y
WARNING: given --rosdistro eloquen but ROS_DISTRO is "eloquent". Ignoring environment.
WARNING: ROS_PYTHON_VERSION is unset. Defaulting to 2
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
nav2_behavior_tree: Cannot locate rosdep definition for [behaviortree_cpp_v3]
nav2_system_tests: Cannot locate rosdep definition for [launch_testing]
nav2_map_server: Cannot locate rosdep definition for [launch_testing]
nav2_amcl: Cannot locate rosdep definition for [launch_testing]
nav2_bringup: Cannot locate rosdep definition for [launch_testing]
nav2_core: Cannot locate rosdep definition for [launch_testing]
nav2_bt_navigator: Cannot locate rosdep definition for [behaviortree_cpp_v3]
nav2_util: Cannot locate rosdep definition for [test_msgs]
nav2_costmap_2d: Cannot locate rosdep definition for [launch_testing]
Solution:
Add the -r parameter, ignore the error and reinstall the dependencies
rosdep install -i --from-path src --rosdistro eloquent -y -r
2. Compile:
colcon build
Still getting an error:
CMake Error at test/CMakeLists.txt:4 (find_package):
By not providing "Findtest_msgs.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"test_msgs", but CMake did not find one.
Could not find a package configuration file provided by "test_msgs" with
any of the following names:
test_msgsConfig.cmake
test_msgs-config.cmake
Add the installation prefix of "test_msgs" to CMAKE_PREFIX_PATH or set
"test_msgs_DIR" to a directory containing one of the above files. If
"test_msgs" provides a separate development package or SDK, be sure it has
been installed.
---
Solution: Manually install dependent packages
There are several similar dependent packages installed together
sudo apt install ros-eloquent-test-msgs
sudo apt install ros-eloquent-behaviortree-cpp-v3
sudo apt install ros-eloquent-gazebo-rospkgsr
Here is a trick to install the dependency package: if you don’t know the name of the dependency package in this version, such as test-msgs, you can type ros-eloquent-test first and then double-click the Tab key to find the corresponding package. .
Recompilation was successful.