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 <aspect/blackboard.h>
26 #include <aspect/blocked_timing.h>
27 #include <aspect/configurable.h>
28 #include <aspect/logging.h>
29 #include <core/threading/thread.h>
30 
31 #include <cfloat>
32 #include <string>
33 
34 namespace fawkes {
35 class MotorInterface;
36 class JoystickInterface;
37 class Laser360Interface;
38 } // namespace fawkes
39 
42  public fawkes::LoggingAspect,
45 {
46 public:
48 
49  virtual void init();
50  virtual void loop();
51  virtual bool prepare_finalize_user();
52  virtual void finalize();
53 
54  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
55 protected:
56  virtual void
57  run()
58  {
59  Thread::run();
60  }
61 
62 private:
63  void stop();
64  bool is_area_free(float theta);
65  void send_transrot(float vx, float vy, float omega);
66 
67 private:
68  fawkes::MotorInterface * motor_if_;
69  fawkes::JoystickInterface *joystick_if_;
70  fawkes::Laser360Interface *laser_if_;
71 
72  unsigned int cfg_axis_forward_;
73  unsigned int cfg_axis_sideward_;
74  unsigned int cfg_axis_rotation_;
75  float cfg_axis_threshold_;
76  bool cfg_deadman_use_axis_;
77  unsigned int cfg_deadman_axis_;
78  float cfg_deadman_ax_thresh_;
79  unsigned int cfg_deadman_butmask_;
80  bool cfg_drive_mode_use_axis_;
81  unsigned int cfg_drive_mode_axis_;
82  float cfg_drive_mode_ax_thresh_;
83  unsigned int cfg_drive_mode_butmask_;
84  float cfg_normal_max_vx_;
85  float cfg_normal_max_vy_;
86  float cfg_normal_max_omega_;
87  float cfg_special_max_vx_;
88  float cfg_special_max_vy_;
89  float cfg_special_max_omega_;
90  bool cfg_collision_safety_;
91  float cfg_collision_safety_distance_;
92  unsigned int cfg_collision_safety_angle_;
93  std::string cfg_ifid_motor_;
94  std::string cfg_ifid_joystick_;
95  bool cfg_use_laser_;
96  std::string cfg_ifid_laser_;
97  bool cfg_use_ff_;
98  unsigned int cfg_runstop_enable_buttons_;
99  unsigned int cfg_runstop_disable_buttons_;
100 
101  bool stopped_;
102  float min_distance_;
103 
104  bool ff_weak_;
105  bool ff_strong_;
106 
107  bool runstop_pressed_;
108 };
109 
110 #endif
JoystickTeleOpThread::init
virtual void init()
Initialize the thread.
Definition: joystick_teleop_thread.cpp:52
JoystickTeleOpThread
Remotely control a robot using a joystick.
Definition: joystick_teleop_thread.h:45
JoystickTeleOpThread::loop
virtual void loop()
Code to execute in the thread.
Definition: joystick_teleop_thread.cpp:204
fawkes::BlockedTimingAspect
Thread aspect to use blocked timing.
Definition: blocked_timing.h:51
fawkes::MotorInterface
MotorInterface Fawkes BlackBoard Interface.
Definition: MotorInterface.h:34
JoystickTeleOpThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: joystick_teleop_thread.h:57
fawkes::BlackBoardAspect
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
fawkes
Fawkes library namespace.
fawkes::LoggingAspect
Thread aspect to log output.
Definition: logging.h:33
fawkes::Thread
Thread class encapsulation of pthreads.
Definition: thread.h:46
JoystickTeleOpThread::prepare_finalize_user
virtual bool prepare_finalize_user()
Prepare finalization user implementation.
Definition: joystick_teleop_thread.cpp:139
fawkes::ConfigurableAspect
Thread aspect to access configuration data.
Definition: configurable.h:33
fawkes::Laser360Interface
Laser360Interface Fawkes BlackBoard Interface.
Definition: Laser360Interface.h:34
JoystickTeleOpThread::JoystickTeleOpThread
JoystickTeleOpThread()
Constructor.
Definition: joystick_teleop_thread.cpp:45
fawkes::JoystickInterface
JoystickInterface Fawkes BlackBoard Interface.
Definition: JoystickInterface.h:34
JoystickTeleOpThread::finalize
virtual void finalize()
Finalize the thread.
Definition: joystick_teleop_thread.cpp:146