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
GitLab 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
b97165a2
Commit
b97165a2
authored
3 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
add support for pick/place/drop, fix initialization bug
parent
7c93ad52
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/moveit_sorting_controller.cpp
+58
-19
58 additions, 19 deletions
src/moveit_sorting_controller.cpp
with
58 additions
and
19 deletions
src/moveit_sorting_controller.cpp
+
58
−
19
View file @
b97165a2
...
@@ -56,6 +56,12 @@ int main(int argc, char** argv)
...
@@ -56,6 +56,12 @@ int main(int argc, char** argv)
controller
.
initScene
(
scene
,
false
);
controller
.
initScene
(
scene
,
false
);
});
});
ros
::
WallDuration
(
5
).
sleep
();
// wait 5 secs to init scene (to give moveit time to load)
controller
.
loadScene
(
getPrivateParameter
<
std
::
string
>
(
"scene"
,
ros
::
package
::
getPath
(
"ccf_immersive_sorting"
)
+
"/config/config_scene_ceti-table-1-empty.json"
));
// only add the scene observer after the base scene has been loaded
controller
.
addCallback
(
scene_observer_topic
,
[
&
controller
](
auto
msg
)
{
controller
.
addCallback
(
scene_observer_topic
,
[
&
controller
](
auto
msg
)
{
ROS_INFO_STREAM
(
"Updating scene from observer."
);
ROS_INFO_STREAM
(
"Updating scene from observer."
);
Scene
scene
;
Scene
scene
;
...
@@ -63,13 +69,6 @@ int main(int argc, char** argv)
...
@@ -63,13 +69,6 @@ int main(int argc, char** argv)
controller
.
initScene
(
scene
,
true
);
controller
.
initScene
(
scene
,
true
);
});
});
ros
::
WallDuration
(
5
).
sleep
();
// wait 5 secs to init scene (to give moveit time to load)
controller
.
loadScene
(
getPrivateParameter
<
std
::
string
>
(
"scene"
,
ros
::
package
::
getPath
(
"ccf_immersive_sorting"
)
+
"/config/config_scene_ceti-table-placeworld.json"
));
std
::
optional
<
std
::
string
>
currentlyPickedBox
{};
ros
::
Subscriber
sub
=
ros
::
Subscriber
sub
=
n
.
subscribe
<
std_msgs
::
Empty
>
(
"send_scene"
,
1000
,
[
&
controller
](
const
std_msgs
::
EmptyConstPtr
&
msg
)
{
n
.
subscribe
<
std_msgs
::
Empty
>
(
"send_scene"
,
1000
,
[
&
controller
](
const
std_msgs
::
EmptyConstPtr
&
msg
)
{
ROS_INFO_STREAM
(
"Sending scene manually (triggered by a message to the 'send_scene' topic)"
);
ROS_INFO_STREAM
(
"Sending scene manually (triggered by a message to the 'send_scene' topic)"
);
...
@@ -194,25 +193,65 @@ int main(int argc, char** argv)
...
@@ -194,25 +193,65 @@ int main(int argc, char** argv)
}
}
controller
.
configureCollaborationZone
(
*
zone
,
command
.
configchange
().
idrobotnewowner
());
controller
.
configureCollaborationZone
(
*
zone
,
command
.
configchange
().
idrobotnewowner
());
}
}
else
else
if
(
command
.
has_pick
())
{
{
ROS_WARN_STREAM
(
"[COMMAND] IGNORED! Ignoring command of unknown type "
<<
command
.
msg_case
());
Object
*
robot
=
controller
.
resolveObject
(
command
.
pick
().
idrobot
());
Object
*
object
=
controller
.
resolveObject
(
command
.
pick
().
idpick
());
ROS_INFO_STREAM
(
"[COMMAND] Pick "
<<
object
->
id
()
<<
" using robot "
<<
robot
->
id
());
if
(
!
robot
)
{
ROS_ERROR_STREAM
(
"[COMMAND] FAILED! Unable to pick using unknown robot '"
<<
command
.
pick
().
idrobot
()
<<
"'."
);
return
;
}
}
};
if
(
!
object
)
controller
.
reactToCommandMessage
(
pick_place_callback
);
{
ROS_ERROR_STREAM
(
"[COMMAND] FAILED! Unable to pick unknown object '"
<<
command
.
pick
().
idpick
()
<<
"'."
);
return
;
}
controller
.
pick
(
command
.
pick
().
idrobot
(),
command
.
pick
().
idpick
(),
false
);
}
else
if
(
command
.
has_place
())
{
Object
*
robot
=
controller
.
resolveObject
(
command
.
place
().
idrobot
());
Object
*
object
=
controller
.
resolveObject
(
command
.
place
().
idplace
());
ROS_INFO_STREAM
(
"[COMMAND] Place object at "
<<
object
->
id
()
<<
" using robot "
<<
robot
->
id
());
if
(
!
robot
)
{
ROS_ERROR_STREAM
(
"[COMMAND] FAILED! Unable to place using unknown robot '"
<<
command
.
place
().
idrobot
()
<<
"'."
);
return
;
}
if
(
!
object
)
{
ROS_ERROR_STREAM
(
"[COMMAND] FAILED! Unable to place at unknown location '"
<<
command
.
place
().
idplace
()
<<
"'."
);
return
;
}
controller
.
place
(
command
.
place
().
idrobot
(),
command
.
place
().
idplace
(),
false
);
}
else
if
(
command
.
has_drop
())
{
auto
sceneUpdateCallback
=
[
&
currentlyPickedBox
,
&
controller
]()
{
Object
*
robot
=
controller
.
resolveObject
(
command
.
drop
().
idrobot
());
if
(
currentlyPickedBox
.
has_value
())
Object
*
bin
=
controller
.
resolveObject
(
command
.
drop
().
idbin
());
ROS_INFO_STREAM
(
"[COMMAND] drop object into bin "
<<
bin
->
id
()
<<
" using robot "
<<
robot
->
id
());
if
(
!
robot
)
{
{
auto
resolved
=
controller
.
resolveObject
(
currentlyPickedBox
.
value
());
ROS_ERROR_STREAM
(
"[COMMAND] FAILED! Unable to drop using unknown robot '"
<<
command
.
drop
().
idrobot
()
<<
"'."
);
if
(
!
resolved
)
return
;
}
if
(
!
bin
)
{
{
ROS_
INFO
_STREAM
(
"
box "
<<
currentlyPickedBox
.
value
()
<<
" has been removed from the scene!
"
);
ROS_
ERROR
_STREAM
(
"
[COMMAND] FAILED! Unable to drop into unknown bin '"
<<
command
.
drop
().
idbin
()
<<
"'.
"
);
currentlyPickedBox
.
reset
()
;
return
;
}
}
controller
.
drop
(
command
.
drop
().
idrobot
(),
command
.
drop
().
idbin
(),
false
);
}
else
{
ROS_WARN_STREAM
(
"[COMMAND] IGNORED! Ignoring command of unknown type "
<<
command
.
msg_case
());
}
}
};
};
controller
.
reactTo
SceneUpdateMessage
(
sceneUpdateC
allback
);
controller
.
reactTo
CommandMessage
(
pick_place_c
allback
);
ros
::
spin
();
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