test_omni.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * BSD 3-Clause License
3  *
4  * Copyright (c) 2020 Northwestern University
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  *
13  * * Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * * Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *********************************************************************/
39 #include <gtest/gtest.h>
41 
42 TEST(OmniTest, MecanumKinematics)
43 {
44  const auto wheel_radius = 0.1;
45  const auto wheel_base_x = 0.5;
46  const auto wheel_base_y = 0.5;
47 
48  const ergodic_exploration::models::Mecanum mecanum(wheel_radius, wheel_base_x,
49  wheel_base_y);
50 
51  const arma::vec x = { 1.0, 2.0, 0.707 };
52  const arma::vec u = { 0.5, 0.4, 0.6, 0.3 };
53  const arma::vec xdot = mecanum(x, u);
54 
55  ASSERT_NEAR(xdot(0), 0.040709, 1e-6);
56  ASSERT_NEAR(xdot(1), 0.021626, 1e-6);
57  ASSERT_NEAR(xdot(2), 0.005, 1e-6);
58 }
59 
60 TEST(OmniTest, MecanumJacobianState)
61 {
62  const auto wheel_radius = 0.1;
63  const auto wheel_base_x = 0.5;
64  const auto wheel_base_y = 0.5;
65 
66  const ergodic_exploration::models::Mecanum mecanum(wheel_radius, wheel_base_x,
67  wheel_base_y);
68 
69  const arma::vec x = { 1.0, 2.0, 0.707 };
70  const arma::vec u = { 0.5, 0.4, 0.6, 0.3 };
71  const arma::mat A = mecanum.fdx(x, u);
72 
73  ASSERT_NEAR(A(0, 2), -0.021626, 1e-6);
74  ASSERT_NEAR(A(1, 2), 0.040709, 1e-6);
75 }
76 
77 TEST(OmniTest, MecanumJacobianControl)
78 {
79  const auto wheel_radius = 0.1;
80  const auto wheel_base_x = 0.5;
81  const auto wheel_base_y = 0.5;
82 
83  const ergodic_exploration::models::Mecanum mecanum(wheel_radius, wheel_base_x,
84  wheel_base_y);
85 
86  const arma::vec x = { 1.0, 2.0, 0.707 };
87  const arma::vec u = { 0.5, 0.4, 0.6, 0.3 };
88  const arma::mat B = mecanum.fdu(x);
89 
90  ASSERT_NEAR(B(0, 0), 0.035246, 1e-6);
91  ASSERT_NEAR(B(0, 1), 0.002768, 1e-6);
92  ASSERT_NEAR(B(0, 2), 0.035246, 1e-6);
93  ASSERT_NEAR(B(0, 3), 0.002768, 1e-6);
94 
95  ASSERT_NEAR(B(1, 0), -0.002768, 1e-6);
96  ASSERT_NEAR(B(1, 1), 0.035246, 1e-6);
97  ASSERT_NEAR(B(1, 2), -0.002768, 1e-6);
98  ASSERT_NEAR(B(1, 3), 0.035246, 1e-6);
99 
100  ASSERT_NEAR(B(2, 0), -0.025, 1e-6);
101  ASSERT_NEAR(B(2, 1), 0.025, 1e-6);
102  ASSERT_NEAR(B(2, 2), 0.025, 1e-6);
103  ASSERT_NEAR(B(2, 3), -0.025, 1e-6);
104 }
ergodic_exploration::models::Mecanum::fdx
mat fdx(const vec x, const vec u) const
Jacobian of the model with respect to the state.
Definition: omni.hpp:118
A
ergodic_exploration::models::Mecanum::fdu
mat fdu(const vec x) const
Jacobian of the model with respect to the control.
Definition: omni.hpp:141
omni.hpp
Kinematic omni directional models control wheel velocities or body twist.
TEST
TEST(OmniTest, MecanumKinematics)
Definition: test_omni.cpp:42
ergodic_exploration::models::Mecanum
Kinematic model of 4 mecanum wheel robot.
Definition: omni.hpp:59


ergodic_exploration
Author(s): bostoncleek
autogenerated on Wed Mar 2 2022 00:17:13