-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/test/kotlin/org/mechdancer/geometry/transformation/TestPose3D.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.mechdancer.geometry.transformation | ||
|
||
import org.junit.Test | ||
import org.mechdancer.algebra.implement.vector.vector2DOf | ||
import org.mechdancer.algebra.implement.vector.vector3DOfZero | ||
import org.mechdancer.geometry.angle.toRad | ||
import kotlin.math.PI | ||
|
||
class TestPose3D { | ||
/** | ||
* 测试里程计算法 | ||
*/ | ||
@Test | ||
fun test() { | ||
val step0 = pose3D() | ||
assert(step0 == Pose3D(vector3DOfZero(), vector3DOfZero())) { | ||
"里程计初始化错误:$step0" | ||
} | ||
|
||
val delta1 = Pose2D(vector2DOf(3.0, 4.0), (PI / 2).toRad()).to3D() | ||
|
||
val step1 = step0 plusDelta delta1 | ||
assert(step1 == delta1) { | ||
"里程计累加错误:$step1 ≠ $delta1" | ||
} | ||
|
||
val step2 = step1 minusDelta delta1 | ||
assert(step2 == step0) { | ||
"里程计回滚错误:$step2 ≠ $step0" | ||
} | ||
|
||
val delta2 = Pose2D(vector2DOf(1.0, 1.0), (-PI / 4).toRad()).to3D() | ||
|
||
val step3 = step2 plusDelta delta1 | ||
val step4 = step3 plusDelta delta2 minusState step3 | ||
assert(step4 == delta2) { | ||
"里程计标记错误:$step4 ≠ $delta2" | ||
} | ||
} | ||
} |