Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OLD CCF - The CeTI Cobotic Framework
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
CeTI
ROS
CeTI Cobotic Framework
OLD CCF - The CeTI Cobotic Framework
Commits
281f7493
Commit
281f7493
authored
5 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
rename sender and receiver to publisher and subscriber
parent
62c53252
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+6
-6
6 additions, 6 deletions
CMakeLists.txt
package.xml
+1
-1
1 addition, 1 deletion
package.xml
src/nng_publisher.cpp
+3
-3
3 additions, 3 deletions
src/nng_publisher.cpp
src/nng_subscriber.cpp
+4
-6
4 additions, 6 deletions
src/nng_subscriber.cpp
with
14 additions
and
16 deletions
CMakeLists.txt
+
6
−
6
View file @
281f7493
...
...
@@ -138,27 +138,27 @@ include_directories(
## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
add_executable
(
${
PROJECT_NAME
}
_
send
er src/nng_
send
er.cpp
${
PROTO_SRCS
}
${
PROTO_HDRS
}
)
add_executable
(
${
PROJECT_NAME
}
_
receiv
er src/nng_
receiv
er.cpp
${
PROTO_SRCS
}
${
PROTO_HDRS
}
)
add_executable
(
${
PROJECT_NAME
}
_
publish
er src/nng_
publish
er.cpp
${
PROTO_SRCS
}
${
PROTO_HDRS
}
)
add_executable
(
${
PROJECT_NAME
}
_
subscrib
er src/nng_
subscrib
er.cpp
${
PROTO_SRCS
}
${
PROTO_HDRS
}
)
## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## 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
}
_
send
er PROPERTIES OUTPUT_NAME
send
er PREFIX
""
)
set_target_properties
(
${
PROJECT_NAME
}
_
receiv
er PROPERTIES OUTPUT_NAME
receiv
er PREFIX
""
)
set_target_properties
(
${
PROJECT_NAME
}
_
publish
er PROPERTIES OUTPUT_NAME
publish
er PREFIX
""
)
set_target_properties
(
${
PROJECT_NAME
}
_
subscrib
er PROPERTIES OUTPUT_NAME
subscrib
er PREFIX
""
)
## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Specify libraries to link a library or executable target against
target_link_libraries
(
${
PROJECT_NAME
}
_
send
er
target_link_libraries
(
${
PROJECT_NAME
}
_
publish
er
${
catkin_LIBRARIES
}
nng
${
Protobuf_LIBRARIES
}
)
target_link_libraries
(
${
PROJECT_NAME
}
_
receiv
er
target_link_libraries
(
${
PROJECT_NAME
}
_
subscrib
er
${
catkin_LIBRARIES
}
nng
${
Protobuf_LIBRARIES
}
...
...
This diff is collapsed.
Click to expand it.
package.xml
+
1
−
1
View file @
281f7493
...
...
@@ -2,7 +2,7 @@
<package
format=
"2"
>
<name>
nng_test
</name>
<version>
0.1.0
</version>
<description>
a
sender and receiv
er node using nng
</description>
<description>
a
publisher and subscrib
er node using nng
</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<maintainer
email=
"johannes.mey@tu-dresden.de"
>
Johannes Mey
</maintainer>
...
...
This diff is collapsed.
Click to expand it.
src/nng_
send
er.cpp
→
src/nng_
publish
er.cpp
+
3
−
3
View file @
281f7493
...
...
@@ -16,7 +16,7 @@ nng_socket sock;
int
rv
;
void
nngCallback
(
const
std_msgs
::
String
::
ConstPtr
&
msg
)
{
ROS_INFO
(
"
send
ing via NNG: [%s]"
,
msg
->
data
.
c_str
());
ROS_INFO
(
"
publish
ing via NNG: [%s]"
,
msg
->
data
.
c_str
());
// wrap into protobuf message
Ping
ping
;
...
...
@@ -34,7 +34,7 @@ int main(int argc, char **argv) {
GOOGLE_PROTOBUF_VERIFY_VERSION
;
ros
::
init
(
argc
,
argv
,
"nng_
send
er"
);
ros
::
init
(
argc
,
argv
,
"nng_
publish
er"
);
ros
::
NodeHandle
n
(
"nnc_test"
);
...
...
@@ -45,7 +45,7 @@ int main(int argc, char **argv) {
ROS_ERROR_STREAM
(
"nng_listen returned: "
<<
nng_strerror
(
rv
));
}
ros
::
Subscriber
sub
=
n
.
subscribe
(
"
send
_nng"
,
1000
,
nngCallback
);
ros
::
Subscriber
sub
=
n
.
subscribe
(
"
publish_to
_nng"
,
1000
,
nngCallback
);
ros
::
spin
();
...
...
This diff is collapsed.
Click to expand it.
src/nng_
receiv
er.cpp
→
src/nng_
subscrib
er.cpp
+
4
−
6
View file @
281f7493
...
...
@@ -15,11 +15,11 @@
const
std
::
string
URL
=
"tcp://localhost:6576"
;
int
main
(
int
argc
,
char
**
argv
)
{
ros
::
init
(
argc
,
argv
,
"nng_
receiv
er"
);
ros
::
init
(
argc
,
argv
,
"nng_
subscrib
er"
);
ros
::
NodeHandle
n
(
"nnc_test"
);
ros
::
Publisher
nng_
receiv
er_pub
=
n
.
advertise
<
std_msgs
::
String
>
(
"received_nng"
,
1000
);
ros
::
Publisher
nng_
subscrib
er_pub
=
n
.
advertise
<
std_msgs
::
String
>
(
"received_nng
_subscription
"
,
1000
);
ros
::
Rate
loop_rate
(
200
);
...
...
@@ -49,13 +49,11 @@ int main(int argc, char **argv) {
ping
.
ParseFromArray
(
buf
,
sz
);
nng_free
(
buf
,
sz
);
ROS_INFO_STREAM
(
"CLIENT: RECEIVED '"
<<
ping
.
name
()
<<
"'"
);
// build and publish a ROS message
std_msgs
::
String
msg
;
msg
.
data
=
ping
.
name
();
ROS_INFO_STREAM
(
"Publishing ROS message '"
<<
msg
.
data
<<
"'"
);
nng_
receiv
er_pub
.
publish
(
msg
);
ROS_INFO_STREAM
(
"
Received Ping.
Publishing ROS message '"
<<
msg
.
data
<<
"'"
);
nng_
subscrib
er_pub
.
publish
(
msg
);
}
else
if
(
rv
==
NNG_EAGAIN
)
{
// no message received in current spin
}
else
{
...
...
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