ros2_canopen master
C++ ROS CANopen Library
Loading...
Searching...
No Matches
default_homing_mode.hpp
Go to the documentation of this file.
1// Copyright 2023 Christoph Hellmann Santos
2// Copyright 2014-2022 Authors of ros_canopen
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <https://www.gnu.org/licenses/>.
16//
17
18#ifndef DEFAULT_HOMING_MODE_HPP
19#define DEFAULT_HOMING_MODE_HPP
20#include <mutex>
22#include "homing_mode.hpp"
23
24namespace ros2_canopen
25{
26
28{
29 const uint16_t index = 0x6098;
30 std::shared_ptr<LelyDriverBridge> driver;
31
32 std::atomic<bool> execute_;
33
34 std::mutex mutex_;
35 std::condition_variable cond_;
36 uint16_t status_;
37
38 const int homing_timeout_seconds_;
39
40 enum SW_masks
41 {
42 MASK_Reached = (1 << State402::SW_Target_reached),
43 MASK_Attained = (1 << SW_Attained),
44 MASK_Error = (1 << SW_Error),
45 };
46 bool error(const std::string & msg)
47 {
48 execute_ = false;
49 std::cout << msg << std::endl;
50 return false;
51 }
52
53public:
54 DefaultHomingMode(std::shared_ptr<LelyDriverBridge> driver, int homing_timeout_seconds)
55 : homing_timeout_seconds_(homing_timeout_seconds)
56 {
57 this->driver = driver;
58 }
59 virtual bool start();
60 virtual bool read(const uint16_t & sw);
61 virtual bool write(OpModeAccesser & cw);
62
63 virtual bool executeHoming();
64};
65} // namespace ros2_canopen
66#endif // DEFAULT_HOMING_MODE_HPP
Definition default_homing_mode.hpp:28
DefaultHomingMode(std::shared_ptr< LelyDriverBridge > driver, int homing_timeout_seconds)
Definition default_homing_mode.hpp:54
virtual bool read(const uint16_t &sw)
virtual bool write(OpModeAccesser &cw)
Definition homing_mode.hpp:26
@ SW_Error
Definition homing_mode.hpp:31
@ SW_Attained
Definition homing_mode.hpp:30
@ SW_Target_reached
Definition state.hpp:42
Definition word_accessor.hpp:27
Definition configuration_manager.hpp:28