Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CCF Base Application
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CeTI
ROS
CeTI Cobotic Framework
CCF Base Application
Commits
4667e148
Commit
4667e148
authored
3 years ago
by
Sebastian Ebert
Browse files
Options
Downloads
Patches
Plain Diff
completed ros connection example
parent
b0f4a0c8
Branches
feature/ros-connection
No related tags found
1 merge request
!1
Example for -> feature/ros connection
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+1
-1
1 addition, 1 deletion
CMakeLists.txt
src/ros_demo.cpp
+20
-7
20 additions, 7 deletions
src/ros_demo.cpp
with
21 additions
and
8 deletions
CMakeLists.txt
+
1
−
1
View file @
4667e148
...
...
@@ -143,7 +143,7 @@ add_executable(${PROJECT_NAME}_ros_demo src/ros_demo.cpp ${PROTO_SRCS} ${PROTO_H
## target back to the shorter version for ease of user use
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
set_target_properties
(
${
PROJECT_NAME
}
_demo PROPERTIES OUTPUT_NAME demo PREFIX
""
)
set_target_properties
(
${
PROJECT_NAME
}
_ros_demo PROPERTIES OUTPUT_NAME ros_
nnnnn
demo PREFIX
""
)
set_target_properties
(
${
PROJECT_NAME
}
_ros_demo PROPERTIES OUTPUT_NAME ros_demo PREFIX
""
)
## Add cmake target dependencies of the executable
## same as for the library above
...
...
This diff is collapsed.
Click to expand it.
src/ros_demo.cpp
+
20
−
7
View file @
4667e148
...
...
@@ -8,10 +8,13 @@
#include
"ccf/controller/Controller.h"
#include
"ccf/connection/RosConnection.h"
#include
"ccf/util/NodeUtil.h"
void
receiverCallback
(
const
std
::
string
&
msg
){
std
::
cout
<<
"RECEIVED: "
<<
msg
<<
std
::
endl
;
void
receiverCallbackA
(
const
std
::
string
&
msg
){
std
::
cout
<<
"RECEIVED on A: "
<<
msg
<<
std
::
endl
;
}
void
receiverCallbackB
(
const
std
::
string
&
msg
){
std
::
cout
<<
"RECEIVED on B: "
<<
msg
<<
std
::
endl
;
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -24,11 +27,21 @@ int main(int argc, char **argv) {
Controller
controller
{
n
};
std
::
unique_ptr
<
RosConnection
>
connection
=
std
::
make_unique
<
RosConnection
>
(
"demo"
,
n
);
connection
->
setTopic
(
"demo"
);
// connection->setHandle(n);
std
::
unique_ptr
<
RosConnection
>
connection
=
std
::
make_unique
<
RosConnection
>
(
n
,
3000
,
3000
);
connection
->
listen
(
"topicA"
);
connection
->
listen
(
"topicB"
);
connection
->
addPublisher
(
"topicA"
);
controller
.
addConnection
(
std
::
move
(
connection
));
controller
.
addCallback
(
"demo"
,
receiverCallback
);
controller
.
addCallback
(
"topicA"
,
receiverCallbackA
);
controller
.
addCallback
(
"topicB"
,
receiverCallbackB
);
// make sure that the publisher got registered within the master
ros
::
Rate
(
ros
::
Duration
(
0.5
)).
sleep
();
controller
.
sendToAll
(
"topicA"
,
"Hello World!"
);
ros
::
spin
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment