Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
chassis_subsystem_interface.hpp
Go to the documentation of this file.
1/*****************************************************************************/
2/********** !!! WARNING: CODE GENERATED BY TAPROOT. DO NOT EDIT !!! **********/
3/*****************************************************************************/
4
5/*
6 * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington <robomstr@uw.edu>
7 *
8 * This file is part of Taproot.
9 *
10 * Taproot is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * Taproot is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with Taproot. If not, see <https://www.gnu.org/licenses/>.
22 */
23
24#ifndef TAPROOT_CHASSIS_SUBSYSTEM_INTERFACE_HPP_
25#define TAPROOT_CHASSIS_SUBSYSTEM_INTERFACE_HPP_
26
28
29#include "../subsystem.hpp"
30#include "modm/math/matrix.hpp"
31
33{
38{
39public:
41
45 virtual inline int getNumChassisMotors() const = 0;
46
50 virtual inline bool allMotorsOnline() const = 0;
51
57 virtual modm::Matrix<float, 3, 1> getActualVelocityChassisRelative() const = 0;
58
65 modm::Matrix<float, 3, 1>& chassisRelativeVelocity,
66 float chassisHeading)
67 {
68 modm::Matrix<float, 3, 3> transform;
69 float headingCos = cosf(chassisHeading);
70 float headingSin = sinf(chassisHeading);
71 headingCos = tap::algorithms::compareFloatClose(headingCos, 0.0f, 1e-6) ? 0.0f : headingCos;
72 headingSin = tap::algorithms::compareFloatClose(headingSin, 0.0f, 1e-6) ? 0.0f : headingSin;
73
74 transform[0][0] = headingCos;
75 transform[1][0] = headingSin;
76 transform[2][0] = 0;
77 transform[0][1] = -headingSin;
78 transform[1][1] = headingCos;
79 transform[2][1] = 0;
80 transform[0][2] = 0;
81 transform[1][2] = 0;
82 transform[2][2] = 1;
83 chassisRelativeVelocity = transform * chassisRelativeVelocity;
84 }
85};
86} // namespace tap::control::chassis
87
88#endif // TAPROOT_CHASSIS_SUBSYSTEM_INTERFACE_HPP_
Definition drivers.hpp:70
Definition subsystem.hpp:54
Drivers * drivers
Definition subsystem.hpp:138
Abstract interface for a robot chassis.
Definition chassis_subsystem_interface.hpp:38
ChassisSubsystemInterface(Drivers *drivers)
Definition chassis_subsystem_interface.hpp:40
virtual modm::Matrix< float, 3, 1 > getActualVelocityChassisRelative() const =0
static void getVelocityWorldRelative(modm::Matrix< float, 3, 1 > &chassisRelativeVelocity, float chassisHeading)
Definition chassis_subsystem_interface.hpp:64
bool compareFloatClose(float val1, float val2, float epsilon)
Definition math_user_utils.hpp:57
Definition chassis_subsystem_interface.hpp:33