Attribute error for teleop_twist_keyboard

In “ROS2 basics C++ real robot project” rosject, I get an attribute error whenever I try to run the teleop_twist_keyboard to test the simulation. I’ve run the previous commands as instructed in the notebook. I’ve attached a screenshot of the issue.
I also followed a similar forum topic, but that didn’t help either - ROS2 Basics Real Robot Project part1: problems running keyboard teleop

Any help will be appreciated.

Hi @omkars ,

Welcome to this Community!

The error you got is the most common error that people get when they are new to ROS2.

You just forgot to source ROS2. You sourced your compiled folder but before that, you need to source ROS2.

Try these steps in order:

cd                                        # <--- start from home directory
source /opt/ros/noetic/setup.bash                       # <--- source ROS1
source /opt/ros/foxy/setup.bash                         # <--- source ROS2
cd ~/ros2_ws                            # <--- change directory to ros2_ws
colcon build                          # <--- build your packages if needed
source install/setup.bash                # <--- source your ros2 workspace
ros2 run teleop_twist_keyboard teleop_twist_keyboard  # <--- launch teleop

This should fix your problem.


1 Like

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