Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
dji_motor_sim_handler.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_DJI_MOTOR_SIM_HANDLER_HPP_
25#define TAPROOT_DJI_MOTOR_SIM_HANDLER_HPP_
26
27#ifdef PLATFORM_HOSTED
28
29#include <map>
30#include <memory>
31
34
35#include "motor_sim.hpp"
36
37namespace tap::motor::motorsim
38{
39class DjiMotorSimHandler
40{
41public:
42 static DjiMotorSimHandler* getInstance()
43 {
44 static DjiMotorSimHandler* handler = new DjiMotorSimHandler;
45 return handler;
46 }
47
51 void resetMotorSims();
52
59 void registerSim(
60 std::shared_ptr<MotorSim> motorSim,
61 std::tuple<can::CanBus, motor::MotorId> canBusAndMotorId);
62
68 bool parseMotorMessage(tap::can::CanBus bus, const modm::can::Message& message);
69
74 bool encodeMessage(tap::can::CanBus bus, modm::can::Message* message);
75
77 void updateSims();
78
79private:
80 std::map<std::tuple<can::CanBus, MotorId>, std::shared_ptr<MotorSim>> motorIDToMotorSimMap;
81
82 std::map<can::CanBus, MotorId> nextMotorIdToEncode;
83
84 bool getNextMotorId(can::CanBus bus);
85};
86} // namespace tap::motor::motorsim
87
88#endif // PLATFORM_HOSTED
89
90#endif // TAPROOT_DJI_MOTOR_SIM_HANDLER_HPP_
CanBus
Definition can_bus.hpp:30