Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Simox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Florian Leander Singer
Simox
Commits
5943a74a
Commit
5943a74a
authored
2 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Add debug code
parent
c0fa3347
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
VirtualRobot/Nodes/HemisphereJoint/operations.cpp
+7
-1
7 additions, 1 deletion
VirtualRobot/Nodes/HemisphereJoint/operations.cpp
VirtualRobot/examples/HemisphereJoint/main.cpp
+67
-44
67 additions, 44 deletions
VirtualRobot/examples/HemisphereJoint/main.cpp
with
74 additions
and
45 deletions
VirtualRobot/Nodes/HemisphereJoint/operations.cpp
+
7
−
1
View file @
5943a74a
...
...
@@ -6,9 +6,14 @@ namespace VirtualRobot
Eigen
::
Vector3d
hemisphere
::
getEndEffectorPosition
(
const
Expressions
&
expr
)
{
return
Eigen
::
Vector3d
{
expr
.
ex
,
expr
.
ey
,
expr
.
ez
};
return
Eigen
::
Vector3d
{
expr
.
ex
,
expr
.
ey
,
expr
.
ez
};
}
Eigen
::
Matrix3d
hemisphere
::
getEndEffectorOrientation
(
const
Expressions
&
expr
)
{
// r_wrist_to_base = np.array([[exx, eyx, ezx], [exy, eyy, ezy], [exz, eyz, ezz]])
...
...
@@ -19,6 +24,7 @@ namespace VirtualRobot
return
ori
;
}
Eigen
::
Matrix
<
double
,
6
,
2
>
hemisphere
::
getJacobian
(
const
Expressions
&
expr
)
{
Eigen
::
Matrix
<
double
,
6
,
2
>
jacobian
;
...
...
This diff is collapsed.
Click to expand it.
VirtualRobot/examples/HemisphereJoint/main.cpp
+
67
−
44
View file @
5943a74a
...
...
@@ -18,10 +18,14 @@ using VirtualRobot::RuntimeEnvironment;
*/
int
main
(
int
argc
,
char
*
argv
[])
{
const
Eigen
::
IOFormat
iof
(
5
,
0
,
" "
,
"
\n
"
,
" ["
,
"]"
,
""
,
""
);
RuntimeEnvironment
::
setCaption
(
"Convert .iv to .wrl files"
);
RuntimeEnvironment
::
considerFlag
(
"verbose"
,
"Enable verbose output."
);
RuntimeEnvironment
::
considerFlag
(
"debug"
,
"Branch to debug code."
);
RuntimeEnvironment
::
processCommandLine
(
argc
,
argv
);
...
...
@@ -35,66 +39,85 @@ int main(int argc, char* argv[])
}
const
bool
verbose
=
RuntimeEnvironment
::
hasFlag
(
"verbose"
);
const
bool
debug
=
RuntimeEnvironment
::
hasFlag
(
"debug"
);
const
double
lever
=
1
,
theta0
=
simox
::
math
::
deg_to_rad
(
25.
);
std
::
cout
<<
"(lever, theta0) = ("
<<
lever
<<
", "
<<
theta0
<<
") "
<<
std
::
endl
;
std
::
vector
<
double
>
a1s
,
a2s
;
int
num
=
100
;
double
aMin
=
-
0.7
,
aMax
=
0.7
;
for
(
int
i
=
0
;
i
<
num
;
++
i
)
{
double
value
=
simox
::
math
::
rescale
(
double
(
i
),
double
(
0
),
double
(
num
),
aMin
,
aMax
);
a1s
.
push_back
(
value
);
a2s
.
push_back
(
value
);
}
using
time_point
=
std
::
chrono
::
system_clock
::
time_point
;
std
::
vector
<
double
>
durationsUs
;
durationsUs
.
reserve
(
a1s
.
size
()
*
a2s
.
size
());
for
(
double
a1
:
a1s
)
if
(
not
debug
)
{
for
(
double
a2
:
a2s
)
std
::
vector
<
double
>
a1s
,
a2s
;
int
num
=
100
;
double
aMin
=
-
0.7
,
aMax
=
0.7
;
for
(
int
i
=
0
;
i
<
num
;
++
i
)
{
const
time_point
start
=
std
::
chrono
::
system_clock
::
now
();
double
value
=
simox
::
math
::
rescale
(
double
(
i
),
double
(
0
),
double
(
num
),
aMin
,
aMax
);
a1s
.
push_back
(
value
);
a2s
.
push_back
(
value
);
}
VirtualRobot
::
hemisphere
::
Expressions
expr
;
expr
.
compute
(
a1
,
a2
,
lever
,
theta0
);
const
Eigen
::
Vector3d
pos
=
VirtualRobot
::
hemisphere
::
getEndEffectorPosition
(
expr
);
const
Eigen
::
Matrix3d
ori
=
VirtualRobot
::
hemisphere
::
getEndEffectorOrientation
(
expr
);
const
Eigen
::
Matrix
<
double
,
6
,
2
>
jacobian
=
VirtualRobot
::
hemisphere
::
getJacobian
(
expr
);
using
time_point
=
std
::
chrono
::
system_clock
::
time_point
;
const
time_point
end
=
std
::
chrono
::
system_clock
::
now
();
using
duration
=
std
::
chrono
::
nanoseconds
;
durationsUs
.
push_back
(
std
::
chrono
::
duration_cast
<
duration
>
(
end
-
start
).
count
()
/
1000.
f
);
std
::
vector
<
double
>
durationsUs
;
durationsUs
.
reserve
(
a1s
.
size
()
*
a2s
.
size
());
if
(
verbose
)
for
(
double
a1
:
a1s
)
{
for
(
double
a2
:
a2s
)
{
Eigen
::
IOFormat
iof
(
5
,
0
,
" "
,
"
\n
"
,
" ["
,
"]"
,
""
,
""
);
std
::
cout
<<
"(a1, a2) = ("
<<
a1
<<
", "
<<
a2
<<
")"
<<
"
\n
->"
<<
"
\n
pos =
\n
"
<<
pos
.
transpose
().
format
(
iof
)
<<
"
\n
ori =
\n
"
<<
ori
.
format
(
iof
)
<<
"
\n
jac =
\n
"
<<
jacobian
.
format
(
iof
)
<<
std
::
endl
;
const
time_point
start
=
std
::
chrono
::
system_clock
::
now
();
VirtualRobot
::
hemisphere
::
Expressions
expr
;
expr
.
compute
(
a1
,
a2
,
lever
,
theta0
);
const
Eigen
::
Vector3d
pos
=
VirtualRobot
::
hemisphere
::
getEndEffectorPosition
(
expr
);
const
Eigen
::
Matrix3d
ori
=
VirtualRobot
::
hemisphere
::
getEndEffectorOrientation
(
expr
);
const
Eigen
::
Matrix
<
double
,
6
,
2
>
jacobian
=
VirtualRobot
::
hemisphere
::
getJacobian
(
expr
);
const
time_point
end
=
std
::
chrono
::
system_clock
::
now
();
using
duration
=
std
::
chrono
::
nanoseconds
;
durationsUs
.
push_back
(
std
::
chrono
::
duration_cast
<
duration
>
(
end
-
start
).
count
()
/
1000.
f
);
if
(
verbose
)
{
std
::
cout
<<
"(a1, a2) = ("
<<
a1
<<
", "
<<
a2
<<
")"
<<
"
\n
->"
<<
"
\n
pos =
\n
"
<<
pos
.
transpose
().
format
(
iof
)
<<
"
\n
ori =
\n
"
<<
ori
.
format
(
iof
)
<<
"
\n
jac =
\n
"
<<
jacobian
.
format
(
iof
)
<<
std
::
endl
;
}
}
}
double
mean
=
simox
::
math
::
mean
(
durationsUs
);
double
stddev
=
simox
::
math
::
stddev
(
durationsUs
,
mean
);
double
min
=
simox
::
math
::
min
(
durationsUs
);
double
max
=
simox
::
math
::
max
(
durationsUs
);
const
std
::
string
unit
=
" us"
;
std
::
cout
<<
"Durations:"
<<
" "
<<
mean
<<
" +- "
<<
stddev
<<
unit
<<
", range: ["
<<
min
<<
unit
<<
" to "
<<
max
<<
unit
<<
"]"
<<
std
::
endl
;
}
else
{
double
offset
=
std
::
asin
(
theta0
);
double
a1
=
0
,
a2
=
0
;
a1
+=
offset
;
a2
+=
offset
;
double
mean
=
simox
::
math
::
mean
(
durationsUs
);
double
stddev
=
simox
::
math
::
stddev
(
durationsUs
,
mean
);
double
min
=
simox
::
math
::
min
(
durationsUs
);
double
max
=
simox
::
math
::
max
(
durationsUs
);
VirtualRobot
::
hemisphere
::
Expressions
expr
;
expr
.
compute
(
a1
,
a2
,
lever
,
theta0
);
const
std
::
string
unit
=
" us"
;
std
::
cout
<<
"
Durations:"
<<
" "
<<
mean
<<
" +- "
<<
stddev
<<
unit
<<
", range: ["
<<
min
<<
unit
<<
" to "
<<
max
<<
unit
<<
"]"
<<
std
::
endl
;
const
Eigen
::
Vector3d
pos
=
VirtualRobot
::
hemisphere
::
getEndEffectorPosition
(
expr
)
;
std
::
cout
<<
"
\n
pos =
\n
"
<<
pos
.
transpose
().
format
(
iof
)
<<
std
::
endl
;
}
return
0
;
}
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