Part I Example Attribute Error


I am trying to finish the Part I example in the ROS2 Basics in 5 Days (Python) course and I am running into an error I cannot seem to get around.

I have created my own package called part1_pkg and have created a node called inside of it. I have also set up my launch file in accordance with the course materials where everything seems to work fine.

The problem is when I run my launch file, I get the below error traceback:

user:~/ros2_ws$ ros2 launch part1_pkg
[INFO] [launch]: All log files can be found below /home/user/.ros/log/2021-10-21-23-30-17-982061-2_xterm-28206
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [part1-1]: process started with pid [28385]
[part1-1] Traceback (most recent call last):
[part1-1] File “/home/user/ros2_ws/install/part1_pkg/lib/part1_pkg/part1”, line 33, in
[part1-1] sys.exit(load_entry_point(‘part1-pkg==0.0.0’, ‘console_scripts’, ‘part1’)())
[part1-1] File “/home/user/ros2_ws/install/part1_pkg/lib/python3.8/site-packages/part1_pkg/”, line 45, in main
[part1-1] part1 = Part1()
[part1-1] File “/home/user/ros2_ws/install/part1_pkg/lib/python3.8/site-packages/part1_pkg/”, line 10, in init
[part1-1] self.publisher_ = self.create_publisher(Twist, ‘/cmd_vel’, 10)
[part1-1] File “/opt/ros/foxy/lib/python3.8/site-packages/rclpy/”, line 1140, in create_publisher
[part1-1] check_for_type_support(msg_type)
[part1-1] File “/opt/ros/foxy/lib/python3.8/site-packages/rclpy/”, line 20, in check_for_type_support
[part1-1] ts = msg_type.class._TYPE_SUPPORT
[part1-1] AttributeError: type object ‘type’ has no attribute ‘_TYPE_SUPPORT’ Thismight be a ROS 1 message type but it should be a ROS 2 message type. Make sure to source your ROS 2 workspace after your ROS 1 workspace.
[ERROR] [part1-1]: process has died [pid 28385, exit code 1, cmd ‘/home/user/ros2_ws/install/part1_pkg/lib/part1_pkg/part1 --ros-args’].

After I build my package with colcon and before I run my launch file, I source my environments in the below order:

source /opt/ros/foxy/setup.bash
source ~/ros2_ws/install/setup.bash

Any help will be appreciated, thank you!

I apologize about the quick resolution here but hopefully this will help others that may run into this in the future:

My issue was that in my publisher generation, I typed ‘/cmd_vel’ instead ‘cmd_vel’ for the topic. Changing this and rebuilding fixed my issue.