Fawkes API  Fawkes Development Version
joystick_teleop_thread.h
1 
2 /***************************************************************************
3  * joystick_teleop_thread.h - Joystick teleop thread
4  *
5  * Created: Sun Nov 13 23:22:29 2011 (as part of the robotino plugin)
6  * Copyright 2011-2014 Tim Niemueller [www.niemueller.de]
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #ifndef __PLUGINS_JOYSTICK_JOYSTICK_TELEOP_THREAD_H_
23 #define __PLUGINS_JOYSTICK_JOYSTICK_TELEOP_THREAD_H_
24 
25 #include <core/threading/thread.h>
26 #include <aspect/blocked_timing.h>
27 #include <aspect/logging.h>
28 #include <aspect/configurable.h>
29 #include <aspect/blackboard.h>
30 
31 #include <string>
32 #include <cfloat>
33 
34 namespace fawkes {
35  class MotorInterface;
36  class JoystickInterface;
37  class Laser360Interface;
38 }
39 
41 : public fawkes::Thread,
43  public fawkes::LoggingAspect,
46 {
47  public:
49 
50  virtual void init();
51  virtual void loop();
52  virtual bool prepare_finalize_user();
53  virtual void finalize();
54 
55  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
56  protected: virtual void run() { Thread::run(); }
57 
58  private:
59  void stop();
60  bool is_area_free(float theta);
61  void send_transrot(float vx, float vy, float omega);
62 
63  private:
64  fawkes::MotorInterface *motor_if_;
65  fawkes::JoystickInterface *joystick_if_;
66  fawkes::Laser360Interface *laser_if_;
67 
68  unsigned int cfg_axis_forward_;
69  unsigned int cfg_axis_sideward_;
70  unsigned int cfg_axis_rotation_;
71  float cfg_axis_threshold_;
72  bool cfg_deadman_use_axis_;
73  unsigned int cfg_deadman_axis_;
74  float cfg_deadman_ax_thresh_;
75  unsigned int cfg_deadman_butmask_;
76  bool cfg_drive_mode_use_axis_;
77  unsigned int cfg_drive_mode_axis_;
78  float cfg_drive_mode_ax_thresh_;
79  unsigned int cfg_drive_mode_butmask_;
80  float cfg_normal_max_vx_;
81  float cfg_normal_max_vy_;
82  float cfg_normal_max_omega_;
83  float cfg_special_max_vx_;
84  float cfg_special_max_vy_;
85  float cfg_special_max_omega_;
86  bool cfg_collision_safety_;
87  float cfg_collision_safety_distance_;
88  unsigned int cfg_collision_safety_angle_;
89  std::string cfg_ifid_motor_;
90  std::string cfg_ifid_joystick_;
91  bool cfg_use_laser_;
92  std::string cfg_ifid_laser_;
93  bool cfg_use_ff_;
94  unsigned int cfg_runstop_enable_buttons_;
95  unsigned int cfg_runstop_disable_buttons_;
96 
97  bool stopped_;
98  float min_distance_;
99 
100  bool ff_weak_;
101  bool ff_strong_;
102 
103  bool runstop_pressed_;
104 };
105 
106 
107 #endif
Laser360Interface Fawkes BlackBoard Interface.
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
JoystickInterface Fawkes BlackBoard Interface.
Fawkes library namespace.
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:939
Remotely control a robot using a joystick.
Thread class encapsulation of pthreads.
Definition: thread.h:42
Thread aspect to use blocked timing.
Thread aspect to log output.
Definition: logging.h:35
Thread aspect to access configuration data.
Definition: configurable.h:35
virtual void run()
Stub to see name in backtrace for easier debugging.
MotorInterface Fawkes BlackBoard Interface.