Skip to content

Commit edc3bef

Browse files
committed
Made the tutorials package a C++ one
1 parent 740875a commit edc3bef

File tree

4 files changed

+99
-9
lines changed

4 files changed

+99
-9
lines changed

CMakeLists.txt

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(tutorials)
3+
4+
# Default to C99
5+
if(NOT CMAKE_C_STANDARD)
6+
set(CMAKE_C_STANDARD 99)
7+
endif()
8+
9+
# Default to C++14
10+
if(NOT CMAKE_CXX_STANDARD)
11+
set(CMAKE_CXX_STANDARD 14)
12+
endif()
13+
14+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
15+
add_compile_options(-Wall -Wextra -Wpedantic)
16+
endif()
17+
18+
19+
# Find and include all dependencies
20+
find_package(ament_cmake REQUIRED)
21+
find_package(ament_cmake_python REQUIRED)
22+
find_package(rclcpp REQUIRED)
23+
find_package(rclpy REQUIRED)
24+
25+
# Include the core package
26+
find_package(core REQUIRED)
27+
28+
# Include the include directory
29+
include_directories(
30+
include
31+
${catkin_INCLUDE_DIRS}
32+
"${PROJECT_SOURCE_DIR}/include"
33+
)
34+
35+
# C++ executables
36+
#add_executable(#name #source.cpp #dependency.cpp)
37+
#ament_target_dependencies(#name rclcpp core)
38+
39+
# Add all the installation directories
40+
install(DIRECTORY
41+
#launch
42+
DESTINATION share/${PROJECT_NAME}
43+
)
44+
45+
# Add all Python executables to this list
46+
install(PROGRAMS
47+
tutorials/example_publisher.py
48+
tutorials/example_subscriber.py
49+
tutorials/example_client.py
50+
tutorials/example_service.py
51+
DESTINATION lib/${PROJECT_NAME}
52+
)
53+
54+
55+
if(BUILD_TESTING)
56+
find_package(ament_lint_auto REQUIRED)
57+
# the following line skips the linter which checks for copyrights
58+
# uncomment the line when a copyright and license is not present in all source files
59+
#set(ament_cmake_copyright_FOUND TRUE)
60+
# the following line skips cpplint (only works in a git repo)
61+
# uncomment the line when this package is not in a git repo
62+
#set(ament_cmake_cpplint_FOUND TRUE)
63+
ament_lint_auto_find_test_dependencies()
64+
endif()
65+
66+
ament_package()

package.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
<test_depend>ament_pep257</test_depend>
1313
<test_depend>python3-pytest</test_depend>
1414

15-
<exec_depend>core</exec_depend>
16-
<exec_depend>rclpy</exec_depend>
17-
<exec_depend>std_msgs</exec_depend>
18-
<exec_depend>example_interfaces</exec_depend>
15+
<depend>rclcpp</depend>
16+
<depend>core</depend>
17+
<depend>std_msgs</depend>
18+
<depend>example_interfaces</depend>
1919

2020
<export>
21-
<build_type>ament_python</build_type>
21+
<build_type>ament_cmake</build_type>
2222
</export>
2323
</package>

setup.cfg

-4
This file was deleted.

tutorials/test.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python3
2+
3+
import rclpy
4+
from rclpy.node import Node
5+
6+
import coms_utils
7+
8+
9+
class Tester (Node):
10+
11+
def __init__ (self):
12+
super().__init__('node_test')
13+
#self.test_obj = Test()
14+
#print(self.test_obj.get_value(2))
15+
16+
17+
# Main function for setting up the ROS node
18+
def main (args = None):
19+
rclpy.init(args = args)
20+
service = Tester()
21+
rclpy.spin(service)
22+
23+
service.destroy_node()
24+
rclpy.shutdown()
25+
26+
# This code is called when 'python3' is used to run the script
27+
if __name__ == '__main__':
28+
main()

0 commit comments

Comments
 (0)