├── .gitignore
├── README.md
├── create_package_generated
└── catkin_ws
│ └── src
│ ├── CMakeLists.txt
│ └── beginner_tutorials
│ ├── CMakeLists.txt
│ └── package.xml
├── create_package_modified
└── catkin_ws
│ └── src
│ ├── CMakeLists.txt
│ └── beginner_tutorials
│ ├── CMakeLists.txt
│ └── package.xml
├── create_package_pubsub
└── catkin_ws
│ └── src
│ ├── CMakeLists.txt
│ └── beginner_tutorials
│ ├── CMakeLists.txt
│ ├── msg
│ └── Num.msg
│ ├── package.xml
│ ├── src
│ ├── listener.cpp
│ └── talker.cpp
│ └── srv
│ └── AddTwoInts.srv
└── create_package_srvclient
└── catkin_ws
└── src
├── CMakeLists.txt
└── beginner_tutorials
├── CMakeLists.txt
├── msg
└── Num.msg
├── package.xml
├── src
├── add_two_ints_client.cpp
├── add_two_ints_server.cpp
├── listener.cpp
└── talker.cpp
└── srv
└── AddTwoInts.srv
/.gitignore:
--------------------------------------------------------------------------------
1 | build
2 | devel
3 | install
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros/catkin_tutorials/8628128c4d12d20c0bc50ee758c8433e49ba9307/README.md
--------------------------------------------------------------------------------
/create_package_generated/catkin_ws/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # toplevel CMakeLists.txt for a catkin workspace
2 | # catkin/cmake/toplevel.cmake
3 |
4 | cmake_minimum_required(VERSION 2.8.3)
5 |
6 | # optionally provide a cmake file in the workspace to override arbitrary stuff
7 | include(workspace.cmake OPTIONAL)
8 |
9 | set(CATKIN_TOPLEVEL TRUE)
10 |
11 | # include catkin directly or via find_package()
12 | if(EXISTS "${CMAKE_SOURCE_DIR}/catkin/cmake/all.cmake" AND EXISTS "${CMAKE_SOURCE_DIR}/catkin/CMakeLists.txt")
13 | set(catkin_EXTRAS_DIR "${CMAKE_SOURCE_DIR}/catkin/cmake")
14 | # include all.cmake without add_subdirectory to let it operate in same scope
15 | include(catkin/cmake/all.cmake NO_POLICY_SCOPE)
16 | add_subdirectory(catkin)
17 |
18 | else()
19 | # use either CMAKE_PREFIX_PATH explicitly passed to CMake as a command line argument
20 | # or CMAKE_PREFIX_PATH from the environment
21 | if(NOT DEFINED CMAKE_PREFIX_PATH)
22 | if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")
23 | string(REPLACE ":" ";" CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
24 | endif()
25 | endif()
26 |
27 | # list of catkin workspaces
28 | set(catkin_search_path "")
29 | foreach(path ${CMAKE_PREFIX_PATH})
30 | if(EXISTS "${path}/.CATKIN_WORKSPACE")
31 | list(FIND catkin_search_path ${path} _index)
32 | if(_index EQUAL -1)
33 | list(APPEND catkin_search_path ${path})
34 | endif()
35 | endif()
36 | endforeach()
37 |
38 | # search for catkin in all workspaces
39 | set(CATKIN_TOPLEVEL_FIND_PACKAGE TRUE)
40 | find_package(catkin REQUIRED
41 | NO_POLICY_SCOPE
42 | PATHS ${catkin_search_path}
43 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
44 | unset(CATKIN_TOPLEVEL_FIND_PACKAGE)
45 | endif()
46 |
47 | catkin_workspace()
48 |
--------------------------------------------------------------------------------
/create_package_generated/catkin_ws/src/beginner_tutorials/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # %Tag(FULLTEXT)%
2 | cmake_minimum_required(VERSION 2.8.3)
3 | project(beginner_tutorials)
4 |
5 | ## Find catkin macros and libraries
6 | ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
7 | ## is used, also find other catkin packages
8 | find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs)
9 |
10 | ## System dependencies are found with CMake's conventions
11 | # find_package(Boost REQUIRED COMPONENTS system)
12 |
13 | ## Uncomment this if the package has a setup.py. This macro ensures
14 | ## modules and scripts declared therein get installed
15 | ## See http://ros.org/doc/groovy/api/catkin/html/user_guide/setup_dot_py.html
16 | # catkin_python_setup()
17 |
18 | #######################################
19 | ## Declare ROS messages and services ##
20 | #######################################
21 |
22 | ## Generate messages in the 'msg' folder
23 | # add_message_files(
24 | # FILES
25 | # Message1.msg
26 | # Message2.msg
27 | # )
28 |
29 | ## Generate services in the 'srv' folder
30 | # add_service_files(
31 | # FILES
32 | # Service1.srv
33 | # Service2.srv
34 | # )
35 |
36 | ## Generate added messages and services with any dependencies listed here
37 | # generate_messages(
38 | # DEPENDENCIES
39 | # std_msgs
40 | # )
41 |
42 | ###################################################
43 | ## Declare things to be passed to other projects ##
44 | ###################################################
45 |
46 | ## LIBRARIES: libraries you create in this project that dependent projects also need
47 | ## CATKIN_DEPENDS: catkin_packages dependent projects also need
48 | ## DEPENDS: system dependencies of this project that dependent projects also need
49 | catkin_package(
50 | INCLUDE_DIRS include
51 | # LIBRARIES beginner_tutorials
52 | # CATKIN_DEPENDS roscpp rospy std_msgs
53 | # DEPENDS system_lib
54 | )
55 |
56 | ###########
57 | ## Build ##
58 | ###########
59 |
60 | ## Specify additional locations of header files
61 | ## Your package locations should be listed before other locations
62 | include_directories(include
63 | ${catkin_INCLUDE_DIRS}
64 | )
65 |
66 | ## Declare a cpp library
67 | # add_library(beginner_tutorials
68 | # src/${PROJECT_NAME}/beginner_tutorials.cpp
69 | # )
70 |
71 | ## Declare a cpp executable
72 | # add_executable(beginner_tutorials_node src/beginner_tutorials_node.cpp)
73 |
74 | ## Add dependencies to the executable
75 | # add_dependencies(beginner_tutorials_node ${PROJECT_NAME})
76 |
77 | ## Specify libraries to link a library or executable target against
78 | # target_link_libraries(beginner_tutorials_node
79 | # ${catkin_LIBRARIES}
80 | # )
81 |
82 | #############
83 | ## Install ##
84 | #############
85 |
86 | # all install targets should use catkin DESTINATION variables
87 | # See http://ros.org/doc/groovy/api/catkin/html/adv_user_guide/variables.html
88 |
89 | ## Mark executable scripts (Python etc.) for installation
90 | ## in contrast to setup.py, you can choose the destination
91 | # install(PROGRAMS
92 | # scripts/my_python_script
93 | # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
94 | # )
95 |
96 | ## Mark executables and/or libraries for installation
97 | # install(TARGETS beginner_tutorials beginner_tutorials_node
98 | # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
99 | # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
100 | # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
101 | # )
102 |
103 | ## Mark cpp header files for installation
104 | # install(DIRECTORY include/${PROJECT_NAME}/
105 | # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
106 | # FILES_MATCHING PATTERN "*.h"
107 | # PATTERN ".svn" EXCLUDE
108 | # )
109 |
110 | ## Mark other files for installation (e.g. launch and bag files, etc.)
111 | # install(FILES
112 | # # myfile1
113 | # # myfile2
114 | # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
115 | # )
116 |
117 | #############
118 | ## Testing ##
119 | #############
120 |
121 | ## Add gtest based cpp test target and link libraries
122 | # catkin_add_gtest(${PROJECT_NAME}-test test/test_beginner_tutorials.cpp)
123 | # if(TARGET ${PROJECT_NAME}-test)
124 | # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
125 | # endif()
126 |
127 | ## Add folders to be run by python nosetests
128 | # catkin_add_nosetests(test)
129 |
130 |
131 | # %EndTag(FULLTEXT)%
--------------------------------------------------------------------------------
/create_package_generated/catkin_ws/src/beginner_tutorials/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beginner_tutorials
6 |
7 |
8 | 0.0.0
9 |
10 |
11 | The beginner_tutorials package
12 |
13 |
14 |
15 |
16 |
17 |
18 | user
19 |
20 |
21 |
22 |
23 |
24 |
25 | TODO
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | catkin
55 | roscpp
56 | rospy
57 | std_msgs
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/create_package_modified/catkin_ws/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # toplevel CMakeLists.txt for a catkin workspace
2 | # catkin/cmake/toplevel.cmake
3 |
4 | cmake_minimum_required(VERSION 2.8.3)
5 |
6 | # optionally provide a cmake file in the workspace to override arbitrary stuff
7 | include(workspace.cmake OPTIONAL)
8 |
9 | set(CATKIN_TOPLEVEL TRUE)
10 |
11 | # include catkin directly or via find_package()
12 | if(EXISTS "${CMAKE_SOURCE_DIR}/catkin/cmake/all.cmake" AND EXISTS "${CMAKE_SOURCE_DIR}/catkin/CMakeLists.txt")
13 | set(catkin_EXTRAS_DIR "${CMAKE_SOURCE_DIR}/catkin/cmake")
14 | # include all.cmake without add_subdirectory to let it operate in same scope
15 | include(catkin/cmake/all.cmake NO_POLICY_SCOPE)
16 | add_subdirectory(catkin)
17 |
18 | else()
19 | # use either CMAKE_PREFIX_PATH explicitly passed to CMake as a command line argument
20 | # or CMAKE_PREFIX_PATH from the environment
21 | if(NOT DEFINED CMAKE_PREFIX_PATH)
22 | if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")
23 | string(REPLACE ":" ";" CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
24 | endif()
25 | endif()
26 |
27 | # list of catkin workspaces
28 | set(catkin_search_path "")
29 | foreach(path ${CMAKE_PREFIX_PATH})
30 | if(EXISTS "${path}/.CATKIN_WORKSPACE")
31 | list(FIND catkin_search_path ${path} _index)
32 | if(_index EQUAL -1)
33 | list(APPEND catkin_search_path ${path})
34 | endif()
35 | endif()
36 | endforeach()
37 |
38 | # search for catkin in all workspaces
39 | set(CATKIN_TOPLEVEL_FIND_PACKAGE TRUE)
40 | find_package(catkin REQUIRED
41 | NO_POLICY_SCOPE
42 | PATHS ${catkin_search_path}
43 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
44 | unset(CATKIN_TOPLEVEL_FIND_PACKAGE)
45 | endif()
46 |
47 | catkin_workspace()
48 |
--------------------------------------------------------------------------------
/create_package_modified/catkin_ws/src/beginner_tutorials/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # %Tag(FULLTEXT)%
2 | cmake_minimum_required(VERSION 2.8.3)
3 | project(beginner_tutorials)
4 |
5 | ## Find catkin and any catkin packages
6 | find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs genmsg)
7 |
8 | ## Declare ROS messages and services
9 | add_message_files(DIRECTORY msg FILES Num.msg)
10 | add_service_files(DIRECTORY srv FILES AddTwoInts.srv)
11 |
12 | ## Generate added messages and services
13 | generate_messages(DEPENDENCIES std_msgs)
14 |
15 | ## Declare a catkin package
16 | catkin_package()
17 |
18 | # %EndTag(FULLTEXT)%
--------------------------------------------------------------------------------
/create_package_modified/catkin_ws/src/beginner_tutorials/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beginner_tutorials
6 |
7 |
8 | 0.1.0
9 |
10 |
11 | The beginner_tutorials package
12 |
13 |
14 |
15 | Your Name
16 |
17 |
18 | BSD
19 |
20 |
21 | http://wiki.ros.org/beginner_tutorials
22 |
23 |
24 | Jane Doe
25 |
26 |
27 |
28 | catkin
29 |
30 | roscpp
31 | rospy
32 | std_msgs
33 |
34 | roscpp
35 | rospy
36 | std_msgs
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/create_package_pubsub/catkin_ws/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # toplevel CMakeLists.txt for a catkin workspace
2 | # catkin/cmake/toplevel.cmake
3 |
4 | cmake_minimum_required(VERSION 2.8.3)
5 |
6 | # optionally provide a cmake file in the workspace to override arbitrary stuff
7 | include(workspace.cmake OPTIONAL)
8 |
9 | set(CATKIN_TOPLEVEL TRUE)
10 |
11 | # include catkin directly or via find_package()
12 | if(EXISTS "${CMAKE_SOURCE_DIR}/catkin/cmake/all.cmake" AND EXISTS "${CMAKE_SOURCE_DIR}/catkin/CMakeLists.txt")
13 | set(catkin_EXTRAS_DIR "${CMAKE_SOURCE_DIR}/catkin/cmake")
14 | # include all.cmake without add_subdirectory to let it operate in same scope
15 | include(catkin/cmake/all.cmake NO_POLICY_SCOPE)
16 | add_subdirectory(catkin)
17 |
18 | else()
19 | # use either CMAKE_PREFIX_PATH explicitly passed to CMake as a command line argument
20 | # or CMAKE_PREFIX_PATH from the environment
21 | if(NOT DEFINED CMAKE_PREFIX_PATH)
22 | if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")
23 | string(REPLACE ":" ";" CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
24 | endif()
25 | endif()
26 |
27 | # list of catkin workspaces
28 | set(catkin_search_path "")
29 | foreach(path ${CMAKE_PREFIX_PATH})
30 | if(EXISTS "${path}/.CATKIN_WORKSPACE")
31 | list(FIND catkin_search_path ${path} _index)
32 | if(_index EQUAL -1)
33 | list(APPEND catkin_search_path ${path})
34 | endif()
35 | endif()
36 | endforeach()
37 |
38 | # search for catkin in all workspaces
39 | set(CATKIN_TOPLEVEL_FIND_PACKAGE TRUE)
40 | find_package(catkin REQUIRED
41 | NO_POLICY_SCOPE
42 | PATHS ${catkin_search_path}
43 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
44 | unset(CATKIN_TOPLEVEL_FIND_PACKAGE)
45 | endif()
46 |
47 | catkin_workspace()
48 |
--------------------------------------------------------------------------------
/create_package_pubsub/catkin_ws/src/beginner_tutorials/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # %Tag(FULLTEXT)%
2 | cmake_minimum_required(VERSION 2.8.3)
3 | project(beginner_tutorials)
4 |
5 | ## Find catkin and any catkin packages
6 | find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs genmsg)
7 |
8 | ## Declare ROS messages and services
9 | add_message_files(FILES Num.msg)
10 | add_service_files(FILES AddTwoInts.srv)
11 |
12 | ## Generate added messages and services
13 | generate_messages(DEPENDENCIES std_msgs)
14 |
15 | ## Declare a catkin package
16 | catkin_package()
17 |
18 | ## Build talker and listener
19 | include_directories(include ${catkin_INCLUDE_DIRS})
20 |
21 | add_executable(talker src/talker.cpp)
22 | target_link_libraries(talker ${catkin_LIBRARIES})
23 | add_dependencies(talker beginner_tutorials_generate_messages_cpp)
24 |
25 | add_executable(listener src/listener.cpp)
26 | target_link_libraries(listener ${catkin_LIBRARIES})
27 | add_dependencies(listener beginner_tutorials_generate_messages_cpp)
28 |
29 | # %EndTag(FULLTEXT)%
30 |
--------------------------------------------------------------------------------
/create_package_pubsub/catkin_ws/src/beginner_tutorials/msg/Num.msg:
--------------------------------------------------------------------------------
1 | int64 num
2 |
--------------------------------------------------------------------------------
/create_package_pubsub/catkin_ws/src/beginner_tutorials/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beginner_tutorials
6 |
7 |
8 | 0.1.0
9 |
10 |
11 | The beginner_tutorials package
12 |
13 |
14 |
15 | Your Name
16 |
17 |
18 | BSD
19 |
20 |
21 | http://wiki.ros.org/beginner_tutorials
22 |
23 |
24 | Jane Doe
25 |
26 |
27 |
28 | catkin
29 |
30 | roscpp
31 | rospy
32 | std_msgs
33 |
34 | roscpp
35 | rospy
36 | std_msgs
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/create_package_pubsub/catkin_ws/src/beginner_tutorials/src/listener.cpp:
--------------------------------------------------------------------------------
1 | #include "ros/ros.h"
2 | #include "std_msgs/String.h"
3 |
4 | /**
5 | * This tutorial demonstrates simple receipt of messages over the ROS system.
6 | */
7 | void chatterCallback(const std_msgs::String::ConstPtr& msg)
8 | {
9 | ROS_INFO("I heard: [%s]", msg->data.c_str());
10 | }
11 |
12 | int main(int argc, char **argv)
13 | {
14 | /**
15 | * The ros::init() function needs to see argc and argv so that it can
16 | * perform any ROS arguments and name remapping that were provided
17 | * at the command line. For programmatic remappings you can use a
18 | * different version of init() which takes remappings directly, but
19 | * for most command-line programs, passing argc and argv is the easiest
20 | * way to do it. The third argument to init() is the name of the node.
21 | *
22 | * You must call one of the versions of ros::init() before using any other
23 | * part of the ROS system.
24 | */
25 | ros::init(argc, argv, "listener");
26 |
27 | /**
28 | * NodeHandle is the main access point to communications with the
29 | * ROS system. The first NodeHandle constructed will fully initialize
30 | * this node, and the last NodeHandle destructed will close down the node.
31 | */
32 | ros::NodeHandle n;
33 |
34 | /**
35 | * The subscribe() call is how you tell ROS that you want to receive
36 | * messages on a given topic. This invokes a call to the ROS master
37 | * node, which keeps a registry of who is publishing and who is subscribing.
38 | * Messages are passed to a callback function, here called chatterCallback.
39 | * subscribe() returns a Subscriber object that you must hold on to
40 | * until you want to unsubscribe. When all copies of the Subscriber
41 | * object go out of scope, this callback will automatically be
42 | * unsubscribed from this topic.
43 | *
44 | * The second parameter to the subscribe() function is the size of
45 | * the message queue. If messages are arriving faster than they are
46 | * being processed, this is the number of messages that will be
47 | * buffered up before beginning to throw away the oldest ones.
48 | */
49 | ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);
50 |
51 | /**
52 | * ros::spin() will enter a loop, pumping callbacks. With this
53 | * version, all callbacks will be called from within this thread
54 | * (the main one). ros::spin() will exit when Ctrl-C is pressed,
55 | * or the node is shutdown by the master.
56 | */
57 | ros::spin();
58 |
59 | return 0;
60 | }
61 |
--------------------------------------------------------------------------------
/create_package_pubsub/catkin_ws/src/beginner_tutorials/src/talker.cpp:
--------------------------------------------------------------------------------
1 | #include "ros/ros.h"
2 | #include "std_msgs/String.h"
3 |
4 | #include
5 |
6 | /**
7 | * This tutorial demonstrates simple sending of messages over the ROS system.
8 | */
9 | int main(int argc, char **argv)
10 | {
11 | /**
12 | * The ros::init() function needs to see argc and argv so that it can
13 | * perform any ROS arguments and name remapping that were provided at
14 | * the command line. For programmatic remappings you can use a
15 | * different version of init() which takes remappings directly, but
16 | * for most command-line programs, passing argc and argv is the easiest
17 | * way to do it. The third argument to init() is the name of the node.
18 | *
19 | * You must call one of the versions of ros::init() before using any
20 | * other part of the ROS system.
21 | */
22 | ros::init(argc, argv, "talker");
23 |
24 | /**
25 | * NodeHandle is the main access point to communications with the
26 | * ROS system. The first NodeHandle constructed will fully initialize
27 | * this node, and the last NodeHandle destructed will close down
28 | * the node.
29 | */
30 | ros::NodeHandle n;
31 |
32 | /**
33 | * The advertise() function is how you tell ROS that you want to
34 | * publish on a given topic name. This invokes a call to the ROS
35 | * master node, which keeps a registry of who is publishing and who
36 | * is subscribing. After this advertise() call is made, the master
37 | * node will notify anyone who is trying to subscribe to this topic name,
38 | * and they will in turn negotiate a peer-to-peer connection with this
39 | * node. advertise() returns a Publisher object which allows you to
40 | * publish messages on that topic through a call to publish(). Once
41 | * all copies of the returned Publisher object are destroyed, the topic
42 | * will be automatically unadvertised.
43 | *
44 | * The second parameter to advertise() is the size of the message queue
45 | * used for publishing messages. If messages are published more quickly
46 | * than we can send them, the number here specifies how many messages to
47 | * buffer up before throwing some away.
48 | */
49 | ros::Publisher chatter_pub = n.advertise("chatter", 1000);
50 |
51 | ros::Rate loop_rate(10);
52 |
53 | /**
54 | * A count of how many messages we have sent. This is used to create
55 | * a unique string for each message.
56 | */
57 | int count = 0;
58 | while (ros::ok())
59 | {
60 | /**
61 | * This is a message object. You stuff it with data, and then publish it.
62 | */
63 | std_msgs::String msg;
64 |
65 | std::stringstream ss;
66 | ss << "hello world " << count;
67 | msg.data = ss.str();
68 |
69 | ROS_INFO("%s", msg.data.c_str());
70 |
71 | /**
72 | * The publish() function is how you send messages. The parameter
73 | * is the message object. The type of this object must agree with the type
74 | * given as a template parameter to the advertise<>() call, as was done
75 | * in the constructor above.
76 | */
77 | chatter_pub.publish(msg);
78 |
79 | ros::spinOnce();
80 |
81 | loop_rate.sleep();
82 | ++count;
83 | }
84 |
85 |
86 | return 0;
87 | }
88 |
--------------------------------------------------------------------------------
/create_package_pubsub/catkin_ws/src/beginner_tutorials/srv/AddTwoInts.srv:
--------------------------------------------------------------------------------
1 | int64 a
2 | int64 b
3 | ---
4 | int64 sum
5 |
--------------------------------------------------------------------------------
/create_package_srvclient/catkin_ws/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # toplevel CMakeLists.txt for a catkin workspace
2 | # catkin/cmake/toplevel.cmake
3 |
4 | cmake_minimum_required(VERSION 2.8.3)
5 |
6 | # optionally provide a cmake file in the workspace to override arbitrary stuff
7 | include(workspace.cmake OPTIONAL)
8 |
9 | set(CATKIN_TOPLEVEL TRUE)
10 |
11 | # include catkin directly or via find_package()
12 | if(EXISTS "${CMAKE_SOURCE_DIR}/catkin/cmake/all.cmake" AND EXISTS "${CMAKE_SOURCE_DIR}/catkin/CMakeLists.txt")
13 | set(catkin_EXTRAS_DIR "${CMAKE_SOURCE_DIR}/catkin/cmake")
14 | # include all.cmake without add_subdirectory to let it operate in same scope
15 | include(catkin/cmake/all.cmake NO_POLICY_SCOPE)
16 | add_subdirectory(catkin)
17 |
18 | else()
19 | # use either CMAKE_PREFIX_PATH explicitly passed to CMake as a command line argument
20 | # or CMAKE_PREFIX_PATH from the environment
21 | if(NOT DEFINED CMAKE_PREFIX_PATH)
22 | if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")
23 | string(REPLACE ":" ";" CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
24 | endif()
25 | endif()
26 |
27 | # list of catkin workspaces
28 | set(catkin_search_path "")
29 | foreach(path ${CMAKE_PREFIX_PATH})
30 | if(EXISTS "${path}/.CATKIN_WORKSPACE")
31 | list(FIND catkin_search_path ${path} _index)
32 | if(_index EQUAL -1)
33 | list(APPEND catkin_search_path ${path})
34 | endif()
35 | endif()
36 | endforeach()
37 |
38 | # search for catkin in all workspaces
39 | set(CATKIN_TOPLEVEL_FIND_PACKAGE TRUE)
40 | find_package(catkin REQUIRED
41 | NO_POLICY_SCOPE
42 | PATHS ${catkin_search_path}
43 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
44 | unset(CATKIN_TOPLEVEL_FIND_PACKAGE)
45 | endif()
46 |
47 | catkin_workspace()
48 |
--------------------------------------------------------------------------------
/create_package_srvclient/catkin_ws/src/beginner_tutorials/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # %Tag(FULLTEXT)%
2 | cmake_minimum_required(VERSION 2.8.3)
3 | project(beginner_tutorials)
4 |
5 | ## Find catkin and any catkin packages
6 | find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs genmsg)
7 |
8 | ## Declare ROS messages and services
9 | add_message_files(FILES Num.msg)
10 | add_service_files(FILES AddTwoInts.srv)
11 |
12 | ## Generate added messages and services
13 | generate_messages(DEPENDENCIES std_msgs)
14 |
15 | ## Declare a catkin package
16 | catkin_package()
17 |
18 | ## Build talker and listener
19 | include_directories(include ${catkin_INCLUDE_DIRS})
20 |
21 | add_executable(talker src/talker.cpp)
22 | target_link_libraries(talker ${catkin_LIBRARIES})
23 |
24 | add_executable(listener src/listener.cpp)
25 | target_link_libraries(listener ${catkin_LIBRARIES})
26 |
27 | ## Build service client and server
28 | # %Tag(SRVCLIENT)%
29 | add_executable(add_two_ints_server src/add_two_ints_server.cpp)
30 | target_link_libraries(add_two_ints_server ${catkin_LIBRARIES})
31 | add_dependencies(add_two_ints_server beginner_tutorials_gencpp)
32 |
33 | add_executable(add_two_ints_client src/add_two_ints_client.cpp)
34 | target_link_libraries(add_two_ints_client ${catkin_LIBRARIES})
35 | add_dependencies(add_two_ints_client beginner_tutorials_gencpp)
36 |
37 | # %EndTag(SRVCLIENT)%
38 |
39 | # %EndTag(FULLTEXT)%
--------------------------------------------------------------------------------
/create_package_srvclient/catkin_ws/src/beginner_tutorials/msg/Num.msg:
--------------------------------------------------------------------------------
1 | int64 num
2 |
--------------------------------------------------------------------------------
/create_package_srvclient/catkin_ws/src/beginner_tutorials/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beginner_tutorials
6 |
7 |
8 | 0.1.0
9 |
10 |
11 | The beginner_tutorials package
12 |
13 |
14 |
15 | Your Name
16 |
17 |
18 | BSD
19 |
20 |
21 | http://wiki.ros.org/beginner_tutorials
22 |
23 |
24 | Jane Doe
25 |
26 |
27 |
28 | catkin
29 |
30 | roscpp
31 | rospy
32 | std_msgs
33 |
34 | roscpp
35 | rospy
36 | std_msgs
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/create_package_srvclient/catkin_ws/src/beginner_tutorials/src/add_two_ints_client.cpp:
--------------------------------------------------------------------------------
1 | #include "ros/ros.h"
2 | #include "beginner_tutorials/AddTwoInts.h"
3 | #include
4 |
5 | int main(int argc, char **argv)
6 | {
7 | ros::init(argc, argv, "add_two_ints_client");
8 | if (argc != 3)
9 | {
10 | ROS_INFO("usage: add_two_ints_client X Y");
11 | return 1;
12 | }
13 |
14 | ros::NodeHandle n;
15 | ros::ServiceClient client = n.serviceClient("add_two_ints");
16 | beginner_tutorials::AddTwoInts srv;
17 | srv.request.a = atoll(argv[1]);
18 | srv.request.b = atoll(argv[2]);
19 | if (client.call(srv))
20 | {
21 | ROS_INFO("Sum: %ld", (long int)srv.response.sum);
22 | }
23 | else
24 | {
25 | ROS_ERROR("Failed to call service add_two_ints");
26 | return 1;
27 | }
28 |
29 | return 0;
30 | }
31 |
--------------------------------------------------------------------------------
/create_package_srvclient/catkin_ws/src/beginner_tutorials/src/add_two_ints_server.cpp:
--------------------------------------------------------------------------------
1 | #include "ros/ros.h"
2 | #include "beginner_tutorials/AddTwoInts.h"
3 |
4 | bool add(beginner_tutorials::AddTwoInts::Request &req,
5 | beginner_tutorials::AddTwoInts::Response &res)
6 | {
7 | res.sum = req.a + req.b;
8 | ROS_INFO("request: x=%ld, y=%ld", (long int)req.a, (long int)req.b);
9 | ROS_INFO("sending back response: [%ld]", (long int)res.sum);
10 | return true;
11 | }
12 |
13 | int main(int argc, char **argv)
14 | {
15 | ros::init(argc, argv, "add_two_ints_server");
16 | ros::NodeHandle n;
17 |
18 | ros::ServiceServer service = n.advertiseService("add_two_ints", add);
19 | ROS_INFO("Ready to add two ints.");
20 | ros::spin();
21 |
22 | return 0;
23 | }
24 |
--------------------------------------------------------------------------------
/create_package_srvclient/catkin_ws/src/beginner_tutorials/src/listener.cpp:
--------------------------------------------------------------------------------
1 | #include "ros/ros.h"
2 | #include "std_msgs/String.h"
3 |
4 | /**
5 | * This tutorial demonstrates simple receipt of messages over the ROS system.
6 | */
7 | void chatterCallback(const std_msgs::String::ConstPtr& msg)
8 | {
9 | ROS_INFO("I heard: [%s]", msg->data.c_str());
10 | }
11 |
12 | int main(int argc, char **argv)
13 | {
14 | /**
15 | * The ros::init() function needs to see argc and argv so that it can
16 | * perform any ROS arguments and name remapping that were provided
17 | * at the command line. For programmatic remappings you can use a
18 | * different version of init() which takes remappings directly, but
19 | * for most command-line programs, passing argc and argv is the easiest
20 | * way to do it. The third argument to init() is the name of the node.
21 | *
22 | * You must call one of the versions of ros::init() before using any other
23 | * part of the ROS system.
24 | */
25 | ros::init(argc, argv, "listener");
26 |
27 | /**
28 | * NodeHandle is the main access point to communications with the
29 | * ROS system. The first NodeHandle constructed will fully initialize
30 | * this node, and the last NodeHandle destructed will close down the node.
31 | */
32 | ros::NodeHandle n;
33 |
34 | /**
35 | * The subscribe() call is how you tell ROS that you want to receive
36 | * messages on a given topic. This invokes a call to the ROS master
37 | * node, which keeps a registry of who is publishing and who is subscribing.
38 | * Messages are passed to a callback function, here called chatterCallback.
39 | * subscribe() returns a Subscriber object that you must hold on to
40 | * until you want to unsubscribe. When all copies of the Subscriber
41 | * object go out of scope, this callback will automatically be
42 | * unsubscribed from this topic.
43 | *
44 | * The second parameter to the subscribe() function is the size of
45 | * the message queue. If messages are arriving faster than they are
46 | * being processed, this is the number of messages that will be
47 | * buffered up before beginning to throw away the oldest ones.
48 | */
49 | ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);
50 |
51 | /**
52 | * ros::spin() will enter a loop, pumping callbacks. With this
53 | * version, all callbacks will be called from within this thread
54 | * (the main one). ros::spin() will exit when Ctrl-C is pressed,
55 | * or the node is shutdown by the master.
56 | */
57 | ros::spin();
58 |
59 | return 0;
60 | }
61 |
--------------------------------------------------------------------------------
/create_package_srvclient/catkin_ws/src/beginner_tutorials/src/talker.cpp:
--------------------------------------------------------------------------------
1 | #include "ros/ros.h"
2 | #include "std_msgs/String.h"
3 |
4 | #include
5 |
6 | /**
7 | * This tutorial demonstrates simple sending of messages over the ROS system.
8 | */
9 | int main(int argc, char **argv)
10 | {
11 | /**
12 | * The ros::init() function needs to see argc and argv so that it can
13 | * perform any ROS arguments and name remapping that were provided at
14 | * the command line. For programmatic remappings you can use a
15 | * different version of init() which takes remappings directly, but
16 | * for most command-line programs, passing argc and argv is the easiest
17 | * way to do it. The third argument to init() is the name of the node.
18 | *
19 | * You must call one of the versions of ros::init() before using any
20 | * other part of the ROS system.
21 | */
22 | ros::init(argc, argv, "talker");
23 |
24 | /**
25 | * NodeHandle is the main access point to communications with the
26 | * ROS system. The first NodeHandle constructed will fully initialize
27 | * this node, and the last NodeHandle destructed will close down
28 | * the node.
29 | */
30 | ros::NodeHandle n;
31 |
32 | /**
33 | * The advertise() function is how you tell ROS that you want to
34 | * publish on a given topic name. This invokes a call to the ROS
35 | * master node, which keeps a registry of who is publishing and who
36 | * is subscribing. After this advertise() call is made, the master
37 | * node will notify anyone who is trying to subscribe to this topic name,
38 | * and they will in turn negotiate a peer-to-peer connection with this
39 | * node. advertise() returns a Publisher object which allows you to
40 | * publish messages on that topic through a call to publish(). Once
41 | * all copies of the returned Publisher object are destroyed, the topic
42 | * will be automatically unadvertised.
43 | *
44 | * The second parameter to advertise() is the size of the message queue
45 | * used for publishing messages. If messages are published more quickly
46 | * than we can send them, the number here specifies how many messages to
47 | * buffer up before throwing some away.
48 | */
49 | ros::Publisher chatter_pub = n.advertise("chatter", 1000);
50 |
51 | ros::Rate loop_rate(10);
52 |
53 | /**
54 | * A count of how many messages we have sent. This is used to create
55 | * a unique string for each message.
56 | */
57 | int count = 0;
58 | while (ros::ok())
59 | {
60 | /**
61 | * This is a message object. You stuff it with data, and then publish it.
62 | */
63 | std_msgs::String msg;
64 |
65 | std::stringstream ss;
66 | ss << "hello world " << count;
67 | msg.data = ss.str();
68 |
69 | ROS_INFO("%s", msg.data.c_str());
70 |
71 | /**
72 | * The publish() function is how you send messages. The parameter
73 | * is the message object. The type of this object must agree with the type
74 | * given as a template parameter to the advertise<>() call, as was done
75 | * in the constructor above.
76 | */
77 | chatter_pub.publish(msg);
78 |
79 | ros::spinOnce();
80 |
81 | loop_rate.sleep();
82 | ++count;
83 | }
84 |
85 |
86 | return 0;
87 | }
88 |
--------------------------------------------------------------------------------
/create_package_srvclient/catkin_ws/src/beginner_tutorials/srv/AddTwoInts.srv:
--------------------------------------------------------------------------------
1 | int64 a
2 | int64 b
3 | ---
4 | int64 sum
5 |
--------------------------------------------------------------------------------