Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lennard Hofmann
RobotAPI
Commits
b6aa8bde
Commit
b6aa8bde
authored
8 years ago
by
Mirko Wächter
Browse files
Options
Downloads
Patches
Plain Diff
implemented dynamic lib loading for robotunit
parent
7b48d99f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/RobotAPI/libraries/Controllers/RobotUnit.cpp
+81
-0
81 additions, 0 deletions
source/RobotAPI/libraries/Controllers/RobotUnit.cpp
source/RobotAPI/libraries/Controllers/RobotUnit.h
+7
-9
7 additions, 9 deletions
source/RobotAPI/libraries/Controllers/RobotUnit.h
with
88 additions
and
9 deletions
source/RobotAPI/libraries/Controllers/RobotUnit.cpp
+
81
−
0
View file @
b6aa8bde
...
@@ -22,6 +22,10 @@
...
@@ -22,6 +22,10 @@
#include
"RobotUnit.h"
#include
"RobotUnit.h"
#include
<ArmarXCore/core/system/cmake/CMakePackageFinder.h>
#include
<ArmarXCore/core/system/DynamicLibrary.h>
armarx
::
PropertyDefinitionsPtr
armarx
::
RobotUnit
::
createPropertyDefinitions
()
armarx
::
PropertyDefinitionsPtr
armarx
::
RobotUnit
::
createPropertyDefinitions
()
{
{
return
armarx
::
PropertyDefinitionsPtr
(
new
RobotUnitPropertyDefinitions
(
getConfigIdentifier
()));
return
armarx
::
PropertyDefinitionsPtr
(
new
RobotUnitPropertyDefinitions
(
getConfigIdentifier
()));
...
@@ -311,3 +315,80 @@ bool armarx::RobotUnit::hasLVL0Controller(const std::string& jointName, const st
...
@@ -311,3 +315,80 @@ bool armarx::RobotUnit::hasLVL0Controller(const std::string& jointName, const st
return
lvl0Controllers
.
end
()
!=
lvl0Controllers
.
find
(
jointName
)
&&
return
lvl0Controllers
.
end
()
!=
lvl0Controllers
.
find
(
jointName
)
&&
lvl0Controllers
.
at
(
jointName
).
end
()
!=
lvl0Controllers
.
at
(
jointName
).
find
(
controlMode
);
lvl0Controllers
.
at
(
jointName
).
end
()
!=
lvl0Controllers
.
at
(
jointName
).
find
(
controlMode
);
}
}
bool
armarx
::
RobotUnit
::
loadLibFromAbsolutePath
(
const
std
::
string
&
path
)
{
if
(
loadedLibs
.
count
(
path
)
>
0
)
{
return
true
;
}
DynamicLibraryPtr
lib
(
new
DynamicLibrary
());
try
{
lib
->
load
(
path
);
}
catch
(...)
{
handleExceptions
();
return
false
;
}
if
(
lib
->
isLibraryLoaded
())
{
loadedLibs
[
path
]
=
lib
;
}
else
{
ARMARX_ERROR
<<
"Could not load lib "
+
path
+
": "
+
lib
->
getErrorMessage
();
return
false
;
}
return
true
;
}
bool
armarx
::
RobotUnit
::
loadLibFromPath
(
const
std
::
string
&
path
,
const
Ice
::
Current
&
)
{
std
::
string
absPath
;
if
(
ArmarXDataPath
::
getAbsolutePath
(
path
,
absPath
))
{
return
loadLibFromAbsolutePath
(
absPath
);
}
else
{
ARMARX_ERROR
<<
"Could not find library "
+
path
;
return
false
;
}
}
bool
armarx
::
RobotUnit
::
loadLibFromPackage
(
const
std
::
string
&
package
,
const
std
::
string
&
name
,
const
Ice
::
Current
&
)
{
CMakePackageFinder
finder
(
package
);
if
(
!
finder
.
packageFound
())
{
ARMARX_ERROR
<<
"Could not find package '"
<<
package
<<
"'"
;
return
false
;
}
for
(
auto
libDirPath
:
armarx
::
Split
(
finder
.
getLibraryPaths
(),
";"
))
{
boost
::
filesystem
::
path
fullPath
=
libDirPath
;
fullPath
/=
"lib"
+
name
+
"."
+
DynamicLibrary
::
GetSharedLibraryFileExtension
();
if
(
!
boost
::
filesystem
::
exists
(
fullPath
))
{
fullPath
=
libDirPath
;
fullPath
/=
name
;
if
(
!
boost
::
filesystem
::
exists
(
fullPath
))
{
continue
;
}
}
if
(
loadLibFromAbsolutePath
(
fullPath
.
string
()))
{
return
true
;
}
}
ARMARX_ERROR
<<
"Could not find library "
<<
name
<<
" in package "
<<
package
;
return
false
;
}
This diff is collapsed.
Click to expand it.
source/RobotAPI/libraries/Controllers/RobotUnit.h
+
7
−
9
View file @
b6aa8bde
...
@@ -47,6 +47,8 @@
...
@@ -47,6 +47,8 @@
namespace
armarx
namespace
armarx
{
{
class
DynamicLibrary
;
typedef
boost
::
shared_ptr
<
DynamicLibrary
>
DynamicLibraryPtr
;
/**
/**
* @class RobotUnitPropertyDefinitions
* @class RobotUnitPropertyDefinitions
* @brief
* @brief
...
@@ -98,14 +100,8 @@ namespace armarx
...
@@ -98,14 +100,8 @@ namespace armarx
//loading and switching
//loading and switching
virtual
void
switchSetup
(
const
Ice
::
StringSeq
&
controllerRequestedNames
,
const
Ice
::
Current
&
=
GlobalIceCurrent
)
override
;
virtual
void
switchSetup
(
const
Ice
::
StringSeq
&
controllerRequestedNames
,
const
Ice
::
Current
&
=
GlobalIceCurrent
)
override
;
virtual
LVL1ControllerInterfacePrx
loadController
(
const
std
::
string
&
className
,
const
std
::
string
&
instanceName
,
const
LVL1ControllerConfigPtr
&
config
,
const
Ice
::
Current
&
=
GlobalIceCurrent
)
override
;
virtual
LVL1ControllerInterfacePrx
loadController
(
const
std
::
string
&
className
,
const
std
::
string
&
instanceName
,
const
LVL1ControllerConfigPtr
&
config
,
const
Ice
::
Current
&
=
GlobalIceCurrent
)
override
;
virtual
bool
loadLibFromPath
(
const
std
::
string
&
path
,
const
Ice
::
Current
&
=
GlobalIceCurrent
)
const
override
virtual
bool
loadLibFromPath
(
const
std
::
string
&
path
,
const
Ice
::
Current
&
=
GlobalIceCurrent
)
override
;
{
virtual
bool
loadLibFromPackage
(
const
std
::
string
&
package
,
const
std
::
string
&
lib
,
const
Ice
::
Current
&
=
GlobalIceCurrent
)
override
;
throw
"NYI"
;
/*TODO mirko*/
}
virtual
bool
loadLibFromPackage
(
const
std
::
string
&
package
,
const
std
::
string
&
lib
,
const
Ice
::
Current
&
=
GlobalIceCurrent
)
const
override
{
throw
"NYI"
;
/*TODO mirko*/
}
//units (ice)
//units (ice)
virtual
KinematicUnitInterfacePrx
getKinematicUnit
(
const
Ice
::
Current
&
=
GlobalIceCurrent
)
const
=
0
;
virtual
KinematicUnitInterfacePrx
getKinematicUnit
(
const
Ice
::
Current
&
=
GlobalIceCurrent
)
const
=
0
;
...
@@ -161,8 +157,10 @@ namespace armarx
...
@@ -161,8 +157,10 @@ namespace armarx
* May not be accessed in rt.
* May not be accessed in rt.
*/
*/
std
::
map
<
std
::
string
,
LVL1ControllerPtr
>
lvl1Controllers
;
std
::
map
<
std
::
string
,
LVL1ControllerPtr
>
lvl1Controllers
;
std
::
map
<
std
::
string
,
DynamicLibraryPtr
>
loadedLibs
;
private
:
private
:
bool
loadLibFromAbsolutePath
(
const
std
::
string
&
path
);
JointNameToControlModeDictionary
jointsUsedByLVL1Controler
;
JointNameToControlModeDictionary
jointsUsedByLVL1Controler
;
};
};
...
...
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