Errors when Compile and source the ros2 workspace

Hi Support,

So I’m following the instructions in the 1. ROS2 Manipulation Moveit,

Up to the compiling section towards the bottom:

cd ~/ros2_ws/
source /opt/ros/foxy/setup.bash
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
source install/setup.bash

And I received these errors below:

user:~/ros2_ws$ colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
Starting >>> grasping_msgsStarting >>> my_moveit2_config
Starting >>> ur_e_description
Finished <<< my_moveit2_config [0.51s]Finished <<< ur_e_description [0.56s]
— stderr: grasping_msgs
CMake Warning (dev) at CMakeLists.txt:2 (project):
Policy CMP0048 is not set: project() command manages VERSION variables.
Run “cmake --help-policy CMP0048” for policy details. Use the cmake_policy
command to set the policy and suppress this warning.

The following variable(s) would be set to empty:

CMAKE_PROJECT_VERSION
CMAKE_PROJECT_VERSION_MAJOR
CMAKE_PROJECT_VERSION_MINOR
CMAKE_PROJECT_VERSION_PATCH

This warning is for project developers. Use -Wno-dev to suppress it.

Traceback (most recent call last):
File “/home/user/ros2_ws/build/grasping_msgs/catkin_generated/generate_cached_setup.py”, line 22, in
code = generate_environment_script(’/home/user/ros2_ws/build/grasping_msgs/devel/env.sh’)
File “/opt/ros/noetic/lib/python3/dist-packages/catkin/environment_cache.py”, line 63, in generate_environment_script
env_after = ast.literal_eval(output.decode(‘utf8’))
File “/usr/lib/python3.8/ast.py”, line 59, in literal_eval
node_or_string = parse(node_or_string, mode=‘eval’)
File “/usr/lib/python3.8/ast.py”, line 47, in parse
return compile(source, filename, mode, flags,
File “”, line 1
ROS_DISTRO was set to ‘foxy’ before. Please make sure that the environment does not mix paths from different distributions.
^
SyntaxError: invalid syntax
CMake Error at /opt/ros/noetic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
execute_process(/usr/bin/python3
“/home/user/ros2_ws/build/grasping_msgs/catkin_generated/generate_cached_setup.py”)
returned error code 1
Call Stack (most recent call first):
/opt/ros/noetic/share/catkin/cmake/all.cmake:208 (safe_execute_process)
/opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:20 (include)
CMakeLists.txt:4 (find_package)


Failed <<< grasping_msgs [1.36s, exited with code 1]

Summary: 2 packages finished [1.62s]
1 package failed: grasping_msgs
1 package had stderr output: grasping_msgs

And then when I tried the ros2 launch,it failed completely with the screenshot below:

Please assist in resolving this, as I’m unable to move on to ROS1 Bridge

Hi @wai.mak
there is a small mistake in the notebook which indicates that you must clone the grasping_msgs package. You don’t need to clone that, and that is the source of the error. That package is in ROS1 format and we are indicating that students clone it in the ROS2 ws. There it is the error during compilation.

Please delete the full package grasping_msgs and also de build and install directories. Then compile again. Everything should work properly.

ok @rtellez , removing the grasping_msgs package in ROS2 ws worked for the compile with no errors, please amend this course so others wont need to deal with this mistake here…,

but another issue came up in rviz2 when I do the ros2 launch my_moveit2_config my_planning_execution.launch.py launch_rviz:=true , see below

it comes up blank…which it shouldn’t as shown in this course 1.

Please advise…, (am frustrated…getting problems here and there…I’m just following step by step on the course…)

Hello @wai.mak ,

Have you created the file view_robot.rviz as indicated in the notebook (make sure you’ve created it properly)? You need to have this file in order to properly visualize Moveit2 in Rviz2.

Hi @albertoezquerro,

Ok got it, when I copy over the rviz code to create the view_robot.rviz file, I accidentally copied the words above it…, so that’s why the view_robot.rviz was playing up,

is there a copy button on the codes section? because everytime I highlight them …, I had to scroll up and down to highlight and I end up copying the instructions words above it as well, …which is kind of annoying,

Please guide,

thanks