Using FollowJointTrajectory action message in ROS2 Python Script


I’m trying to import the FollowJointTrajectory action message to use in an action server. I have the following line in my Python script, but on running it, I get the error that the control_msgs.action module cannot be found.
from control_msgs.action import FollowJointTrajectory

Some things I have looked into:
ros2 interface list | grep Follow:
locate control_msgs | grep galactic | grep FollowJointTrajectory shows no .h or .py files:

Any suggestions on how I can fix this? Thank you!

Hello @cjans121,

thanks for posting what you already have tried to do. It is good that you can see the message when you execute the ros2 interface list command.

In addition to what you have already done, I can suggest that you open a Python Interpreter and see if the import works without error messages.

In a Shell run:


then inside the python interpreter run:

from control_msgs.action import FollowJointTrajectory

I did that and it did not show any errors. Like this:

Could you please post here your results?



Hi @rzegers , thanks for your response. Below is the result you requested. It can’t find the module.
Here are some more things that might be useful in this investigation.
Output of which python3:
Output of echo $PYTHONPATH is as follows. base_ws is my ros2 workspace.

First line of my python script:

Result of importing rclpy which imports fine:
Result of locate control_msgs | grep galactic | grep follow is as follows. I notice a py file there. However, it is instead of I’ve tried importing this too but, of course, I get stuck on the control_msgs.action module not being found.

@rzegers, on further investigation, I noticed as I jumped to definition from the control_msgs.action import line, it was taking me to a noetic directory. This mix-up is also evident in the PYTHONPATH variable. Removing the noetic and ROS1 paths from PYTHONPATH, resolved this issue. However, I’ve run into another related problem now. I get the following runtime error regarding the action server initialization when using the FollowJointTrajectory action. However, if I replace FollowJointTrajectory with Fibonacci then, initialization works, i.e. I see the “After initializing arm action server” message printed. Do you have any insights about this?



import sys
import threading

import rclpy
from action_tutorials_interfaces.action import Fibonacci
from control_msgs.action import FollowJointTrajectory
from rclpy.action import ActionServer
from rclpy.node import Node
from sensor_msgs.msg import JointState

from my_package.my_script import \

class FollowJointTrajectory(Node, MyClass):

    def __init__(self, argv):
        Node.__init__(self, "follow_joint_trajectory_node")

        print("Before initializing arm action server")
        self.arm_action_server = ActionServer(
        print("After initializing arm action server")

    def arm_goal_callback(self, goal_handle):
        """Callback for arm_action_server"""
        #Some Code
        return self.arm_result

Hi @cjans121, I am glad that you got your issue solved. I have to admit that I wouldn’t have thought that you had two ROS versions installed on your system.

From the error message that you posted this part here caught my attention:

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 ...

As you see that message is cut on the screenshot I think the key part is missing as this is how that message normally continues:

Make sure to source your ROS 2 workspace after your ROS 1 workspace.

Any chance you could work on a system that only has one version of ROS2 installed? Things can really get messed up, and that way, you could rule out any errors caused by this. Personally, I haven’t worked on systems that have two versions installed, so it’s outside my area of expertise at the moment and I can’t really help you much there. However, if you encounter any issues on a pure ROS2 system, I’d be happy to help you troubleshoot.



Hi @rzegers , unfortunately, I need both ROS and ROS2 in my system at the moment. I appreciate your support so far. I’ll post an update here if I figure anything out.


1 Like

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