Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
multi_cell_builder
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
Matteo Anedda
multi_cell_builder
Commits
f64b0bbb
Commit
f64b0bbb
authored
2 years ago
by
KingMaZito
Browse files
Options
Downloads
Patches
Plain Diff
some mutex changed
parent
bc0471c5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mediator/mg_mediator.cpp
+62
-34
62 additions, 34 deletions
src/mediator/mg_mediator.cpp
with
62 additions
and
34 deletions
src/mediator/mg_mediator.cpp
+
62
−
34
View file @
f64b0bbb
...
@@ -32,6 +32,31 @@ void MGMediator::processSharedStructure() {
...
@@ -32,6 +32,31 @@ void MGMediator::processSharedStructure() {
ss
<<
it
->
first
<<
"/idle"
;
ss
<<
it
->
first
<<
"/idle"
;
sendToAll
(
ss
.
str
(),
""
);
sendToAll
(
ss
.
str
(),
""
);
/*
Lets publish also scene modifications here
But I want to publish only vanished objects
TODO: Implement your own stage, so you don't have to do this embarrassing loops
*/
std
::
string
temp
;
if
((
cuboid_reader_
->
cuboidBox
().
size
()
+
cuboid_reader_
->
cuboidBox
().
size
())
>
psi_
->
getObjects
().
size
()){
ROS_INFO
(
"object is vanished!"
);
try
{
for
(
const
auto
&
c
:
cuboid_reader_
->
cuboidBox
()){
temp
=
c
.
Name
;
psi_
->
getObjects
().
at
(
c
.
Name
);
}
}
catch
(
const
std
::
out_of_range
&
e
)
{
std
::
stringstream
payload
;
payload
<<
"{
\"
type
\"
:
\"
MODIFY
\"
,
\"
mode
\"
:
\"
DELETE
\"
,
\"
robot
\"
:
\"
"
<<
it
->
first
<<
"
\"
,
\"
object
\"
:
\"
"
<<
temp
<<
"
\"
}"
;
std
::
stringstream
payload_topic
;
payload_topic
<<
it
->
first
<<
"/payload"
;
sendToAll
(
payload_topic
.
str
(),
payload
.
str
());
}
}
it
=
shared_structure
.
erase
(
it
);
it
=
shared_structure
.
erase
(
it
);
--
it
;
// Adjust the iterator after erasing
--
it
;
// Adjust the iterator after erasing
}
}
...
@@ -155,6 +180,9 @@ void MGMediator::setupMqtt(){
...
@@ -155,6 +180,9 @@ void MGMediator::setupMqtt(){
}
catch
(
const
YAML
::
RepresentationException
&
e
){
ROS_INFO
(
"Bad Command"
);
return
;}
}
catch
(
const
YAML
::
RepresentationException
&
e
){
ROS_INFO
(
"Bad Command"
);
return
;}
if
(
node
[
"mode"
].
as
<
std
::
string
>
()
==
"PICKUP"
){
if
(
node
[
"mode"
].
as
<
std
::
string
>
()
==
"PICKUP"
){
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
shared_mutex
);
moveit
::
task_constructor
::
Task
mgt
=
pickUp
(
node
[
"object"
].
as
<
std
::
string
>
(),
node
[
"robot"
].
as
<
std
::
string
>
());
moveit
::
task_constructor
::
Task
mgt
=
pickUp
(
node
[
"object"
].
as
<
std
::
string
>
(),
node
[
"robot"
].
as
<
std
::
string
>
());
if
(
mgt
.
plan
(
1
))
{
if
(
mgt
.
plan
(
1
))
{
//mgt.introspection().publishSolution(*mgt.solutions().front());
//mgt.introspection().publishSolution(*mgt.solutions().front());
...
@@ -162,49 +190,49 @@ void MGMediator::setupMqtt(){
...
@@ -162,49 +190,49 @@ void MGMediator::setupMqtt(){
moveit_task_constructor_msgs
::
ExecuteTaskSolutionGoal
e
;
moveit_task_constructor_msgs
::
ExecuteTaskSolutionGoal
e
;
mgt
.
solutions
().
front
()
->
fillMessage
(
e
.
solution
,
&
mgt
.
introspection
());
mgt
.
solutions
().
front
()
->
fillMessage
(
e
.
solution
,
&
mgt
.
introspection
());
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
shared_mutex
);
shared_structure
.
push_back
(
std
::
make_pair
(
node
[
"robot"
].
as
<
std
::
string
>
(),
std
::
move
(
e
)));
shared_structure
.
push_back
(
std
::
make_pair
(
node
[
"robot"
].
as
<
std
::
string
>
(),
std
::
move
(
e
)));
}
// Notify the consuming thread
// Notify the consuming thread
cv
.
notify_one
();
cv
.
notify_one
();
}
}
}
}
}
if
(
node
[
"mode"
].
as
<
std
::
string
>
()
==
"PLACE"
){
if
(
node
[
"mode"
].
as
<
std
::
string
>
()
==
"PLACE"
){
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
shared_mutex
);
moveit
::
task_constructor
::
Task
mgt
=
place
(
node
[
"object"
].
as
<
std
::
string
>
(),
node
[
"robot"
].
as
<
std
::
string
>
(),
node
[
"place"
].
as
<
std
::
string
>
());
moveit
::
task_constructor
::
Task
mgt
=
place
(
node
[
"object"
].
as
<
std
::
string
>
(),
node
[
"robot"
].
as
<
std
::
string
>
(),
node
[
"place"
].
as
<
std
::
string
>
());
if
(
mgt
.
plan
(
1
))
{
if
(
mgt
.
plan
(
1
))
{
//mgt.introspection().publishSolution(*mgt.solutions().front());
//mgt.introspection().publishSolution(*mgt.solutions().front());
moveit_task_constructor_msgs
::
ExecuteTaskSolutionGoal
e
;
moveit_task_constructor_msgs
::
ExecuteTaskSolutionGoal
e
;
mgt
.
solutions
().
front
()
->
fillMessage
(
e
.
solution
,
&
mgt
.
introspection
());
mgt
.
solutions
().
front
()
->
fillMessage
(
e
.
solution
,
&
mgt
.
introspection
());
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
shared_mutex
);
shared_structure
.
push_back
(
std
::
make_pair
(
node
[
"robot"
].
as
<
std
::
string
>
(),
std
::
move
(
e
)));
shared_structure
.
push_back
(
std
::
make_pair
(
node
[
"robot"
].
as
<
std
::
string
>
(),
std
::
move
(
e
)));
}
// Notify the consuming thread
// Notify the consuming thread
cv
.
notify_one
();
cv
.
notify_one
();
}
}
}
}
}
if
(
node
[
"mode"
].
as
<
std
::
string
>
()
==
"DROP"
){
if
(
node
[
"mode"
].
as
<
std
::
string
>
()
==
"DROP"
){
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
shared_mutex
);
moveit
::
task_constructor
::
Task
mgt
=
drop
(
node
[
"object"
].
as
<
std
::
string
>
(),
node
[
"robot"
].
as
<
std
::
string
>
(),
node
[
"drop"
].
as
<
std
::
string
>
());
moveit
::
task_constructor
::
Task
mgt
=
drop
(
node
[
"object"
].
as
<
std
::
string
>
(),
node
[
"robot"
].
as
<
std
::
string
>
(),
node
[
"drop"
].
as
<
std
::
string
>
());
if
(
mgt
.
plan
(
1
))
{
if
(
mgt
.
plan
(
1
))
{
//mgt.introspection().publishSolution(*mgt.solutions().front());
//mgt.introspection().publishSolution(*mgt.solutions().front());
moveit_task_constructor_msgs
::
ExecuteTaskSolutionGoal
e
;
moveit_task_constructor_msgs
::
ExecuteTaskSolutionGoal
e
;
mgt
.
solutions
().
front
()
->
fillMessage
(
e
.
solution
,
&
mgt
.
introspection
());
mgt
.
solutions
().
front
()
->
fillMessage
(
e
.
solution
,
&
mgt
.
introspection
());
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
shared_mutex
);
shared_structure
.
push_back
(
std
::
make_pair
(
node
[
"robot"
].
as
<
std
::
string
>
(),
std
::
move
(
e
)));
shared_structure
.
push_back
(
std
::
make_pair
(
node
[
"robot"
].
as
<
std
::
string
>
(),
std
::
move
(
e
)));
}
// Notify the consuming thread
// Notify the consuming thread
cv
.
notify_one
();
cv
.
notify_one
();
}
}
}
}
}
});
});
}
}
...
...
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