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
5593e96d
Commit
5593e96d
authored
2 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
send the scene more frequently, restart the scene provider when it crashes
parent
0720e3a3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
launch/distributed-sorting/virtual_scene_provider.launch
+1
-1
1 addition, 1 deletion
launch/distributed-sorting/virtual_scene_provider.launch
src/virtual_scene_provider.cpp
+70
-74
70 additions, 74 deletions
src/virtual_scene_provider.cpp
with
71 additions
and
75 deletions
launch/distributed-sorting/virtual_scene_provider.launch
+
1
−
1
View file @
5593e96d
...
...
@@ -3,7 +3,7 @@
<arg name="connection_address" default="tcp://*:6576" doc="connection address for NNG scene-based selection"/>
<arg name="mqtt_server" default="tcp://127.0.0.1:1883" doc="MQTT server for communication with client cells"/>
<node pkg="ccf_immersive_sorting" type="virtual_scene_provider" name="main_controller" output="screen">
<node pkg="ccf_immersive_sorting" type="virtual_scene_provider" name="main_controller" output="screen"
respawn="true" respawn_delay="3"
>
<param name="connection_address" type="string" value="$(arg connection_address)"/>
<param name="mqtt_server" type="yaml" value="$(arg mqtt_server)"/>
<param name="arm" type="string" value="virtual-arm"/>
...
...
This diff is collapsed.
Click to expand it.
src/virtual_scene_provider.cpp
+
70
−
74
View file @
5593e96d
...
...
@@ -12,17 +12,17 @@
#include
"ccf/connection/MqttConnection.h"
#include
"ccf/util/NodeUtil.h"
const
char
*
DEFAULT_NODE_NAME
=
"virtual_scene_provider"
;
const
char
*
DEFAULT_NODE_NAME
=
"virtual_scene_provider"
;
std
::
string
NODE_NAME
;
using
CetiRosToolbox
::
getParameter
;
using
CetiRosToolbox
::
getPrivateParameter
;
const
float
UNSELECT
=
0.8
;
const
float
SELECT
=
1
/
UNSELECT
;
const
float
SELECT
=
1
/
UNSELECT
;
const
float
DELETING
=
0.08
;
void
highlight
(
Object
*
selected_bin
,
float
factor
)
void
highlight
(
Object
*
selected_bin
,
float
factor
)
{
if
(
selected_bin
)
{
...
...
@@ -32,7 +32,7 @@ void highlight(Object *selected_bin, float factor)
}
}
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
GOOGLE_PROTOBUF_VERIFY_VERSION
;
...
...
@@ -46,7 +46,7 @@ int main(int argc, char **argv)
auto
robotName
=
getPrivateParameter
<
std
::
string
>
(
"arm"
,
"virtual-arm"
);
ROS_INFO_STREAM
(
"This cell controls arm "
<<
robotName
);
DummyRobotArmController
controller
{
n
,
NODE_NAME
,
robotName
};
DummyRobotArmController
controller
{
n
,
NODE_NAME
,
robotName
};
std
::
map
<
std
::
string
,
CellController
>
clients
;
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
actions
;
...
...
@@ -62,81 +62,77 @@ int main(int argc, char **argv)
controller
.
addConnection
(
client_connection
);
client_connection
->
listen
(
getParameter
<
std
::
string
>
(
n
,
"topics/selection"
,
"selection"
));
auto
fallback_path
=
ros
::
package
::
getPath
(
"ccf_immersive_sorting"
)
+
"/config/config_scene_virtual-tag-table-grey.json"
;
auto
fallback_path
=
ros
::
package
::
getPath
(
"ccf_immersive_sorting"
)
+
"/config/config_scene_virtual-tag-table-grey.json"
;
controller
.
loadScene
(
getPrivateParameter
<
std
::
string
>
(
"scene"
,
fallback_path
));
Object
*
robot
=
controller
.
resolveObject
(
controller
.
getRobotName
());
Object
*
selected_box
=
nullptr
;
Object
*
selected_bin
=
nullptr
;
Object
*
selected_box
=
nullptr
;
Object
*
selected_bin
=
nullptr
;
ros
::
Subscriber
sub
=
n
.
subscribe
<
std_msgs
::
Empty
>
(
"send_scene"
,
1000
,
[
&
controller
](
const
std_msgs
::
EmptyConstPtr
&
msg
)
{
controller
.
sendScene
();
});
ros
::
Timer
timer
=
n
.
createTimer
(
ros
::
Duration
(
10
),
[
&
controller
](
const
ros
::
TimerEvent
&
event
)
{
"send_scene"
,
1000
,
[
&
controller
](
const
std_msgs
::
EmptyConstPtr
&
msg
)
{
controller
.
sendScene
();
});
ros
::
Timer
timer
=
n
.
createTimer
(
ros
::
Duration
(
3
),
[
&
controller
](
const
ros
::
TimerEvent
&
event
)
{
controller
.
sendScene
();
});
// send a scene every ten seconds
auto
selection_message_callback
=
[
&
controller
,
&
selected_box
,
&
selected_bin
,
client_connection
](
const
Selection
&
selection
)
});
// send a scene every three seconds
auto
selection_message_callback
=
[
&
controller
,
&
selected_box
,
&
selected_bin
,
client_connection
](
const
Selection
&
selection
)
{
client_connection
->
send
(
"vr_selection"
,
selection
.
SerializeAsString
());
Object
*
object
=
controller
.
resolveObject
(
selection
.
id
());
if
(
!
object
)
{
ROS_ERROR_STREAM
(
"Selected unknown object '"
<<
selection
.
id
()
<<
"'"
);
return
;
}
auto
type
=
Object
::
Type_Name
(
object
->
type
());
if
(
object
->
type
()
==
Object
::
BOX
)
{
highlight
(
selected_box
,
UNSELECT
);
if
(
selected_box
==
object
)
{
client_connection
->
send
(
"vr_selection"
,
selection
.
SerializeAsString
());
Object
*
object
=
controller
.
resolveObject
(
selection
.
id
());
if
(
!
object
)
{
ROS_ERROR_STREAM
(
"Selected unknown object '"
<<
selection
.
id
()
<<
"'"
);
return
;
}
auto
type
=
Object
::
Type_Name
(
object
->
type
());
if
(
object
->
type
()
==
Object
::
BOX
)
{
highlight
(
selected_box
,
UNSELECT
);
if
(
selected_box
==
object
)
{
selected_box
=
nullptr
;
}
else
{
selected_box
=
object
;
highlight
(
selected_box
,
SELECT
);
}
controller
.
sendScene
();
ROS_INFO_STREAM
(
"Selected "
<<
type
<<
" '"
<<
selection
.
id
()
<<
"'"
);
}
else
if
(
object
->
type
()
==
Object
::
BIN
)
{
highlight
(
selected_bin
,
UNSELECT
);
if
(
selected_bin
==
object
)
{
selected_bin
=
nullptr
;
}
else
{
selected_bin
=
object
;
highlight
(
selected_bin
,
SELECT
);
}
controller
.
sendScene
();
ROS_INFO_STREAM
(
"Selected "
<<
type
<<
" '"
<<
selection
.
id
()
<<
"'"
);
}
else
{
ROS_WARN_STREAM
(
"Selected unsupported "
<<
type
<<
" '"
<<
selection
.
id
()
<<
"'"
);
}
if
(
selected_bin
&&
selected_box
)
{
auto
boxId
=
selected_box
->
id
();
ROS_INFO_STREAM
(
"Got task: Put "
<<
boxId
<<
" into "
<<
selected_bin
->
id
());
highlight
(
selected_bin
,
UNSELECT
);
highlight
(
selected_box
,
UNSELECT
);
controller
.
sendScene
();
selected_box
=
nullptr
;
selected_bin
=
nullptr
;
}
};
selected_box
=
nullptr
;
}
else
{
selected_box
=
object
;
highlight
(
selected_box
,
SELECT
);
}
controller
.
sendScene
();
ROS_INFO_STREAM
(
"Selected "
<<
type
<<
" '"
<<
selection
.
id
()
<<
"'"
);
}
else
if
(
object
->
type
()
==
Object
::
BIN
)
{
highlight
(
selected_bin
,
UNSELECT
);
if
(
selected_bin
==
object
)
{
selected_bin
=
nullptr
;
}
else
{
selected_bin
=
object
;
highlight
(
selected_bin
,
SELECT
);
}
controller
.
sendScene
();
ROS_INFO_STREAM
(
"Selected "
<<
type
<<
" '"
<<
selection
.
id
()
<<
"'"
);
}
else
{
ROS_WARN_STREAM
(
"Selected unsupported "
<<
type
<<
" '"
<<
selection
.
id
()
<<
"'"
);
}
if
(
selected_bin
&&
selected_box
)
{
auto
boxId
=
selected_box
->
id
();
ROS_INFO_STREAM
(
"Got task: Put "
<<
boxId
<<
" into "
<<
selected_bin
->
id
());
highlight
(
selected_bin
,
UNSELECT
);
highlight
(
selected_box
,
UNSELECT
);
controller
.
sendScene
();
selected_box
=
nullptr
;
selected_bin
=
nullptr
;
}
};
controller
.
reactToSelectionMessage
(
selection_message_callback
);
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