ros2_rover
Loading...
Searching...
No Matches
motor_controller.hpp
Go to the documentation of this file.
1// MIT License
2
3// Copyright (c) 2023 Miguel Ángel González Santamarta
4
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
22
23#ifndef MOTOR_CONTROLLER_HPP
24#define MOTOR_CONTROLLER_HPP
25
26#include <cstdint>
27#include <memory>
28#include <string>
29#include <vector>
30
31#include "lx16a/lx16a.hpp"
33
34namespace lx16a {
35
37private:
38 std::unique_ptr<LX16A> lx16a;
39
40public:
41 MotorController(std::string serial_port, unsigned int baud_rate);
42
43 void corner_to_position(std::vector<int> corner_ticks);
44 void send_motor_duty(std::vector<int> drive_ticks);
45
46 void kill_motors();
47
48 int get_corner_position(uint8_t servo_id);
49 int get_motor_speed(uint8_t servo_id);
50
51 uint8_t get_mode(uint8_t servo_id);
52 uint8_t get_status(uint8_t servo_id);
53
54 void move(uint8_t servo_id, int position, int time);
55
56 void led_turn_off(uint8_t servo_id);
57 void led_turn_on(uint8_t servo_id);
58};
59
60} // namespace lx16a
61#endif
void led_turn_on(uint8_t servo_id)
Definition motor_controller.cpp:95
void send_motor_duty(std::vector< int > drive_ticks)
Definition motor_controller.cpp:57
void led_turn_off(uint8_t servo_id)
Definition motor_controller.cpp:91
void kill_motors()
Definition motor_controller.cpp:66
MotorController(std::string serial_port, unsigned int baud_rate)
Definition motor_controller.cpp:32
uint8_t get_status(uint8_t servo_id)
Definition motor_controller.cpp:83
int get_motor_speed(uint8_t servo_id)
Definition motor_controller.cpp:75
void corner_to_position(std::vector< int > corner_ticks)
Definition motor_controller.cpp:49
uint8_t get_mode(uint8_t servo_id)
Definition motor_controller.cpp:79
void move(uint8_t servo_id, int position, int time)
Definition motor_controller.cpp:87
int get_corner_position(uint8_t servo_id)
Definition motor_controller.cpp:71
Definition lx16a.hpp:35