keyop_core.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Yujin Robot.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of Yujin Robot nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
37 /*****************************************************************************
38  ** Ifdefs
39  *****************************************************************************/
40 
41 #ifndef KEYOP_CORE_NODE_HPP_
42 #define KEYOP_CORE_NODE_HPP_
43 
44 /*****************************************************************************
45  ** Includes
46  *****************************************************************************/
47 
48 #include <ros/ros.h>
49 #include <termios.h> // for keyboard input
50 #include <ecl/threads.hpp>
51 #include <geometry_msgs/Twist.h> // for velocity commands
52 #include <geometry_msgs/TwistStamped.h> // for velocity commands
53 #include <kobuki_msgs/KeyboardInput.h> // keycodes from remote teleops.
54 
55 /*****************************************************************************
56  ** Namespaces
57  *****************************************************************************/
58 
59 namespace keyop_core
60 {
61 
62 /*****************************************************************************
63  ** Interface
64  *****************************************************************************/
69 class KeyOpCore
70 {
71 public:
72  /*********************
73  ** C&D
74  **********************/
75  KeyOpCore();
76  ~KeyOpCore();
77  bool init();
78 
79  /*********************
80  ** Runtime
81  **********************/
82  void spin();
83 
84 private:
92  geometry_msgs::TwistPtr cmd;
93  geometry_msgs::TwistStampedPtr cmd_stamped;
96  std::string name;
97 
98  /*********************
99  ** Commands
100  **********************/
101  void enable();
102  void disable();
107  void resetVelocity();
108 
109  /*********************
110  ** Keylogging
111  **********************/
112 
113  void keyboardInputLoop();
114  void processKeyboardInput(char c);
115  void remoteKeyInputReceived(const kobuki_msgs::KeyboardInput& key);
116  void restoreTerminal();
119  struct termios original_terminal_state;
120  ecl::Thread thread;
121 };
122 
123 } // namespace keyop_core
124 
125 #endif /* KEYOP_CORE_NODE_HPP_ */
void enable()
Reset/re-enable the navigation system.
Definition: keyop_core.cpp:378
void disable()
Disables commands to the navigation system.
Definition: keyop_core.cpp:351
bool init()
Initialises the node.
Definition: keyop_core.cpp:86
Keyboard remote control for our robot core (mobile base).
Definition: keyop_core.hpp:69
void decrementLinearVelocity()
If not already minned, decrement the linear velocities..
Definition: keyop_core.cpp:422
geometry_msgs::TwistStampedPtr cmd_stamped
Definition: keyop_core.hpp:93
ros::Subscriber keyinput_subscriber
Definition: keyop_core.hpp:85
geometry_msgs::TwistPtr cmd
Definition: keyop_core.hpp:92
ros::Publisher motor_power_publisher_
Definition: keyop_core.hpp:87
void remoteKeyInputReceived(const kobuki_msgs::KeyboardInput &key)
Callback function for remote keyboard inputs subscriber.
Definition: keyop_core.cpp:272
void keyboardInputLoop()
The worker thread function that accepts input keyboard commands.
Definition: keyop_core.cpp:238
KeyOpCore()
Default constructor, needs initialisation.
Definition: keyop_core.cpp:62
ros::Publisher velocity_publisher_
Definition: keyop_core.hpp:86
void incrementLinearVelocity()
If not already maxxed, increment the command velocities..
Definition: keyop_core.cpp:403
void spin()
Worker thread loop; sends current velocity command at a fixed rate.
Definition: keyop_core.cpp:193
void processKeyboardInput(char c)
Process individual keyboard inputs.
Definition: keyop_core.cpp:282
void decrementAngularVelocity()
If not already mined, decrement the angular velocities..
Definition: keyop_core.cpp:460
struct termios original_terminal_state
Definition: keyop_core.hpp:119
void incrementAngularVelocity()
If not already maxxed, increment the angular velocities..
Definition: keyop_core.cpp:441


kobuki_keyop
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:45:04