AERA
test_mem.h
1 //_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
2 //_/_/
3 //_/_/ AERA
4 //_/_/ Autocatalytic Endogenous Reflective Architecture
5 //_/_/
6 //_/_/ Copyright (c) 2018-2025 Jeff Thompson
7 //_/_/ Copyright (c) 2018-2025 Kristinn R. Thorisson
8 //_/_/ Copyright (c) 2018-2025 Icelandic Institute for Intelligent Machines
9 //_/_/ Copyright (c) 2021 Arash Sheikhlar
10 //_/_/ http://www.iiim.is
11 //_/_/
12 //_/_/ Copyright (c) 2010-2012 Eric Nivel
13 //_/_/ Center for Analysis and Design of Intelligent Agents
14 //_/_/ Reykjavik University, Menntavegur 1, 102 Reykjavik, Iceland
15 //_/_/ http://cadia.ru.is
16 //_/_/
17 //_/_/ Part of this software was developed by Eric Nivel
18 //_/_/ in the HUMANOBS EU research project, which included
19 //_/_/ the following parties:
20 //_/_/
21 //_/_/ Autonomous Systems Laboratory
22 //_/_/ Technical University of Madrid, Spain
23 //_/_/ http://www.aslab.org/
24 //_/_/
25 //_/_/ Communicative Machines
26 //_/_/ Edinburgh, United Kingdom
27 //_/_/ http://www.cmlabs.com/
28 //_/_/
29 //_/_/ Istituto Dalle Molle di Studi sull'Intelligenza Artificiale
30 //_/_/ University of Lugano and SUPSI, Switzerland
31 //_/_/ http://www.idsia.ch/
32 //_/_/
33 //_/_/ Institute of Cognitive Sciences and Technologies
34 //_/_/ Consiglio Nazionale delle Ricerche, Italy
35 //_/_/ http://www.istc.cnr.it/
36 //_/_/
37 //_/_/ Dipartimento di Ingegneria Informatica
38 //_/_/ University of Palermo, Italy
39 //_/_/ http://diid.unipa.it/roboticslab/
40 //_/_/
41 //_/_/
42 //_/_/ --- HUMANOBS Open-Source BSD License, with CADIA Clause v 1.0 ---
43 //_/_/
44 //_/_/ Redistribution and use in source and binary forms, with or without
45 //_/_/ modification, is permitted provided that the following conditions
46 //_/_/ are met:
47 //_/_/ - Redistributions of source code must retain the above copyright
48 //_/_/ and collaboration notice, this list of conditions and the
49 //_/_/ following disclaimer.
50 //_/_/ - Redistributions in binary form must reproduce the above copyright
51 //_/_/ notice, this list of conditions and the following disclaimer
52 //_/_/ in the documentation and/or other materials provided with
53 //_/_/ the distribution.
54 //_/_/
55 //_/_/ - Neither the name of its copyright holders nor the names of its
56 //_/_/ contributors may be used to endorse or promote products
57 //_/_/ derived from this software without specific prior
58 //_/_/ written permission.
59 //_/_/
60 //_/_/ - CADIA Clause: The license granted in and to the software
61 //_/_/ under this agreement is a limited-use license.
62 //_/_/ The software may not be used in furtherance of:
63 //_/_/ (i) intentionally causing bodily injury or severe emotional
64 //_/_/ distress to any person;
65 //_/_/ (ii) invading the personal privacy or violating the human
66 //_/_/ rights of any person; or
67 //_/_/ (iii) committing or preparing for any act of war.
68 //_/_/
69 //_/_/ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
70 //_/_/ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
71 //_/_/ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
72 //_/_/ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
73 //_/_/ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
74 //_/_/ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
75 //_/_/ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
76 //_/_/ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
77 //_/_/ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
78 //_/_/ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
79 //_/_/ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
80 //_/_/ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
81 //_/_/ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
82 //_/_/ OF SUCH DAMAGE.
83 //_/_/
84 //_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
85 
86 #ifndef test_mem_h
87 #define test_mem_h
88 
89 #include "../r_exec/mem.h"
90 
98 template<class O, class S> class TestMem :
99  public r_exec::MemExec<O, S> {
100 public:
101  TestMem();
102 
103  ~TestMem();
104 
108  bool load(const std::vector<r_code::Code *> *objects, uint32 stdin_oid, uint32 stdout_oid, uint32 self_oid) override;
109 
118  r_code::Code* eject(r_code::Code *command) override;
119 
124  void on_diagnostic_time_tick() override { on_time_tick(); }
125 
126 protected:
127  class _Thread : public Thread {
128  };
129 
130  void on_time_tick();
131 
136  void startTimeTickThread();
137 
144  static thread_ret thread_function_call timeTickRun(void *args);
145  std::ofstream ofs;
146 
147  Thread* timeTickThread_;
148  Timestamp lastInjectTime_;
149  float velocity_y_;
150  float position_y_;
151  float force_y_;
152  float next_velocity_y_;
153  float next_position_y_;
154  float next_theta_y_;
155  float next_omega_y_;
156  r_code::Code* position_y_obj_;
157  r_code::Code* cart_position_y_obj_;
158  r_code::Code* position_property_;
159  r_code::Code* position_y_property_;
160  r_code::Code* velocity_y_property_;
161  r_code::Code* force_y_property_;
162  r_code::Code* theta_y_property_;
163  r_code::Code* omega_y_property_;
164  r_code::Code* primary_group_;
165  uint16 ready_opcode_;
166  uint16 set_velocity_y_opcode_;
167  uint16 set_force_y_opcode_;
168  uint16 move_y_plus_opcode_;
169  uint16 move_y_minus_opcode_;
170  Timestamp lastCommandTime_;
171 
172  r_code::Code* yEnt_[10];
173  r_code::Code* discretePositionObj_;
174  r_code::Code* discretePosition_;
175  r_code::Code* nextDiscretePosition_;
176  int babbleState_;
177 };
178 
179 #endif
TestMem::eject
r_code::Code * eject(r_code::Code *command) override
Definition: test_mem.cpp:165
TestMem::_Thread
Definition: test_mem.h:127
TestMem
Definition: test_mem.h:99
TestMem::on_diagnostic_time_tick
void on_diagnostic_time_tick() override
Definition: test_mem.h:124
core::Thread
Definition: submodules/CoreLibrary/CoreLibrary/utils.h:159
r_code::Code
Definition: r_code/object.h:224
TestMem::load
bool load(const std::vector< r_code::Code * > *objects, uint32 stdin_oid, uint32 stdout_oid, uint32 self_oid) override
Definition: test_mem.cpp:136
TestMem::timeTickRun
static thread_ret thread_function_call timeTickRun(void *args)
Definition: test_mem.cpp:561
r_exec::MemExec
Definition: mem.h:979
TestMem::startTimeTickThread
void startTimeTickThread()
Definition: test_mem.cpp:547