I am doing the topics project in ROS2 python course. But, the following error happens when I try to subscribe to the /scan or publish in /cmd_vel:
user:~/ros2_ws$ ros2 launch wall_follower start_wall_following.launch.py
[INFO] [launch]: All log files can be found below /home/user/.ros/log/2023-05-09-21-10-12-024513-2_xterm-24267
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [wall_following_node-1]: process started with pid 
[wall_following_node-1] Traceback (most recent call last):
[wall_following_node-1] File “/home/user/ros2_ws/install/wall_follower/lib/wall_follower/wall_following_node”, line 33, in
[wall_following_node-1] sys.exit(load_entry_point(‘wall-follower==0.0.0’, ‘console_scripts’, ‘wall_following_node’)())
[wall_following_node-1] File “/home/user/ros2_ws/install/wall_follower/lib/python3.8/site-packages/wall_follower/wall_following.py”, line 92, in main
[wall_following_node-1] wall_following_node = WallFollowing()
[wall_following_node-1] File “/home/user/ros2_ws/install/wall_follower/lib/python3.8/site-packages/wall_follower/wall_following.py”, line 19, in init
[wall_following_node-1] self.publisher_ = self.create_publisher(Twist, ‘cmd_vel’, 2)
[wall_following_node-1] File “/opt/ros/foxy/lib/python3.8/site-packages/rclpy/node.py”, line 1140, increate_publisher
[wall_following_node-1] File “/opt/ros/foxy/lib/python3.8/site-packages/rclpy/type_support.py”, line 20, in check_for_type_support
[wall_following_node-1] ts = msg_type.class._TYPE_SUPPORT
[wall_following_node-1] AttributeError: type object ‘type’ has no attribute ‘_TYPE_SUPPORT’ This might 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] [wall_following_node-1]: process has died [pid 24318, exit code 1, cmd ‘/home/user/ros2_ws/install/wall_follower/lib/wall_follower/wall_following_node --ros-args’].
The ROS1 is sourced first, then the ROS2. The topics can be viewed using ROS1 and ROS2 command line instructions, but when running the python scripts it does not work.