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
56ad65b6
Commit
56ad65b6
authored
3 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
change owner handling for collab zones
parent
cc9dd5d1
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/dummy_sorting_controller.cpp
+81
-62
81 additions, 62 deletions
src/dummy_sorting_controller.cpp
src/moveit_sorting_controller.cpp
+1
-1
1 addition, 1 deletion
src/moveit_sorting_controller.cpp
with
82 additions
and
63 deletions
src/dummy_sorting_controller.cpp
+
81
−
62
View file @
56ad65b6
...
@@ -25,7 +25,6 @@ using CetiRosToolbox::getPrivateParameter;
...
@@ -25,7 +25,6 @@ using CetiRosToolbox::getPrivateParameter;
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
GOOGLE_PROTOBUF_VERIFY_VERSION
;
GOOGLE_PROTOBUF_VERIFY_VERSION
;
ros
::
init
(
argc
,
argv
,
NODE_NAME
);
ros
::
init
(
argc
,
argv
,
NODE_NAME
);
...
@@ -39,8 +38,8 @@ int main(int argc, char **argv)
...
@@ -39,8 +38,8 @@ int main(int argc, char **argv)
DummyRobotArmController
controller
{
n
,
NODE_NAME
,
robotName
};
DummyRobotArmController
controller
{
n
,
NODE_NAME
,
robotName
};
auto
mqttServer
=
getPrivateParameter
<
std
::
string
>
(
"mqtt_server"
,
"localhost:1883"
);
auto
mqttServer
=
getPrivateParameter
<
std
::
string
>
(
"mqtt_server"
,
"localhost:1883"
);
std
::
unique_ptr
<
MqttConnection
>
std
::
unique_ptr
<
MqttConnection
>
mqtt_connection
=
mqtt_connection
=
std
::
make_unique
<
MqttConnection
>
(
mqttServer
,
ros
::
this_node
::
getName
());
std
::
make_unique
<
MqttConnection
>
(
mqttServer
,
ros
::
this_node
::
getName
());
mqtt_connection
->
listen
(
getParameter
<
std
::
string
>
(
n
,
"topics/selection"
,
"selection"
));
mqtt_connection
->
listen
(
getParameter
<
std
::
string
>
(
n
,
"topics/selection"
,
"selection"
));
auto
commandTopic
=
getParameter
<
std
::
string
>
(
n
,
"topics/command"
,
"/ceti_cell_placeworld/command"
);
auto
commandTopic
=
getParameter
<
std
::
string
>
(
n
,
"topics/command"
,
"/ceti_cell_placeworld/command"
);
mqtt_connection
->
listen
(
commandTopic
);
mqtt_connection
->
listen
(
commandTopic
);
...
@@ -57,89 +56,107 @@ int main(int argc, char **argv)
...
@@ -57,89 +56,107 @@ int main(int argc, char **argv)
ros
::
WallDuration
(
5
).
sleep
();
// wait 5 secs to init scene (to give moveit time to load)
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"
)
+
controller
.
loadScene
(
getPrivateParameter
<
std
::
string
>
(
"scene"
,
ros
::
package
::
getPath
(
"ccf_immersive_sorting"
)
+
"/con"
"/config/config_scene_ceti-table-placeworld.json"
));
"fig/"
"conf"
"ig_"
"scen"
"e_"
"ceti"
"-tab"
"le-"
"plac"
"ewor"
"ld."
"jso"
"n"
));
std
::
optional
<
std
::
string
>
currentlyPickedBox
{};
std
::
optional
<
std
::
string
>
currentlyPickedBox
{};
ros
::
Subscriber
sub
=
n
.
subscribe
<
std_msgs
::
Empty
>
(
"send_scene"
,
1000
,
[
&
controller
](
ros
::
Subscriber
sub
=
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)"
);
controller
.
sendScene
();
controller
.
sendScene
();
});
});
auto
pick_place_callback
=
[
&
controller
](
const
Command
&
command
)
auto
pick_place_callback
=
[
&
controller
](
const
Command
&
command
)
{
{
const
PickAndPlace
&
pick_place
=
command
.
pickandplace
();
const
PickAndPlace
&
pick_place
=
command
.
pickandplace
();
if
(
command
.
has_pickandplace
())
{
if
(
command
.
has_pickandplace
())
ROS_INFO_STREAM
(
"Got Command to pick object "
<<
pick_place
.
idpick
()
<<
" and place it into "
<<
pick_place
.
idplace
());
{
ROS_INFO_STREAM
(
"Got Command to pick object "
<<
pick_place
.
idpick
()
<<
" and place it into "
<<
pick_place
.
idplace
());
Object
*
pick_object
=
controller
.
resolveObject
(
pick_place
.
idpick
());
Object
*
pick_object
=
controller
.
resolveObject
(
pick_place
.
idpick
());
if
(
!
pick_object
)
if
(
!
pick_object
)
{
{
ROS_ERROR_STREAM
(
ROS_ERROR_STREAM
(
"Selected unknown pick object '"
<<
pick_place
.
idpick
()
<<
"'"
);
"Selected unknown pick object '"
<<
pick_place
.
idpick
()
<<
"'"
);
return
;
return
;
}
}
Object
*
place_object
=
controller
.
resolveObject
(
pick_place
.
idplace
());
Object
*
place_object
=
controller
.
resolveObject
(
pick_place
.
idplace
());
if
(
!
place_object
)
if
(
!
place_object
)
{
{
ROS_ERROR_STREAM
(
ROS_ERROR_STREAM
(
"Selected unknown place object '"
<<
pick_place
.
idplace
()
<<
"'"
);
"Selected unknown place object '"
<<
pick_place
.
idplace
()
<<
"'"
);
return
;
return
;
}
}
if
(
pick_object
->
type
()
!=
Object
::
BOX
)
if
(
pick_object
->
type
()
!=
Object
::
BOX
)
{
{
ROS_WARN_STREAM
(
ROS_WARN_STREAM
(
"Selected unsupported pick object of type "
<<
pick_object
->
type
());
"Selected unsupported pick object of type "
<<
pick_object
->
type
());
}
}
if
(
place_object
->
type
()
!=
Object
::
BIN
&&
place_object
->
type
()
!=
Object
::
DROP_OFF_LOCATION
&&
place_object
->
type
()
!=
Object
::
COLLABORATION_ZONE
)
if
(
place_object
->
type
()
!=
Object
::
BIN
&&
place_object
->
type
()
!=
Object
::
DROP_OFF_LOCATION
&&
place_object
->
type
()
!=
Object
::
COLLABORATION_ZONE
)
{
{
ROS_WARN_STREAM
(
ROS_WARN_STREAM
(
"Selected unsupported place object of type "
<<
place_object
->
type
());
"Selected unsupported place object of type "
<<
place_object
->
type
());
}
}
if
(
command
.
pickandplace
().
idrobot
()
!=
controller
.
getRobotName
())
{
if
(
command
.
pickandplace
().
idrobot
()
!=
controller
.
getRobotName
())
ROS_WARN_STREAM
(
{
"Ignoring command pick-place command for robot "
<<
command
.
pickandplace
().
idrobot
()
<<
" (this is "
<<
controller
.
getRobotName
()
<<
")"
);
ROS_WARN_STREAM
(
"Ignoring command pick-place command for robot "
<<
command
.
pickandplace
().
idrobot
()
<<
" (this is "
<<
controller
.
getRobotName
()
<<
")"
);
return
;
return
;
}
}
Object
*
robot
=
controller
.
resolveObject
(
command
.
pickandplace
().
idrobot
());
Object
*
robot
=
controller
.
resolveObject
(
command
.
pickandplace
().
idrobot
());
if
(
!
robot
)
if
(
!
robot
)
{
{
ROS_ERROR_STREAM
(
ROS_ERROR_STREAM
(
"Inconsistent scene, robot '"
<<
command
.
evacuate
().
idrobot
()
<<
"' not found!"
);
"Inconsistent scene, robot '"
<<
command
.
evacuate
().
idrobot
()
<<
"' not found!"
);
return
;
return
;
}
}
if
(
place_object
->
type
()
==
Object
::
BIN
)
{
if
(
place_object
->
type
()
==
Object
::
BIN
)
if
(
!
controller
.
pickAndDrop
(
*
robot
,
*
pick_object
,
*
place_object
,
false
))
{
{
if
(
!
controller
.
pickAndDrop
(
*
robot
,
*
pick_object
,
*
place_object
,
false
))
{
ROS_WARN_STREAM
(
"Unable to remove box '"
<<
pick_place
.
idpick
()
<<
"'!"
);
ROS_WARN_STREAM
(
"Unable to remove box '"
<<
pick_place
.
idpick
()
<<
"'!"
);
}
else
{
}
else
{
ROS_INFO_STREAM
(
"Job is done! '"
<<
pick_place
.
idpick
()
<<
"' is no more."
);
ROS_INFO_STREAM
(
"Job is done! '"
<<
pick_place
.
idpick
()
<<
"' is no more."
);
controller
.
sendScene
();
controller
.
sendScene
();
}
}
}
else
if
(
place_object
->
type
()
==
Object
::
DROP_OFF_LOCATION
||
place_object
->
type
()
==
Object
::
COLLABORATION_ZONE
)
{
}
if
(
!
controller
.
pickAndPlace
(
*
robot
,
*
pick_object
,
*
place_object
,
false
))
{
else
if
(
place_object
->
type
()
==
Object
::
DROP_OFF_LOCATION
||
place_object
->
type
()
==
Object
::
COLLABORATION_ZONE
)
{
if
(
!
controller
.
pickAndPlace
(
*
robot
,
*
pick_object
,
*
place_object
,
false
))
{
ROS_WARN_STREAM
(
"Unable to move box '"
<<
pick_place
.
idpick
()
<<
"'!"
);
ROS_WARN_STREAM
(
"Unable to move box '"
<<
pick_place
.
idpick
()
<<
"'!"
);
}
else
{
}
else
{
ROS_INFO_STREAM
(
"Job is done! '"
<<
pick_place
.
idpick
()
<<
"' is at its new location."
);
ROS_INFO_STREAM
(
"Job is done! '"
<<
pick_place
.
idpick
()
<<
"' is at its new location."
);
controller
.
sendScene
();
controller
.
sendScene
();
}
}
}
}
}
else
if
(
command
.
has_evacuate
())
{
}
else
if
(
command
.
has_evacuate
())
{
if
(
command
.
evacuate
().
idrobot
()
!=
controller
.
getRobotName
())
{
if
(
command
.
evacuate
().
idrobot
()
!=
controller
.
getRobotName
())
ROS_WARN_STREAM
(
{
"Ignoring command pick-place command for robot "
<<
command
.
evacuate
().
idrobot
()
<<
" (this is "
<<
controller
.
getRobotName
()
<<
")"
);
ROS_WARN_STREAM
(
"Ignoring command pick-place command for robot "
<<
command
.
evacuate
().
idrobot
()
<<
" (this is "
<<
controller
.
getRobotName
()
<<
")"
);
return
;
return
;
}
}
Object
*
robot
=
controller
.
resolveObject
(
command
.
evacuate
().
idrobot
());
Object
*
robot
=
controller
.
resolveObject
(
command
.
evacuate
().
idrobot
());
if
(
!
robot
)
if
(
!
robot
)
{
{
ROS_ERROR_STREAM
(
ROS_ERROR_STREAM
(
"Inconsistent scene, robot '"
<<
command
.
evacuate
().
idrobot
()
<<
"' not found!"
);
"Inconsistent scene, robot '"
<<
command
.
evacuate
().
idrobot
()
<<
"' not found!"
);
return
;
return
;
}
}
...
@@ -149,8 +166,9 @@ int main(int argc, char **argv)
...
@@ -149,8 +166,9 @@ int main(int argc, char **argv)
pose
.
position
.
y
=
robot
->
pos
().
y
();
pose
.
position
.
y
=
robot
->
pos
().
y
();
pose
.
position
.
z
=
robot
->
pos
().
z
()
+
.4
;
pose
.
position
.
z
=
robot
->
pos
().
z
()
+
.4
;
controller
.
moveToPose
(
*
robot
,
pose
,
false
);
controller
.
moveToPose
(
*
robot
,
pose
,
false
);
}
}
else
if
(
command
.
has_configchange
())
{
else
if
(
command
.
has_configchange
())
{
Object
*
zone
=
controller
.
resolveObject
(
command
.
configchange
().
idcollaborationzone
());
Object
*
zone
=
controller
.
resolveObject
(
command
.
configchange
().
idcollaborationzone
());
if
(
!
zone
)
if
(
!
zone
)
{
{
...
@@ -161,18 +179,19 @@ int main(int argc, char **argv)
...
@@ -161,18 +179,19 @@ int main(int argc, char **argv)
Object
*
robot
=
controller
.
resolveObject
(
command
.
configchange
().
idrobotnewowner
());
Object
*
robot
=
controller
.
resolveObject
(
command
.
configchange
().
idrobotnewowner
());
if
(
!
robot
)
if
(
!
robot
)
{
{
ROS_WARN_STREAM
(
ROS_WARN_STREAM
(
"Collaboration zone active for unknown robot '"
<<
command
.
evacuate
().
idrobot
()
"Collaboration zone active for unknown robot '"
<<
command
.
evacuate
().
idrobot
()
<<
"', so blocked in all."
);
<<
"', so blocked in all."
);
}
}
controller
.
configureCollaborationZone
(
*
zone
,
command
.
configchange
().
idrobotnewowner
()
!=
controller
.
getRobotName
());
controller
.
configureCollaborationZone
(
*
zone
,
command
.
configchange
().
idrobotnewowner
());
}
else
{
}
else
{
ROS_WARN_STREAM
(
"Ignoring command that is not PickAndPlace but "
<<
command
.
msg_case
());
ROS_WARN_STREAM
(
"Ignoring command that is not PickAndPlace but "
<<
command
.
msg_case
());
}
}
};
};
controller
.
reactToCommandMessage
(
pick_place_callback
);
controller
.
reactToCommandMessage
(
pick_place_callback
);
auto
sceneUpdateCallback
=
[
&
currentlyPickedBox
,
&
controller
]()
auto
sceneUpdateCallback
=
[
&
currentlyPickedBox
,
&
controller
]()
{
{
if
(
currentlyPickedBox
.
has_value
())
if
(
currentlyPickedBox
.
has_value
())
{
{
auto
resolved
=
controller
.
resolveObject
(
currentlyPickedBox
.
value
());
auto
resolved
=
controller
.
resolveObject
(
currentlyPickedBox
.
value
());
...
...
This diff is collapsed.
Click to expand it.
src/moveit_sorting_controller.cpp
+
1
−
1
View file @
56ad65b6
...
@@ -164,7 +164,7 @@ int main(int argc, char **argv)
...
@@ -164,7 +164,7 @@ int main(int argc, char **argv)
ROS_WARN_STREAM
(
ROS_WARN_STREAM
(
"Collaboration zone active for unknown robot '"
<<
command
.
evacuate
().
idrobot
()
<<
"', so blocked in all."
);
"Collaboration zone active for unknown robot '"
<<
command
.
evacuate
().
idrobot
()
<<
"', so blocked in all."
);
}
}
controller
.
configureCollaborationZone
(
*
zone
,
command
.
configchange
().
idrobotnewowner
()
!=
controller
.
getRobotName
()
);
controller
.
configureCollaborationZone
(
*
zone
,
command
.
configchange
().
idrobotnewowner
());
}
else
{
}
else
{
ROS_WARN_STREAM
(
"Ignoring command that is not PickAndPlace but "
<<
command
.
msg_case
());
ROS_WARN_STREAM
(
"Ignoring command that is not PickAndPlace but "
<<
command
.
msg_case
());
}
}
...
...
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