ROS Basics in 5 Days (C++) Course Project 1 keyboard_teleop not starting

The rosject environment of the ROS basics c++ course seems to be messed up, the teleop_twist_keyboard does not launch.
I have tried the instruction in the course notebook and the solutions indicated here and here but to no avail.
Might be related to the PYTHONPATH?

ros2 run teleop_twist_keyboard teleop_twist_keyboard
Traceback (most recent call last):
  File "/opt/ros/foxy/lib/teleop_twist_keyboard/teleop_twist_keyboard", line 11, in <module>
    load_entry_point('teleop-twist-keyboard==2.3.2', 'console_scripts', 'teleop_twist_keyboard')()
  File "/opt/ros/foxy/lib/python3.8/site-packages/", line 138, in main
    pub = node.create_publisher(geometry_msgs.msg.Twist, 'cmd_vel', 10)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/", line 1140, in create_publisher
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/", line 20, in check_for_type_support
    ts = msg_type.__class__._TYPE_SUPPORT
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.

There is a note saying

The simulation of Turtlebot3 runs on ROS1, but your programs will run on ROS2. Hence, you will need to launch also the ros1_bridge program to allow communication between them.

while I am clearly starting a ros2 simulation? Maybe I am missing something here, but please clarify the instructions in the notebook.

Thanks a lot!

Hi @tschuette ,

Welcome to this Community!

Yes, you need to have ROS Bridge running in order to communicate with the robot for the teleop movements.
So this is what you do:
First, start (launch) the simulation in a terminal, if you are using a simulation. Otherwise you can skip this step.
Terminal 1: source ROS1, source ROS2, start ROS bridge and leave this terminal running (don’t close).
Terminal 2: start ROS2 version of teleop keyboard, and use this terminal to control the robot.

This should work.


Hi @girishkumar.kannan,
Thank you for your response.
If do exactly what you ask me to do (I’m running the simulation) I get an “Failed to contact master…” error.
Here’s what I do:
Shell 1:

source ~/simulation_ws/install/setup.bash

ros2 launch turtlebot3_gazebo main_turtlebot3_lab.launch.xml

shell 2

source /opt/ros/noetic/setup.bash
source /opt/ros/foxy/setup.bash
ros2 run ros1_bridge dynamic_bridge

and I get

[ERROR] [1690622216.539986841]: [registerPublisher] Failed tocontact master at [2_xterm:11311]. Retrying…

Any ideas? Same happens when I do a rostopic list. However, when I source ROS2 and do a ros2 node list i get the following nodes:

ros2 node list

Any ideas?

Best regards,


For anyone else coming across this:
I checked the python course for change and there the note is correct: The simulation is running in ros2, only the real robot needs the rosbridge.
Also the keyboard_teleop node works, if I don’t source anything in a new terminal. As soon as I source the setup in the ros2_ws/install it does not work anymore. So the instructions in the notebook are wrong here.
The setup seems to first source ROS1 noetic and then ROS2 foxy (I assume for the rosbridge for the real robot) and that seems to mess with the keyboard_teleop node.

So the correct instructions would be:
Shell 1:

source ~/simulation_ws/install/setup.bash

ros2 launch turtlebot3_gazebo main_turtlebot3_lab.launch.xml

Shell 2 (new terminal):

ros2 run teleop_twist_keyboard teleop_twist_keyboard

if you want to test your own code
Shell 3:

source ~/ros2_ws/install/setup.bash

ros2 run your_package your_node

@tschuette Thank you for that feedback. We will review it and use it to improve the project.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.