# Unit 4 : fatal error: geometry\_msgs/Twist: No such file or directory

**URL:** <https://get-help.theconstruct.ai/t/unit-4-fatal-error-geometry-msgs-twist-no-such-file-or-directory/27554>\
**Category:** ROS Basics In 5 Days (C++)\
**Tags:** error, catkin\_make\
**Created:** [November 28, 2023, 3:14pm UTC](https://get-help.theconstruct.ai/t/unit-4-fatal-error-geometry-msgs-twist-no-such-file-or-directory/27554 "2023-11-28T15:14:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![muhammadjunaid](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/muhammadjunaid/32/7140_2.png) [@muhammadjunaid](https://get-help.theconstruct.ai/u/muhammadjunaid)\
**Post date:** [November 28, 2023, 3:14pm UTC](https://get-help.theconstruct.ai/t/unit-4-fatal-error-geometry-msgs-twist-no-such-file-or-directory/27554/1 "2023-11-28T15:14:03Z")

</div>

Hi !

I am studying ROS1 course. I am stuck with this error message when i build with catkin\_make :

fatal error: geometry\_msgs/Twist: No such file or directory  
1 | #include \<geometry\_msgs/Twist\>

 ![image](https://get-help.robotigniteacademy.com/uploads/default/original/2X/9/9d13ff6c976ccdd9e61661ef77dc0730553e4946.png)

I also have included the dependency in package.xml

![image](https://get-help.robotigniteacademy.com/uploads/default/original/2X/d/da9516842fb882de278c36372a8996a6e364d146.png)

also i have added the required lines in Cmakelists :

```auto
find_package(catkin REQUIRED COMPONENTS
  roscpp
  std_msgs
  geometry_msgs
)

catkin_package(
# INCLUDE_DIRS include
# LIBRARIES topic_publisher_pkg
# CATKIN_DEPENDS roscpp std_msgs
# DEPENDS system_lib
   CATKIN_DEPENDS roscpp std_msgs geometry_msgs
)
include_directories(
# include
  ${catkin_INCLUDE_DIRS}
)

add_executable(simple_topic_publisher src/simple_topic_publisher.cpp)
add_executable(publisher_1 src/publisher_1.cpp)

add_dependencies(simple_topic_publisher ${simple_topic_publisher_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
add_dependencies(publisher_1 ${publisher_1_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

target_link_libraries(simple_topic_publisher
  ${catkin_LIBRARIES}
)
target_link_libraries(publisher_1
  ${catkin_LIBRARIES}
)

```

I also have confirmed that geometry\_msgs is in the system path

here is my code :

```auto
#include <geometry_msgs/Twist>
#include <ros/ros.h>
#include <std_msgs/float64.h>
// Import all the necessary ROS libraries and import the Int32 message from the
// std_msgs package

int main(int argc, char **argv) {

  ros::init(
      argc, argv,
      "velocity_publisher_node"); // Initiate a Node named 'topic_publisher'
  ros::NodeHandle nh;

  ros::Publisher pub = nh.advertise<geometry_msgs::Twist>(
      "cmd_vel", 1000); // Create a Publisher object, that will // publish on
                          // the /counter topic messages of type float64
  ros::Rate loop_rate(2); // Set a publish rate of 2 Hz

  geometry_msgs::Twist velocity; // Create a variable of type Int32
  velocity.linear.x = 0.5; // Initialize 'velocity' variable
  velocity.angular.z = 0;

  while (ros::ok()) // Create a loop that will go until someone stops the
                    // program execution
  {
    pub.publish(velocity); // Publish the message within the 'count' variable
    ros::spinOnce();
    loop_rate.sleep(); // Make sure the publish rate maintains at 2 Hz
  }

  return 0;
}

```

Can anyone please guide me 🙂

Best ,  
Muhammad

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [November 29, 2023, 9:39am UTC](https://get-help.theconstruct.ai/t/unit-4-fatal-error-geometry-msgs-twist-no-such-file-or-directory/27554/2 "2023-11-29T09:39:23Z")

</div>

There’s a typo in your include. It should be:

```auto
#include <geometry_msgs/Twist.h>

```

The `.h` part was missing.

---

<div class="post-metadata">

**Author:** ![system](https://get-help.theconstruct.ai/uploads/default/original/2X/9/9d3ce8305cc0d0d9b6e07d15767a6f245c526f1b.jpeg) [@system](https://get-help.theconstruct.ai/u/system)\
**Post date:** [December 4, 2023, 9:39am UTC](https://get-help.theconstruct.ai/t/unit-4-fatal-error-geometry-msgs-twist-no-such-file-or-directory/27554/3 "2023-12-04T09:39:39Z")

</div>

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