Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guilhem Saurel
hpp-gui
Commits
0ebf366b
Commit
0ebf366b
authored
Nov 29, 2018
by
Joseph Mirabel
Browse files
Make widgets thread safe.
parent
602a1433
Changes
5
Hide whitespace changes
Inline
Side-by-side
plugins/hppwidgetsplugin/configurationlistwidget.cc
View file @
0ebf366b
...
...
@@ -75,8 +75,8 @@ namespace hpp {
void
ConfigurationListWidget
::
onSaveClicked
()
{
hpp
::
floatSeq
_var
c
=
plugin_
->
client
()
->
robot
()
->
getCurrentConfig
();
list
()
->
addItem
(
makeItem
(
name
()
->
text
(),
c
.
in
()
));
hpp
::
floatSeq
const
*
c
=
plugin_
->
getCurrentConfig
();
list
()
->
addItem
(
makeItem
(
name
()
->
text
(),
*
c
));
name
()
->
setText
(
basename_
+
QString
::
number
(
count_
));
count_
++
;
}
...
...
@@ -85,8 +85,7 @@ namespace hpp {
{
if
(
current
!=
0
)
{
const
hpp
::
floatSeq
&
c
=
getConfig
(
current
);
plugin_
->
client
()
->
robot
()
->
setCurrentConfig
(
c
);
main_
->
requestApplyCurrentConfiguration
();
plugin_
->
setCurrentConfig
(
c
);
if
(
previous_
&&
previous_
!=
current
->
listWidget
())
{
previous_
->
clearSelection
();
...
...
plugins/hppwidgetsplugin/hppwidgetsplugin.cc
View file @
0ebf366b
...
...
@@ -216,6 +216,7 @@ namespace hpp {
void
HppWidgetsPlugin
::
setCurrentConfig
(
const
hpp
::
floatSeq
&
q
)
{
config_
=
q
;
MainWindow
::
instance
()
->
requestApplyCurrentConfiguration
();
}
hpp
::
floatSeq
const
*
HppWidgetsPlugin
::
getCurrentConfig
()
const
...
...
@@ -317,8 +318,6 @@ namespace hpp {
"interface) and you did not refresh this GUI. "
"Use the refresh button
\"
Tools
\"
menu."
);
}
// Something smarter could be done here.
// For instance, the joint tree item could know the NodePtr_t of their bodies.
hpp
::
TransformSeq_var
Ts
=
client
()
->
robot
()
->
getLinksPosition
(
config_
,
linkNames_
);
fromHPP
(
Ts
,
bodyConfs_
);
main
->
osg
()
->
applyConfigurations
(
bodyNames_
,
bodyConfs_
);
...
...
@@ -330,8 +329,6 @@ namespace hpp {
ite
->
item
->
updateFromRobotConfig
(
config_
);
}
}
// for (std::list<std::string>::const_iterator it = jointFrames_.begin ();
// it != jointFrames_.end (); ++it) {
Ts
=
client
()
->
robot
()
->
getJointsPosition
(
config_
,
jointFrames_
);
fromHPP
(
Ts
,
bodyConfs_
);
main
->
osg
()
->
applyConfigurations
(
jointGroupNames_
,
bodyConfs_
);
...
...
@@ -414,8 +411,7 @@ namespace hpp {
if
(
type
==
"node"
)
{
try
{
hpp
::
floatSeq_var
q
=
hpp_
->
problem
()
->
node
(
n
);
hpp_
->
robot
()
->
setCurrentConfig
(
q
.
in
());
gepetto
::
gui
::
MainWindow
::
instance
()
->
requestApplyCurrentConfiguration
();
setCurrentConfig
(
q
.
in
());
}
catch
(
const
hpp
::
Error
&
e
)
{
emit
logFailure
(
QString
::
fromLocal8Bit
(
e
.
msg
));
}
...
...
@@ -429,8 +425,7 @@ namespace hpp {
hpp
::
floatSeq_var
times
;
hpp
::
floatSeqSeq_var
waypoints
=
hpp_
->
problem
()
->
getWaypoints
((
CORBA
::
UShort
)
pid
,
times
.
out
());
if
(
n
<
waypoints
->
length
())
{
hpp_
->
robot
()
->
setCurrentConfig
(
waypoints
[
n
]);
MainWindow
::
instance
()
->
requestApplyCurrentConfiguration
();
setCurrentConfig
(
waypoints
[
n
]);
}
}
}
...
...
plugins/hppwidgetsplugin/pathplayer.cc
View file @
0ebf366b
...
...
@@ -88,7 +88,10 @@ namespace hpp {
wsm
->
createGroup
(
pn
);
wsm
->
addToGroup
(
pn
,
"hpp-gui"
);
}
hpp
::
floatSeq_var
curCfg
=
hpp
->
robot
()
->
getCurrentConfig
();
// Temporary object to avoid dynamic allocation.
// Arguments are max, length, storage, take ownership.
char
*
tmps
[
1
];
hpp
::
Names_t
names
(
1
,
1
,
tmps
,
false
);
graphics
::
Configuration
pos
;
osgVector3
pos1
,
pos2
;
for
(
unsigned
int
i
=
0
;
i
<
waypoints
->
length
();
++
i
)
{
...
...
@@ -96,9 +99,9 @@ namespace hpp {
ss
.
clear
();
ss
.
str
(
std
::
string
());
ss
<<
pn
<<
"/node"
<<
i
;
std
::
string
xyzName
=
ss
.
str
();
// Get positions
hpp
->
robot
()
->
setCurrentConfig
(
waypoints
[
i
]
);
hpp
::
Transform
_
_var
t
=
hpp
->
robot
()
->
getJointPosition
(
jointName
.
c_str
()
);
fromHPP
(
t
,
pos
);
names
[
0
]
=
jointName
.
c_str
(
);
hpp
::
Transform
Seq
_var
Ts
=
hpp
->
robot
()
->
getJoint
s
Position
(
waypoints
[
i
],
names
);
fromHPP
(
Ts
[
0
]
,
pos
);
pos1
=
pos2
;
pos2
=
pos
.
position
;
// Create the nodes
if
(
wsm
->
nodeExists
(
xyzName
))
wsm
->
deleteNode
(
xyzName
,
false
);
...
...
@@ -111,7 +114,6 @@ namespace hpp {
wsm
->
addLine
(
xyzName
,
pos1
,
pos2
,
colorE
);
}
}
hpp
->
robot
()
->
setCurrentConfig
(
curCfg
.
in
());
wsm
->
refresh
();
}
...
...
@@ -142,25 +144,28 @@ namespace hpp {
graphics
::
WindowsManager
::
Color_t
colorE
(
1.
f
,
0.
f
,
0.
f
,
1.
f
);
gepetto
::
gui
::
WindowsManagerPtr_t
wsm
=
main
->
osg
();
HppWidgetsPlugin
::
HppClient
*
hpp
=
plugin_
->
client
();
hpp
::
floatSeq_var
curCfg
=
hpp
->
robot
()
->
getCurrentConfig
();
CORBA
::
Double
length
=
hpp
->
problem
()
->
pathLength
(
pid
);
double
dt
=
lengthBetweenRefresh
();
CORBA
::
ULong
nbPos
=
(
CORBA
::
ULong
)(
length
/
dt
)
+
1
;
osgVector3
pos
;
::
osg
::
Vec3ArrayRefPtr
posSeq
=
new
::
osg
::
Vec3Array
;
// Temporary object to avoid dynamic allocation.
// Arguments are max, length, storage, take ownership.
char
*
tmps
[
1
];
hpp
::
Names_t
names
(
1
,
1
,
tmps
,
false
);
float
statusStep
=
100.
f
/
(
float
)
nbPos
;
emit
displayPath_status
(
0
);
for
(
CORBA
::
ULong
i
=
0
;
i
<
nbPos
;
++
i
)
{
double
t
=
std
::
min
(
i
*
dt
,
length
);
hpp
::
floatSeq_var
q
=
hpp
->
problem
()
->
configAtParam
(
pid
,
t
);
hpp
->
robot
()
->
setCurrentConfig
(
q
);
hpp
::
Transform
_
_var
transform
=
hpp
->
robot
()
->
getJointPosition
(
jointName
.
c_str
()
);
const
hpp
::
Transform__slice
*
tt
=
transform
.
in
(
);
posSeq
->
push_back
(
::
osg
::
Vec3
((
float
)
tt
[
0
],(
float
)
tt
[
1
],(
float
)
tt
[
2
])
);
names
[
0
]
=
jointName
.
c_str
(
);
hpp
::
Transform
Seq
_var
Ts
=
hpp
->
robot
()
->
getJoint
s
Position
(
q
.
in
(),
names
);
fromHPP
(
Ts
[
0
],
pos
);
posSeq
->
push_back
(
pos
);
emit
displayPath_status
(
qFloor
((
float
)
i
*
statusStep
));
}
if
(
wsm
->
nodeExists
(
pn
))
wsm
->
deleteNode
(
pn
,
true
);
wsm
->
addCurve
(
pn
,
posSeq
,
colorE
);
hpp
->
robot
()
->
setCurrentConfig
(
curCfg
.
in
());
wsm
->
addToGroup
(
pn
.
c_str
(),
"hpp-gui"
);
wsm
->
refresh
();
emit
displayPath_status
(
100
);
...
...
plugins/hppwidgetsplugin/roadmap.cc
View file @
0ebf366b
...
...
@@ -91,12 +91,10 @@ namespace hpp {
void
Roadmap
::
beforeDisplay
()
{
config_
=
plugin_
->
client
()
->
robot
()
->
getCurrentConfig
();
}
void
Roadmap
::
afterDisplay
()
{
plugin_
->
client
()
->
robot
()
->
setCurrentConfig
(
config_
.
in
());
}
std
::
size_t
Roadmap
::
numberNodes
()
...
...
@@ -132,23 +130,19 @@ namespace hpp {
{
HppWidgetsPlugin
::
HppClient
*
hpp
=
plugin_
->
client
();
hpp
::
floatSeq_var
n
=
hpp
->
problem
()
->
node
(
nodeId
);
hpp
->
robot
()
->
setCurrentConfig
(
n
.
in
());
hpp
::
Transform__var
t
;
getPosition
(
t
);
fromHPP
(
t
,
frame
);
getPosition
(
n
.
in
(),
frame
);
}
void
Roadmap
::
edgePositions
(
EdgeID
edgeId
,
Position
&
start
,
Position
&
end
)
{
HppWidgetsPlugin
::
HppClient
*
hpp
=
plugin_
->
client
();
hpp
::
floatSeq_var
n1
,
n2
;
hpp
::
Transform__var
t
;
Frame
t
;
hpp
->
problem
()
->
edge
(
edgeId
,
n1
.
out
(),
n2
.
out
());
hpp
->
robot
()
->
setCurrentConfig
(
n1
.
in
());
getPosition
(
t
);
fromHPP
(
t
,
start
);
hpp
->
robot
()
->
setCurrentConfig
(
n2
.
in
());
getPosition
(
t
);
fromHPP
(
t
,
end
);
getPosition
(
n1
.
in
(),
t
);
start
=
t
.
position
;
getPosition
(
n2
.
in
(),
t
);
end
=
t
.
position
;
}
void
Roadmap
::
nodeColor
(
NodeID
nodeId
,
Color
&
color
)
...
...
@@ -163,11 +157,18 @@ namespace hpp {
edgeColorMap_
.
getColor
(
iCC
,
color
);
}
inline
void
Roadmap
::
getPosition
(
hpp
::
Transform__var
&
t
)
const
inline
void
Roadmap
::
getPosition
(
const
hpp
::
floatSeq
&
q
,
Frame
&
t
)
const
{
HppWidgetsPlugin
::
HppClient
*
hpp
=
plugin_
->
client
();
if
(
link_
)
t
=
hpp
->
robot
()
->
getLinkPosition
(
name_
.
c_str
());
else
t
=
hpp
->
robot
()
->
getJointPosition
(
name_
.
c_str
());
hpp
::
TransformSeq_var
Ts
;
// Temporary object to avoid dynamic allocation.
// Arguments are max, length, storage, take ownership.
char
*
tmps
[
1
];
hpp
::
Names_t
names
(
1
,
1
,
tmps
,
false
);
names
[
0
]
=
name_
.
c_str
();
if
(
link_
)
Ts
=
hpp
->
robot
()
->
getLinksPosition
(
q
,
names
);
else
Ts
=
hpp
->
robot
()
->
getJointsPosition
(
q
,
names
);
fromHPP
(
Ts
[
0
],
t
);
}
}
// namespace gui
}
// namespace hpp
plugins/hppwidgetsplugin/roadmap.hh
View file @
0ebf366b
...
...
@@ -67,12 +67,11 @@ namespace hpp {
private:
void
initRoadmap
();
inline
void
getPosition
(
hpp
::
Transform__var
&
t
)
const
;
inline
void
getPosition
(
const
hpp
::
floatSeq
&
q
,
Frame
&
t
)
const
;
HppWidgetsPlugin
*
plugin_
;
std
::
string
name_
;
bool
link_
;
hpp
::
floatSeq_var
config_
;
};
}
// namespace gui
}
// namespace hpp
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment