Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
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
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
1dc7d490
Commit
1dc7d490
authored
10 years ago
by
Johan Jansen
Browse files
Options
Downloads
Patches
Plain Diff
VectorMath: Optimization by passing vector by reference instead of value
parent
34f6cf9e
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
src/modules/ekf_att_pos_estimator/estimator_utilities.cpp
+12
-18
12 additions, 18 deletions
src/modules/ekf_att_pos_estimator/estimator_utilities.cpp
src/modules/ekf_att_pos_estimator/estimator_utilities.h
+10
-13
10 additions, 13 deletions
src/modules/ekf_att_pos_estimator/estimator_utilities.h
with
22 additions
and
31 deletions
src/modules/ekf_att_pos_estimator/estimator_utilities.cpp
+
12
−
18
View file @
1dc7d490
...
...
@@ -38,6 +38,7 @@
*/
#include
"estimator_utilities.h"
#include
<algorithm>
// Define EKF_DEBUG here to enable the debug print calls
// if the macro is not set, these will be completely
...
...
@@ -104,17 +105,17 @@ void Mat3f::identity() {
z
.
z
=
1.0
f
;
}
Mat3f
Mat3f
::
transpose
(
void
)
const
Mat3f
Mat3f
::
transpose
()
const
{
Mat3f
ret
=
*
this
;
s
wap_var
(
ret
.
x
.
y
,
ret
.
y
.
x
);
s
wap_var
(
ret
.
x
.
z
,
ret
.
z
.
x
);
s
wap_var
(
ret
.
y
.
z
,
ret
.
z
.
y
);
s
td
::
swap
(
ret
.
x
.
y
,
ret
.
y
.
x
);
s
td
::
swap
(
ret
.
x
.
z
,
ret
.
z
.
x
);
s
td
::
swap
(
ret
.
y
.
z
,
ret
.
z
.
y
);
return
ret
;
}
// overload + operator to provide a vector addition
Vector3f
operator
+
(
Vector3f
vecIn1
,
Vector3f
vecIn2
)
Vector3f
operator
+
(
const
Vector3f
&
vecIn1
,
const
Vector3f
&
vecIn2
)
{
Vector3f
vecOut
;
vecOut
.
x
=
vecIn1
.
x
+
vecIn2
.
x
;
...
...
@@ -124,7 +125,7 @@ Vector3f operator+( Vector3f vecIn1, Vector3f vecIn2)
}
// overload - operator to provide a vector subtraction
Vector3f
operator
-
(
Vector3f
vecIn1
,
Vector3f
vecIn2
)
Vector3f
operator
-
(
const
Vector3f
&
vecIn1
,
const
Vector3f
&
vecIn2
)
{
Vector3f
vecOut
;
vecOut
.
x
=
vecIn1
.
x
-
vecIn2
.
x
;
...
...
@@ -134,7 +135,7 @@ Vector3f operator-( Vector3f vecIn1, Vector3f vecIn2)
}
// overload * operator to provide a matrix vector product
Vector3f
operator
*
(
Mat3f
matIn
,
Vector3f
vecIn
)
Vector3f
operator
*
(
const
Mat3f
&
matIn
,
const
Vector3f
&
vecIn
)
{
Vector3f
vecOut
;
vecOut
.
x
=
matIn
.
x
.
x
*
vecIn
.
x
+
matIn
.
x
.
y
*
vecIn
.
y
+
matIn
.
x
.
z
*
vecIn
.
z
;
...
...
@@ -144,7 +145,7 @@ Vector3f operator*( Mat3f matIn, Vector3f vecIn)
}
// overload * operator to provide a matrix product
Mat3f
operator
*
(
Mat3f
matIn1
,
Mat3f
matIn2
)
Mat3f
operator
*
(
const
Mat3f
&
matIn1
,
const
Mat3f
&
matIn2
)
{
Mat3f
matOut
;
matOut
.
x
.
x
=
matIn1
.
x
.
x
*
matIn2
.
x
.
x
+
matIn1
.
x
.
y
*
matIn2
.
y
.
x
+
matIn1
.
x
.
z
*
matIn2
.
z
.
x
;
...
...
@@ -163,7 +164,7 @@ Mat3f operator*( Mat3f matIn1, Mat3f matIn2)
}
// overload % operator to provide a vector cross product
Vector3f
operator
%
(
Vector3f
vecIn1
,
Vector3f
vecIn2
)
Vector3f
operator
%
(
const
Vector3f
&
vecIn1
,
const
Vector3f
&
vecIn2
)
{
Vector3f
vecOut
;
vecOut
.
x
=
vecIn1
.
y
*
vecIn2
.
z
-
vecIn1
.
z
*
vecIn2
.
y
;
...
...
@@ -173,7 +174,7 @@ Vector3f operator%( Vector3f vecIn1, Vector3f vecIn2)
}
// overload * operator to provide a vector scaler product
Vector3f
operator
*
(
Vector3f
vecIn1
,
float
sclIn1
)
Vector3f
operator
*
(
const
Vector3f
&
vecIn1
,
const
float
sclIn1
)
{
Vector3f
vecOut
;
vecOut
.
x
=
vecIn1
.
x
*
sclIn1
;
...
...
@@ -183,7 +184,7 @@ Vector3f operator*(Vector3f vecIn1, float sclIn1)
}
// overload * operator to provide a vector scaler product
Vector3f
operator
*
(
float
sclIn1
,
Vector3f
vecIn1
)
Vector3f
operator
*
(
float
sclIn1
,
const
Vector3f
&
vecIn1
)
{
Vector3f
vecOut
;
vecOut
.
x
=
vecIn1
.
x
*
sclIn1
;
...
...
@@ -192,13 +193,6 @@ Vector3f operator*(float sclIn1, Vector3f vecIn1)
return
vecOut
;
}
void
swap_var
(
float
&
d1
,
float
&
d2
)
{
float
tmp
=
d1
;
d1
=
d2
;
d2
=
tmp
;
}
// overload / operator to provide a vector scalar division
Vector3f
operator
/
(
const
Vector3f
&
vec
,
const
float
scalar
)
{
...
...
This diff is collapsed.
Click to expand it.
src/modules/ekf_att_pos_estimator/estimator_utilities.h
+
10
−
13
View file @
1dc7d490
...
...
@@ -52,7 +52,6 @@
class
Vector3f
{
private:
public:
float
x
;
float
y
;
...
...
@@ -64,8 +63,8 @@ public:
z
(
c
)
{}
float
length
(
void
)
const
;
void
zero
(
void
);
float
length
()
const
;
void
zero
();
};
class
Mat3f
...
...
@@ -79,20 +78,18 @@ public:
Mat3f
();
void
identity
();
Mat3f
transpose
(
void
)
const
;
Mat3f
transpose
()
const
;
};
Vector3f
operator
*
(
float
sclIn1
,
Vector3f
vecIn1
);
Vector3f
operator
+
(
Vector3f
vecIn1
,
Vector3f
vecIn2
);
Vector3f
operator
-
(
Vector3f
vecIn1
,
Vector3f
vecIn2
);
Vector3f
operator
*
(
Mat3f
matIn
,
Vector3f
vecIn
);
Mat3f
operator
*
(
Mat3f
matIn1
,
Mat3f
matIn2
);
Vector3f
operator
%
(
Vector3f
vecIn1
,
Vector3f
vecIn2
);
Vector3f
operator
*
(
Vector3f
vecIn1
,
float
sclIn1
);
Vector3f
operator
*
(
const
float
sclIn1
,
const
Vector3f
&
vecIn1
);
Vector3f
operator
+
(
const
Vector3f
&
vecIn1
,
const
Vector3f
&
vecIn2
);
Vector3f
operator
-
(
const
Vector3f
&
vecIn1
,
const
Vector3f
&
vecIn2
);
Vector3f
operator
*
(
const
Mat3f
&
matIn
,
const
Vector3f
&
vecIn
);
Mat3f
operator
*
(
const
Mat3f
&
matIn1
,
const
Mat3f
&
matIn2
);
Vector3f
operator
%
(
const
Vector3f
&
vecIn1
,
const
Vector3f
&
vecIn2
);
Vector3f
operator
*
(
const
Vector3f
&
vecIn1
,
const
float
sclIn1
);
Vector3f
operator
/
(
const
Vector3f
&
vec
,
const
float
scalar
);
void
swap_var
(
float
&
d1
,
float
&
d2
);
enum
GPS_FIX
{
GPS_FIX_NOFIX
=
0
,
GPS_FIX_2D
=
2
,
...
...
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