Fawkes API  Fawkes Development Version
clips_tf_thread.h
1 
2 /***************************************************************************
3  * clips_tf_thread.h - Transforms feature for CLIPS
4  *
5  * Created: Sat Apr 11 17:28:18 2015
6  * Copyright 2015 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_CLIPS_TF_CLIPS_TF_THREAD_H_
23 #define __PLUGINS_CLIPS_TF_CLIPS_TF_THREAD_H_
24 
25 #include <core/threading/thread.h>
26 #include <aspect/logging.h>
27 #include <aspect/configurable.h>
28 #include <plugins/clips/aspect/clips_feature.h>
29 #include <aspect/tf.h>
30 
31 #include <clipsmm.h>
32 
34 : public fawkes::Thread,
35  public fawkes::LoggingAspect,
38  public fawkes::CLIPSFeature,
40 {
41  public:
42  ClipsTFThread();
43  virtual ~ClipsTFThread();
44 
45  virtual void init();
46  virtual void loop();
47  virtual void finalize();
48 
49  // for CLIPSFeature
50  virtual void clips_context_init(const std::string &env_name,
52  virtual void clips_context_destroyed(const std::string &env_name);
53 
54  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
55  protected: virtual void run() { Thread::run(); }
56 
57  private:
58  bool validate_time(const CLIPS::Values &time);
59  fawkes::Time convert_time(const CLIPS::Values &time);
60  bool validate_point(const CLIPS::Values &point);
61  bool validate_vector3(const CLIPS::Values &vector3);
62  bool validate_quat(const CLIPS::Values &quat);
63 
64  CLIPS::Values clips_tf_quat_from_yaw(double yaw);
65  double clips_tf_yaw_from_quat(CLIPS::Values quat);
66 
67  CLIPS::Value clips_tf_frame_exists(std::string frame_id);
68  CLIPS::Value clips_tf_can_transform(std::string target_frame, std::string source_frame,
69  CLIPS::Values time);
70  CLIPS::Values clips_tf_transform_point(std::string target_frame, std::string source_frame,
71  CLIPS::Values time, CLIPS::Values point);
72  CLIPS::Values clips_tf_transform_vector(std::string target_frame, std::string source_frame,
73  CLIPS::Values time, CLIPS::Values vector);
74  CLIPS::Values clips_tf_transform_quaternion(std::string target_frame,
75  std::string source_frame,
76  CLIPS::Values time, CLIPS::Values quat);
77 
78  CLIPS::Values clips_tf_transform_pose(std::string target_frame, std::string source_frame,
79  CLIPS::Values time,
80  CLIPS::Values translation,
81  CLIPS::Values rotation_quat);
82 
83  private:
84  std::map<std::string, fawkes::LockPtr<CLIPS::Environment> > envs_;
85 
86 };
87 
88 #endif
Thread aspect to provide a feature to CLIPS environments.
Definition: clips_feature.h:57
virtual void init()
Initialize the thread.
virtual void loop()
Code to execute in the thread.
ClipsTFThread()
Constructor.
A class for handling time.
Definition: time.h:91
Thread class encapsulation of pthreads.
Definition: thread.h:42
virtual void run()
Stub to see name in backtrace for easier debugging.
Thread aspect to access the transform system.
Definition: tf.h:42
virtual void clips_context_init(const std::string &env_name, fawkes::LockPtr< CLIPS::Environment > &clips)
Initialize a CLIPS context to use the provided feature.
CLIPS feature maintainer.
Definition: clips_feature.h:41
Thread aspect to log output.
Definition: logging.h:35
Provide protobuf functionality to CLIPS environment.
Thread aspect to access configuration data.
Definition: configurable.h:35
virtual void finalize()
Finalize the thread.
virtual void clips_context_destroyed(const std::string &env_name)
Notification that a CLIPS environment has been destroyed.
virtual ~ClipsTFThread()
Destructor.