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
Container Registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
RobotAPI
Commits
e455f4f9
Commit
e455f4f9
authored
8 years ago
by
Mirko Wächter
Browse files
Options
Downloads
Patches
Plain Diff
made kinematic platform unit work
parent
bf8826f4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/RobotAPI/components/units/PlatformUnitSimulation.cpp
+89
-38
89 additions, 38 deletions
source/RobotAPI/components/units/PlatformUnitSimulation.cpp
source/RobotAPI/components/units/PlatformUnitSimulation.h
+13
-2
13 additions, 2 deletions
source/RobotAPI/components/units/PlatformUnitSimulation.h
with
102 additions
and
40 deletions
source/RobotAPI/components/units/PlatformUnitSimulation.cpp
+
89
−
38
View file @
e455f4f9
...
@@ -25,20 +25,24 @@
...
@@ -25,20 +25,24 @@
#include
"PlatformUnitSimulation.h"
#include
"PlatformUnitSimulation.h"
#include
<Eigen/Geometry>
#include
<VirtualRobot/MathTools.h>
#include
<cmath>
#include
<cmath>
using
namespace
armarx
;
using
namespace
armarx
;
void
PlatformUnitSimulation
::
onInitPlatformUnit
()
void
PlatformUnitSimulation
::
onInitPlatformUnit
()
{
{
platformMode
=
eUndefined
;
referenceFrame
=
getProperty
<
std
::
string
>
(
"ReferenceFrame"
).
getValue
();
referenceFrame
=
getProperty
<
std
::
string
>
(
"ReferenceFrame"
).
getValue
();
targetPositionX
=
currentPositionX
=
getProperty
<
float
>
(
"InitialPosition.x"
).
getValue
();
targetPositionX
=
currentPositionX
=
getProperty
<
float
>
(
"InitialPosition.x"
).
getValue
();
targetPositionY
=
currentPositionY
=
getProperty
<
float
>
(
"InitialPosition.y"
).
getValue
();
targetPositionY
=
currentPositionY
=
getProperty
<
float
>
(
"InitialPosition.y"
).
getValue
();
targetRotation
=
0.0
;
targetRotation
=
0.0
;
targetRotation
=
currentRotation
=
getProperty
<
float
>
(
"InitialRotation"
).
getValue
();
targetRotation
=
currentRotation
=
getProperty
<
float
>
(
"InitialRotation"
).
getValue
();
l
inearVelocity
=
getProperty
<
float
>
(
"LinearVelocity"
).
getValue
();
maxL
inearVelocity
=
getProperty
<
float
>
(
"LinearVelocity"
).
getValue
();
a
ngularVelocity
=
getProperty
<
float
>
(
"AngularVelocity"
).
getValue
();
maxA
ngularVelocity
=
getProperty
<
float
>
(
"AngularVelocity"
).
getValue
();
positionalAccuracy
=
0.01
;
positionalAccuracy
=
0.01
;
...
@@ -79,44 +83,78 @@ void PlatformUnitSimulation::simulationFunction()
...
@@ -79,44 +83,78 @@ void PlatformUnitSimulation::simulationFunction()
std
::
vector
<
float
>
vel
(
3
,
0.0
f
);
std
::
vector
<
float
>
vel
(
3
,
0.0
f
);
{
{
ScopedLock
lock
(
currentPoseMutex
);
ScopedLock
lock
(
currentPoseMutex
);
float
diff
=
fabs
(
targetPositionX
-
currentPositionX
);
switch
(
platformMode
)
if
(
diff
>
positionalAccuracy
)
{
int
sign
=
copysignf
(
1.0
f
,
(
targetPositionX
-
currentPositionX
));
currentPositionX
+=
sign
*
std
::
min
<
float
>
(
linearVelocity
*
timeDeltaInSeconds
,
diff
);
vel
[
0
]
=
linearVelocity
;
}
diff
=
fabs
(
targetPositionY
-
currentPositionY
);
if
(
diff
>
positionalAccuracy
)
{
int
sign
=
copysignf
(
1.0
f
,
(
targetPositionY
-
currentPositionY
));
currentPositionY
+=
sign
*
std
::
min
<
float
>
(
linearVelocity
*
timeDeltaInSeconds
,
diff
);
vel
[
1
]
=
linearVelocity
;
}
diff
=
fabs
(
targetRotation
-
currentRotation
);
if
(
diff
>
orientationalAccuracy
)
{
{
int
sign
=
copysignf
(
1.0
f
,
(
targetRotation
-
currentRotation
));
case
ePositionControl
:
currentRotation
+=
sign
*
std
::
min
<
float
>
(
angularVelocity
*
timeDeltaInSeconds
,
diff
);
// stay between +/- M_2_PI
if
(
currentRotation
>
2
*
M_PI
)
{
{
currentRotation
-=
2
*
M_PI
;
float
diff
=
fabs
(
targetPositionX
-
currentPositionX
);
ARMARX_INFO
<<
deactivateSpam
(
0.5
)
<<
"Distance to goal X: "
<<
diff
;
if
(
diff
>
positionalAccuracy
)
{
int
sign
=
copysignf
(
1.0
f
,
(
targetPositionX
-
currentPositionX
));
currentPositionX
+=
sign
*
std
::
min
<
float
>
(
maxLinearVelocity
*
timeDeltaInSeconds
,
diff
);
vel
[
0
]
=
linearVelocityX
;
}
diff
=
fabs
(
targetPositionY
-
currentPositionY
);
if
(
diff
>
positionalAccuracy
)
{
int
sign
=
copysignf
(
1.0
f
,
(
targetPositionY
-
currentPositionY
));
currentPositionY
+=
sign
*
std
::
min
<
float
>
(
maxLinearVelocity
*
timeDeltaInSeconds
,
diff
);
vel
[
1
]
=
linearVelocityY
;
}
diff
=
fabs
(
targetRotation
-
currentRotation
);
if
(
diff
>
orientationalAccuracy
)
{
int
sign
=
copysignf
(
1.0
f
,
(
targetRotation
-
currentRotation
));
currentRotation
+=
sign
*
std
::
min
<
float
>
(
maxAngularVelocity
*
timeDeltaInSeconds
,
diff
);
// stay between +/- M_2_PI
if
(
currentRotation
>
2
*
M_PI
)
{
currentRotation
-=
2
*
M_PI
;
}
if
(
currentRotation
<
-
2
*
M_PI
)
{
currentRotation
+=
2
*
M_PI
;
}
vel
[
2
]
=
angularVelocity
;
}
}
}
break
;
if
(
currentRotation
<
-
2
*
M_PI
)
case
eVelocityControl
:
{
{
currentRotation
+=
2
*
M_PI
;
Eigen
::
Vector2f
targetVel
(
linearVelocityX
,
linearVelocityY
);
Eigen
::
Rotation2Df
rot
(
currentRotation
);
targetVel
=
rot
*
targetVel
;
currentPositionX
+=
timeDeltaInSeconds
*
targetVel
[
0
];
currentPositionY
+=
timeDeltaInSeconds
*
targetVel
[
1
];
currentRotation
+=
angularVelocity
*
timeDeltaInSeconds
;
// stay between +/- M_2_PI
if
(
currentRotation
>
2
*
M_PI
)
{
currentRotation
-=
2
*
M_PI
;
}
if
(
currentRotation
<
-
2
*
M_PI
)
{
currentRotation
+=
2
*
M_PI
;
}
vel
[
0
]
=
linearVelocityY
;
vel
[
1
]
=
linearVelocityY
;
vel
[
2
]
=
angularVelocity
;
}
}
break
;
vel
[
2
]
=
angularVelocity
;
default
:
break
;
}
}
}
}
listenerPrx
->
reportPlatformPose
(
currentPositionX
,
currentPositionY
,
currentRotation
);
listenerPrx
->
reportPlatformPose
(
currentPositionX
,
currentPositionY
,
currentRotation
);
...
@@ -125,8 +163,10 @@ void PlatformUnitSimulation::simulationFunction()
...
@@ -125,8 +163,10 @@ void PlatformUnitSimulation::simulationFunction()
void
PlatformUnitSimulation
::
moveTo
(
Ice
::
Float
targetPlatformPositionX
,
Ice
::
Float
targetPlatformPositionY
,
Ice
::
Float
targetPlatformRotation
,
Ice
::
Float
positionalAccuracy
,
Ice
::
Float
orientationalAccuracy
,
const
Ice
::
Current
&
c
)
void
PlatformUnitSimulation
::
moveTo
(
Ice
::
Float
targetPlatformPositionX
,
Ice
::
Float
targetPlatformPositionY
,
Ice
::
Float
targetPlatformRotation
,
Ice
::
Float
positionalAccuracy
,
Ice
::
Float
orientationalAccuracy
,
const
Ice
::
Current
&
c
)
{
{
ARMARX_INFO
<<
"new target pose : "
<<
targetPlatformPositionX
<<
", "
<<
targetPlatformPositionY
<<
" with angle "
<<
targetPlatformRotation
;
{
{
ScopedLock
lock
(
currentPoseMutex
);
ScopedLock
lock
(
currentPoseMutex
);
platformMode
=
ePositionControl
;
targetPositionX
=
targetPlatformPositionX
;
targetPositionX
=
targetPlatformPositionX
;
targetPositionY
=
targetPlatformPositionY
;
targetPositionY
=
targetPlatformPositionY
;
targetRotation
=
targetPlatformRotation
;
targetRotation
=
targetPlatformRotation
;
...
@@ -146,7 +186,13 @@ PropertyDefinitionsPtr PlatformUnitSimulation::createPropertyDefinitions()
...
@@ -146,7 +186,13 @@ PropertyDefinitionsPtr PlatformUnitSimulation::createPropertyDefinitions()
void
armarx
::
PlatformUnitSimulation
::
move
(
float
targetPlatformVelocityX
,
float
targetPlatformVelocityY
,
float
targetPlatformVelocityRotation
,
const
Ice
::
Current
&
c
)
void
armarx
::
PlatformUnitSimulation
::
move
(
float
targetPlatformVelocityX
,
float
targetPlatformVelocityY
,
float
targetPlatformVelocityRotation
,
const
Ice
::
Current
&
c
)
{
{
throw
LocalException
(
"NYI"
);
ARMARX_INFO
<<
deactivateSpam
(
1
)
<<
"New velocity: "
<<
targetPlatformVelocityX
<<
", "
<<
targetPlatformVelocityY
<<
" with angular velocity: "
<<
targetPlatformVelocityRotation
;
ScopedLock
lock
(
currentPoseMutex
);
platformMode
=
eVelocityControl
;
linearVelocityX
=
std
::
min
(
maxLinearVelocity
,
targetPlatformVelocityX
);
linearVelocityY
=
std
::
min
(
maxLinearVelocity
,
targetPlatformVelocityY
);
angularVelocity
=
std
::
min
(
maxAngularVelocity
,
targetPlatformVelocityRotation
);
}
}
void
PlatformUnitSimulation
::
moveRelative
(
float
targetPlatformOffsetX
,
float
targetPlatformOffsetY
,
float
targetPlatformOffsetRotation
,
float
positionalAccuracy
,
float
orientationalAccuracy
,
const
Ice
::
Current
&
c
)
void
PlatformUnitSimulation
::
moveRelative
(
float
targetPlatformOffsetX
,
float
targetPlatformOffsetY
,
float
targetPlatformOffsetRotation
,
float
positionalAccuracy
,
float
orientationalAccuracy
,
const
Ice
::
Current
&
c
)
...
@@ -164,7 +210,12 @@ void PlatformUnitSimulation::moveRelative(float targetPlatformOffsetX, float tar
...
@@ -164,7 +210,12 @@ void PlatformUnitSimulation::moveRelative(float targetPlatformOffsetX, float tar
void
PlatformUnitSimulation
::
setMaxVelocities
(
float
positionalVelocity
,
float
orientaionalVelocity
,
const
Ice
::
Current
&
c
)
void
PlatformUnitSimulation
::
setMaxVelocities
(
float
positionalVelocity
,
float
orientaionalVelocity
,
const
Ice
::
Current
&
c
)
{
{
ScopedLock
lock
(
currentPoseMutex
);
ScopedLock
lock
(
currentPoseMutex
);
linearVelocity
=
positionalVelocity
;
maxLinearVelocity
=
positionalVelocity
;
angularVelocity
=
orientaionalVelocity
;
maxAngularVelocity
=
orientaionalVelocity
;
}
void
PlatformUnitSimulation
::
stopPlatform
(
const
Ice
::
Current
&
c
)
{
move
(
0
,
0
,
0
);
}
}
This diff is collapsed.
Click to expand it.
source/RobotAPI/components/units/PlatformUnitSimulation.h
+
13
−
2
View file @
e455f4f9
...
@@ -89,7 +89,7 @@ namespace armarx
...
@@ -89,7 +89,7 @@ namespace armarx
void
moveRelative
(
float
targetPlatformOffsetX
,
float
targetPlatformOffsetY
,
float
targetPlatformOffsetRotation
,
float
positionalAccuracy
,
float
orientationalAccuracy
,
const
Ice
::
Current
&
c
=
Ice
::
Current
());
void
moveRelative
(
float
targetPlatformOffsetX
,
float
targetPlatformOffsetY
,
float
targetPlatformOffsetRotation
,
float
positionalAccuracy
,
float
orientationalAccuracy
,
const
Ice
::
Current
&
c
=
Ice
::
Current
());
void
setMaxVelocities
(
float
positionalVelocity
,
float
orientaionalVelocity
,
const
Ice
::
Current
&
c
=
Ice
::
Current
());
void
setMaxVelocities
(
float
positionalVelocity
,
float
orientaionalVelocity
,
const
Ice
::
Current
&
c
=
Ice
::
Current
());
void
stopPlatform
(
const
Ice
::
Current
&
c
=
Ice
::
Current
());
/**
/**
* \see PropertyUser::createPropertyDefinitions()
* \see PropertyUser::createPropertyDefinitions()
*/
*/
...
@@ -100,6 +100,14 @@ namespace armarx
...
@@ -100,6 +100,14 @@ namespace armarx
IceUtil
::
Time
lastExecutionTime
;
IceUtil
::
Time
lastExecutionTime
;
int
intervalMs
;
int
intervalMs
;
enum
PlatformMode
{
eUndefined
,
ePositionControl
,
eVelocityControl
}
platformMode
;
::
Ice
::
Float
targetPositionX
;
::
Ice
::
Float
targetPositionX
;
::
Ice
::
Float
targetPositionY
;
::
Ice
::
Float
targetPositionY
;
::
Ice
::
Float
currentPositionX
;
::
Ice
::
Float
currentPositionX
;
...
@@ -107,8 +115,11 @@ namespace armarx
...
@@ -107,8 +115,11 @@ namespace armarx
::
Ice
::
Float
targetRotation
;
::
Ice
::
Float
targetRotation
;
::
Ice
::
Float
currentRotation
;
::
Ice
::
Float
currentRotation
;
::
Ice
::
Float
linearVelocity
;
::
Ice
::
Float
linearVelocityX
;
::
Ice
::
Float
linearVelocityY
;
::
Ice
::
Float
maxLinearVelocity
;
::
Ice
::
Float
angularVelocity
;
::
Ice
::
Float
angularVelocity
;
::
Ice
::
Float
maxAngularVelocity
;
::
Ice
::
Float
positionalAccuracy
;
::
Ice
::
Float
positionalAccuracy
;
::
Ice
::
Float
orientationalAccuracy
;
::
Ice
::
Float
orientationalAccuracy
;
...
...
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