-
Notifications
You must be signed in to change notification settings - Fork 1
/
hardware_interface.cpp
55 lines (45 loc) · 2.23 KB
/
hardware_interface.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Including library header
#include "MotorFunctions/MotorFunctions.h"
// Define functions (and make calls to library functions)
namespace MotorFunctions {
// on_init function
hardware_interface::CallbackReturn HardwareInterface::on_init(const hardware_interface::HardwareInfo & info) {
// If statement condition processes standard values (ex. name)
// Returns error if not all required parameters are set
if (hardware_interface::ActuatorInterface::on_init(info) != hardware_interface::CallbackReturn::SUCCESS) {
return hardware_interface::CallbackReturn()::ERROR;
}
}
hardware_interface::CallbackReturn HardwareInterface::on_configure(const hardware_interface::HardwareInfo & info) {
return hardware_interface::CallbackReturn()::ERROR;
}
// on_activate function: when motor transitions to active state
hardware_interface::CallbackReturn HardwareInterface::on_activate(rclcpp_lifecycle::State & previous_state) {
// Call motor functions from library
MotorFunctions mf;
mf.stop();
sleep(5);
mf.rotate(0xFF);
sleep(5);
return hardware_interface::CallbackReturn::SUCCESS;
}
// Functions below are left empty
hardware_interface::CallbackReturn HardwareInterface::on_deactivate(rclcpp_lifecycle::State & previous_state) {
return hardware_interface::CallbackReturn::SUCCESS;
}
hardware_interface::CallbackReturn on_cleanup(rclcpp_lifecycle::State & previous_state) {
return hardware_interface::CallbackReturn::SUCCESS;
}
hardware_interface::CallbackReturn on_shutdown(rclcpp_lifecycle::State & previous_state) {
return hardware_interface::CallbackReturn::SUCCESS;
}
hardware_interface::CallbackReturn on_error(rclcpp_lifecycle::State & previous_state) {
return hardware_interface::CallbackReturn::ERROR;
}
hardware_interface::return_type HardwareInterface::read(const rclcpp::Time & time, const rclcpp::Duration & period) {
return hardware_interface::return_type::OK;
}
hardware_interface::return_type HardwareInterface::write(const rclcpp::Time & time, const rclcpp::Duration & period) {
return hardware_interface::return_type::OK;
}
}