Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CCF Immersive Sorting Demo
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 Immersive Sorting Demo
Commits
b8f4c2fa
Commit
b8f4c2fa
authored
3 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
add settings and ros message interface to dummy selection provider
parent
ab88f031
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/dummy_selection_provider.cpp
+55
-26
55 additions, 26 deletions
src/dummy_selection_provider.cpp
with
55 additions
and
26 deletions
src/dummy_selection_provider.cpp
+
55
−
26
View file @
b8f4c2fa
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
#include
"ros/ros.h"
#include
"ros/ros.h"
#include
"std_msgs/String.h"
#include
"std_msgs/String.h"
#include
"ccf/util/NodeUtil.h"
#include
<nng/nng.h>
#include
<nng/nng.h>
#include
<nng/protocol/pair1/pair.h>
#include
<nng/protocol/pair1/pair.h>
...
@@ -51,6 +53,9 @@ int main(int argc, char **argv) {
...
@@ -51,6 +53,9 @@ int main(int argc, char **argv) {
ros
::
NodeHandle
n
(
"ccf"
);
ros
::
NodeHandle
n
(
"ccf"
);
auto
autoselect
=
CetiRosToolbox
::
getPrivateParameter
<
bool
>
(
"autoselect"
,
"false"
);
auto
prefix
=
CetiRosToolbox
::
getPrivateParameter
<
std
::
string
>
(
"prefix"
,
"sub_select"
);
if
((
rv
=
nng_pair1_open
(
&
sock
))
!=
0
)
{
if
((
rv
=
nng_pair1_open
(
&
sock
))
!=
0
)
{
ROS_ERROR_STREAM
(
"nng_pair1_open returned: "
<<
nng_strerror
(
rv
));
ROS_ERROR_STREAM
(
"nng_pair1_open returned: "
<<
nng_strerror
(
rv
));
}
}
...
@@ -70,6 +75,11 @@ int main(int argc, char **argv) {
...
@@ -70,6 +75,11 @@ int main(int argc, char **argv) {
std
::
random_device
rd
;
std
::
random_device
rd
;
std
::
mt19937
rng
(
rd
());
std
::
mt19937
rng
(
rd
());
ros
::
Subscriber
sub_select
=
n
.
subscribe
<
std_msgs
::
String
>
(
prefix
+
"/select"
,
1000
,
[
&
](
auto
&
m
)
{
sendSelection
(
m
->
data
);
});
ros
::
Publisher
pub_objects
=
n
.
advertise
<
std_msgs
::
String
>
(
prefix
+
"/objects"
,
1
);
ros
::
Publisher
pub_bins
=
n
.
advertise
<
std_msgs
::
String
>
(
prefix
+
"/bins"
,
1
);
while
(
ros
::
ok
())
{
while
(
ros
::
ok
())
{
char
*
buf
=
nullptr
;
char
*
buf
=
nullptr
;
...
@@ -104,6 +114,25 @@ int main(int argc, char **argv) {
...
@@ -104,6 +114,25 @@ int main(int argc, char **argv) {
}
}
}
}
std_msgs
::
String
objects_msg
;
objects_msg
.
data
=
objects
.
empty
()
?
""
:
std
::
accumulate
(
++
objects
.
begin
(),
objects
.
end
(),
*
objects
.
begin
(),
[](
auto
&
a
,
auto
&
b
)
{
return
a
+
","
+
b
;
});
pub_objects
.
publish
(
objects_msg
);
std_msgs
::
String
bins_msg
;
bins_msg
.
data
=
bins
.
empty
()
?
""
:
std
::
accumulate
(
++
bins
.
begin
(),
bins
.
end
(),
*
bins
.
begin
(),
[](
auto
&
a
,
auto
&
b
)
{
return
a
+
","
+
b
;
});
pub_bins
.
publish
(
bins_msg
);
if
(
autoselect
)
{
if
(
objects
.
empty
())
{
if
(
objects
.
empty
())
{
ROS_INFO
(
"No objects to select in a scene without boxes!"
);
ROS_INFO
(
"No objects to select in a scene without boxes!"
);
}
else
if
(
bins
.
empty
())
{
}
else
if
(
bins
.
empty
())
{
...
@@ -130,7 +159,7 @@ int main(int argc, char **argv) {
...
@@ -130,7 +159,7 @@ int main(int argc, char **argv) {
ROS_INFO_STREAM
(
"Selecting random bin: "
<<
bin
);
ROS_INFO_STREAM
(
"Selecting random bin: "
<<
bin
);
sendSelection
(
bin
);
sendSelection
(
bin
);
}
}
}
}
else
if
(
rv
==
NNG_EAGAIN
)
{
}
else
if
(
rv
==
NNG_EAGAIN
)
{
// no message received in current spin
// no message received in current spin
}
else
{
}
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