Fawkes API  Fawkes Development Version
act_thread.h
1 
2 /***************************************************************************
3  * act_thread.h - Robotino act thread
4  *
5  * Created: Sun Nov 13 16:05:34 2011
6  * Copyright 2011-2014 Tim Niemueller [www.niemueller.de]
7  * 2014 Sebastian Reuter
8  * 2014 Tobias Neumann
9  * 2017 Till Hofmann
10  ****************************************************************************/
11 
12 /* This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Library General Public License for more details.
21  *
22  * Read the full text in the LICENSE.GPL file in the doc directory.
23  */
24 
25 #ifndef _PLUGINS_ROBOTINO_ACT_THREAD_H_
26 #define _PLUGINS_ROBOTINO_ACT_THREAD_H_
27 
28 #include <aspect/blackboard.h>
29 #include <aspect/blocked_timing.h>
30 #include <aspect/clock.h>
31 #include <aspect/configurable.h>
32 #include <aspect/logging.h>
33 #include <core/threading/thread.h>
34 #ifdef HAVE_TF
35 # include <aspect/tf.h>
36 #endif
37 
38 #include <string>
39 
40 namespace fawkes {
41 class MotorInterface;
42 class GripperInterface;
43 class IMUInterface;
44 } // namespace fawkes
45 
46 class RobotinoComThread;
47 
49  public fawkes::LoggingAspect,
51  public fawkes::ClockAspect,
52 #ifdef HAVE_TF
54 #endif
57 {
58 public:
60 
61  virtual void init();
62  virtual void once();
63  virtual void loop();
64  virtual void finalize();
65 
66  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
67 protected:
68  virtual void
69  run()
70  {
71  Thread::run();
72  }
73 
74 private:
75  typedef enum { ODOM_COPY, ODOM_CALC } OdometryMode;
76 
77  void publish_odometry();
78  void publish_gripper();
79 
80 private:
81  RobotinoComThread *com_;
82 
83  unsigned int last_seqnum_;
84  fawkes::MotorInterface * motor_if_;
85  fawkes::GripperInterface *gripper_if_;
86  fawkes::IMUInterface * imu_if_;
87  unsigned int imu_if_nochange_loops_;
88  bool imu_if_writer_warning_printed_;
89  bool imu_if_invquat_warning_printed_;
90  bool imu_if_changed_warning_printed_;
91  bool msg_received_;
92  bool msg_zero_vel_;
93  fawkes::Time last_msg_time_;
94 
95  float cfg_deadman_threshold_;
96  float cfg_odom_time_offset_;
97  bool cfg_gripper_enabled_;
98  std::string cfg_odom_frame_;
99  std::string cfg_base_frame_;
100  OdometryMode cfg_odom_mode_;
101  unsigned int cfg_imu_deadman_loops_;
102  float cfg_odom_corr_phi_;
103  float cfg_odom_corr_trans_;
104  bool cfg_bumper_estop_enabled_;
105  float cfg_rb_;
106  float cfg_rw_;
107  float cfg_gear_;
108  float cfg_trans_accel_;
109  float cfg_trans_decel_;
110  float cfg_rot_accel_;
111  float cfg_rot_decel_;
112 
113 #ifdef HAVE_TF
114  bool cfg_publish_transform_;
115 #endif
116 
117  bool gripper_close_;
118 
119  float odom_x_;
120  float odom_y_;
121  float odom_phi_;
122  float odom_gyro_origin_;
123  fawkes::Time *odom_time_;
124 
125  float des_vx_;
126  float des_vy_;
127  float des_omega_;
128  std::string last_transrot_sender_;
129 };
130 
131 #endif
Robotino act hook integration thread.
Definition: act_thread.h:57
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: act_thread.h:69
virtual void finalize()
Finalize the thread.
Definition: act_thread.cpp:133
RobotinoActThread(RobotinoComThread *com_thread)
Constructor.
Definition: act_thread.cpp:46
virtual void once()
Execute an action exactly once.
Definition: act_thread.cpp:144
virtual void loop()
Code to execute in the thread.
Definition: act_thread.cpp:153
virtual void init()
Initialize the thread.
Definition: act_thread.cpp:57
Virtual base class for thread that communicates with a Robotino.
Definition: com_thread.h:41
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect to use blocked timing.
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:34
Thread aspect to access configuration data.
Definition: configurable.h:33
GripperInterface Fawkes BlackBoard Interface.
IMUInterface Fawkes BlackBoard Interface.
Definition: IMUInterface.h:34
Thread aspect to log output.
Definition: logging.h:33
MotorInterface Fawkes BlackBoard Interface.
Thread class encapsulation of pthreads.
Definition: thread.h:46
A class for handling time.
Definition: time.h:93
Thread aspect to access the transform system.
Definition: tf.h:39
Fawkes library namespace.