Warning: include(php/utility.php): Failed to open stream: No such file or directory in /home/argos/argos3/doc/api/embedded/a00526_source.php on line 2

Warning: include(): Failed opening 'php/utility.php' for inclusion (include_path='.:/usr/lib64/php') in /home/argos/argos3/doc/api/embedded/a00526_source.php on line 2
The ARGoS Website

lua_utility.cpp
Go to the documentation of this file.
1 
7 #include "lua_utility.h"
8 #include <argos3/core/utility/configuration/argos_exception.h>
9 #include <argos3/core/utility/math/angles.h>
10 #include <argos3/core/utility/math/vector2.h>
11 #include <argos3/core/utility/math/vector3.h>
12 #include <argos3/core/utility/math/quaternion.h>
13 #include <argos3/core/utility/datatypes/color.h>
14 
15 namespace argos {
16 
17  /****************************************/
18  /****************************************/
19 
20  static const CRange<Real> UNIT(0.0f, 1.0f);
21 
22  int LuaRNGBernoulli(lua_State* pt_state) {
23  /* Check number of parameters */
24  if(lua_gettop(pt_state) > 1) {
25  return luaL_error(pt_state, "robot.random.bernoulli() expects 0 or 1 arguments");
26  }
27  /* Get RNG instance */
28  CRandom::CRNG* pcRNG = CLuaUtility::GetDeviceInstance<CRandom::CRNG>(pt_state, "random");
29  /* Perform wanted action */
30  if(lua_gettop(pt_state) == 0) {
31  /* Return random number */
32  lua_pushnumber(pt_state, pcRNG->Bernoulli());
33  return 1;
34  }
35  else {
36  /* Check parameter */
37  luaL_checktype(pt_state, 1, LUA_TNUMBER);
38  /* Return random number */
39  lua_pushnumber(pt_state,
40  pcRNG->Bernoulli(lua_tonumber(pt_state, 1)));
41  return 1;
42  }
43  /* Can't reach this point */
44  return 0;
45  }
46 
47  int LuaRNGUniform(lua_State* pt_state) {
48  /* Check number of parameters */
49  if(lua_gettop(pt_state) > 2) {
50  return luaL_error(pt_state, "robot.random.uniform() expects 0, 1, or 2 arguments");
51  }
52  /* Get RNG instance */
53  CRandom::CRNG* pcRNG = CLuaUtility::GetDeviceInstance<CRandom::CRNG>(pt_state, "random");
54  /* Perform wanted action */
55  if(lua_gettop(pt_state) == 0) {
56  /* Return a number between 0 and 1 */
57  lua_pushnumber(pt_state, pcRNG->Uniform(UNIT));
58  return 1;
59  }
60  else if(lua_gettop(pt_state) == 1) {
61  /* Check parameter */
62  luaL_checktype(pt_state, 1, LUA_TNUMBER);
63  /* Return a number between 0 and the max */
64  lua_pushnumber(pt_state,
65  pcRNG->Uniform(CRange<Real>(0,
66  lua_tonumber(pt_state, 1))));
67  return 1;
68  }
69  else {
70  /* Check parameters */
71  luaL_checktype(pt_state, 1, LUA_TNUMBER);
72  luaL_checktype(pt_state, 2, LUA_TNUMBER);
73  /* Return a number between min and max */
74  lua_pushnumber(pt_state,
75  pcRNG->Uniform(CRange<Real>(lua_tonumber(pt_state, 1),
76  lua_tonumber(pt_state, 2))));
77  return 1;
78  }
79  /* Can't reach this point */
80  return 0;
81  }
82 
83  int LuaRNGUniformInt(lua_State* pt_state) {
84  /* Check number of parameters */
85  if(lua_gettop(pt_state) > 2) {
86  return luaL_error(pt_state, "robot.random.uniform_int() expects 1 or 2 arguments");
87  }
88  /* Get RNG instance */
89  CRandom::CRNG* pcRNG = CLuaUtility::GetDeviceInstance<CRandom::CRNG>(pt_state, "random");
90  /* Perform wanted action */
91  if(lua_gettop(pt_state) == 1) {
92  /* Check parameter */
93  luaL_checktype(pt_state, 1, LUA_TNUMBER);
94  /* Return a number between 0 and the max */
95  lua_pushnumber(pt_state,
96  pcRNG->Uniform(CRange<UInt32>(0,
97  Floor(lua_tonumber(pt_state, 1)))));
98  return 1;
99  }
100  else {
101  /* Check parameters */
102  luaL_checktype(pt_state, 1, LUA_TNUMBER);
103  luaL_checktype(pt_state, 2, LUA_TNUMBER);
104  /* Return a number between min and max */
105  lua_pushnumber(pt_state,
106  pcRNG->Uniform(CRange<SInt32>(Floor(lua_tonumber(pt_state, 1)),
107  Floor(lua_tonumber(pt_state, 2)))));
108  return 1;
109  }
110  /* Can't reach this point */
111  return 0;
112  }
113 
114  int LuaRNGExponential(lua_State* pt_state) {
115  /* Check number of parameters */
116  if(lua_gettop(pt_state) != 1) {
117  return luaL_error(pt_state, "robot.random.exponential() expects 1 argument");
118  }
119  /* Get RNG instance */
120  CRandom::CRNG* pcRNG = CLuaUtility::GetDeviceInstance<CRandom::CRNG>(pt_state, "random");
121  /* Check parameter */
122  luaL_checktype(pt_state, 1, LUA_TNUMBER);
123  /* Return random number */
124  lua_pushnumber(pt_state,
125  pcRNG->Exponential(lua_tonumber(pt_state, 1)));
126  return 1;
127  }
128 
129  int LuaRNGGaussian(lua_State* pt_state) {
130  /* Check number of parameters */
131  if(lua_gettop(pt_state) != 1 && lua_gettop(pt_state) != 2) {
132  return luaL_error(pt_state, "robot.random.gaussian() expects 1 or 2 arguments");
133  }
134  /* Get RNG instance */
135  CRandom::CRNG* pcRNG = CLuaUtility::GetDeviceInstance<CRandom::CRNG>(pt_state, "random");
136  /* Perform wanted action */
137  if(lua_gettop(pt_state) == 1) {
138  /* Check parameter */
139  luaL_checktype(pt_state, 1, LUA_TNUMBER);
140  /* Return random number */
141  lua_pushnumber(pt_state, pcRNG->Gaussian(lua_tonumber(pt_state, 1)));
142  return 1;
143  }
144  else {
145  /* Check parameters */
146  luaL_checktype(pt_state, 1, LUA_TNUMBER);
147  luaL_checktype(pt_state, 2, LUA_TNUMBER);
148  /* Return random number */
149  lua_pushnumber(pt_state,
150  pcRNG->Gaussian(lua_tonumber(pt_state, 1),
151  lua_tonumber(pt_state, 2)));
152  return 1;
153  }
154  /* Can't reach this point */
155  return 0;
156  }
157 
158  /****************************************/
159  /****************************************/
160 
161  bool CLuaUtility::LoadScript(lua_State* pt_state,
162  const std::string& str_filename) {
163  if(luaL_loadfile(pt_state, str_filename.c_str())) {
164  return false;
165  }
166  if(lua_pcall(pt_state, 0, 0, 0)) {
167  return false;
168  }
169  return true;
170  }
171 
172  /****************************************/
173  /****************************************/
174 
175  bool CLuaUtility::CallLuaFunction(lua_State* pt_state,
176  const std::string& str_function) {
177  lua_getglobal(pt_state, str_function.c_str());
178  if(lua_pcall(pt_state, 0, 0, 0)) {
179  return false;
180  }
181  return true;
182  }
183 
184  /****************************************/
185  /****************************************/
186 
187  void PrintStackEntry(CARGoSLog& c_log, lua_State* pt_state, SInt32 n_index) {
188  switch(lua_type(pt_state, n_index)) {
189  case LUA_TBOOLEAN: c_log << lua_toboolean(pt_state, n_index); break;
190  case LUA_TNUMBER: c_log << lua_tonumber(pt_state, n_index); break;
191  case LUA_TSTRING: c_log << lua_tostring(pt_state, n_index); break;
192  default: c_log << lua_topointer(pt_state, n_index); break;
193  }
194  }
195 
197  lua_State* pt_state,
198  size_t un_depth) {
199  for(size_t i = 0; i < un_depth; ++i) {
200  c_log << " ";
201  }
202  PrintStackEntry(c_log, pt_state, -2);
203  c_log << " [" << lua_typename(pt_state, lua_type(pt_state, -1)) << "] ";
204  if(lua_istable(pt_state, -1)) {
205  c_log << std::endl;
206  lua_pushnil(pt_state);
207  while(lua_next(pt_state, -2)) {
208  if(lua_type(pt_state, -1) != LUA_TFUNCTION &&
209  (lua_type(pt_state, -2) != LUA_TSTRING ||
210  (std::string(lua_tostring(pt_state, -2)) != "_G" &&
211  std::string(lua_tostring(pt_state, -2)) != "_VERSION" &&
212  std::string(lua_tostring(pt_state, -2)) != "package" &&
213  std::string(lua_tostring(pt_state, -2)) != "string" &&
214  std::string(lua_tostring(pt_state, -2)) != "os" &&
215  std::string(lua_tostring(pt_state, -2)) != "io" &&
216  std::string(lua_tostring(pt_state, -2)) != "math" &&
217  std::string(lua_tostring(pt_state, -2)) != "debug" &&
218  std::string(lua_tostring(pt_state, -2)) != "coroutine" &&
219  std::string(lua_tostring(pt_state, -2)) != "table"))) {
220  RecursivePrintGlobals(c_log, pt_state, un_depth+1);
221  }
222  lua_pop(pt_state, 1);
223  }
224  }
225  else {
226  PrintStackEntry(c_log, pt_state, -1);
227  c_log << std::endl;
228  }
229  }
230 
232  lua_State* pt_state) {
233  c_log << "*** LUA GLOBALS START ***" << std::endl;
234  lua_getglobal(pt_state, "_G");
235  RecursivePrintGlobals(c_log, pt_state, 0);
236  lua_pop(pt_state, 1);
237  c_log << "*** LUA GLOBALS END ***" << std::endl;
238 #ifdef ARGOS_THREADSAFE_LOG
239  c_log.Flush();
240 #endif
241  }
242 
243  /****************************************/
244  /****************************************/
245 
247  lua_State* pt_state) {
248  c_log << "*** LUA STACK START ***" << std::endl;
249  size_t unTop = lua_gettop(pt_state);
250  c_log << "Elements in stack: " << unTop << std::endl;
251  for(size_t i = unTop; i > 0; --i) {
252  c_log << "#" << i << " [" << lua_typename(pt_state, lua_type(pt_state, i)) << "] ";
253  PrintStackEntry(c_log, pt_state, i);
254  c_log << std::endl;
255  }
256  c_log << "*** LUA STACK END ***" << std::endl;
257 #ifdef ARGOS_THREADSAFE_LOG
258  c_log.Flush();
259 #endif
260  }
261 
262  /****************************************/
263  /****************************************/
264 
265  void CLuaUtility::RegisterLoggerWrapper(lua_State* pt_state) {
266  lua_register(pt_state, "log", LOGWrapper);
267  lua_register(pt_state, "logerr", LOGERRWrapper);
268  }
269 
270  /****************************************/
271  /****************************************/
272 
273  void CLuaUtility::RegisterRNG(lua_State* pt_state,
274  CRandom::CRNG* pc_rng) {
275  pc_rng->Reset();
276  OpenRobotStateTable(pt_state, "random");
277  AddToTable(pt_state, "_instance", pc_rng);
278  AddToTable(pt_state, "bernoulli", &LuaRNGBernoulli);
279  AddToTable(pt_state, "uniform", &LuaRNGUniform);
280  AddToTable(pt_state, "uniform_int", &LuaRNGUniformInt);
281  AddToTable(pt_state, "exponential", &LuaRNGExponential);
282  AddToTable(pt_state, "gaussian", &LuaRNGGaussian);
283  CloseRobotStateTable(pt_state);
284  }
285 
286  /****************************************/
287  /****************************************/
288 
289  void CLuaUtility::OpenRobotStateTable(lua_State* pt_state,
290  const std::string& str_key) {
291  lua_pushstring(pt_state, str_key.c_str());
292  lua_rawget(pt_state, -2);
293  if(lua_isnil(pt_state, -1)) {
294  lua_pop(pt_state, 1);
295  StartTable(pt_state, str_key);
296  EndTable(pt_state);
297  lua_pushstring(pt_state, str_key.c_str());
298  lua_rawget(pt_state, -2);
299  }
300  }
301 
302  /****************************************/
303  /****************************************/
304 
305  void CLuaUtility::CloseRobotStateTable(lua_State* pt_state) {
306  lua_pop(pt_state, 1);
307  }
308 
309  /****************************************/
310  /****************************************/
311 
312  void CLuaUtility::StartTable(lua_State* pt_state,
313  const std::string& str_key) {
314  lua_pushstring(pt_state, str_key.c_str());
315  lua_newtable (pt_state);
316  }
317 
318  /****************************************/
319  /****************************************/
320 
321  void CLuaUtility::StartTable(lua_State* pt_state,
322  int n_key) {
323  lua_pushnumber(pt_state, n_key);
324  lua_newtable (pt_state);
325  }
326 
327  /****************************************/
328  /****************************************/
329 
330  void CLuaUtility::EndTable(lua_State* pt_state) {
331  lua_settable(pt_state, -3);
332  }
333 
334  /****************************************/
335  /****************************************/
336 
337  void CLuaUtility::AddToTable(lua_State* pt_state,
338  const std::string& str_key,
339  void* pt_data) {
340  lua_pushstring (pt_state, str_key.c_str());
341  lua_pushlightuserdata(pt_state, pt_data );
342  lua_settable (pt_state, -3 );
343  }
344 
345  /****************************************/
346  /****************************************/
347 
348  void CLuaUtility::AddToTable(lua_State* pt_state,
349  const std::string& str_key,
350  lua_CFunction t_data) {
351  lua_pushstring (pt_state, str_key.c_str());
352  lua_pushcfunction(pt_state, t_data );
353  lua_settable (pt_state, -3 );
354  }
355 
356  /****************************************/
357  /****************************************/
358 
359  void CLuaUtility::AddToTable(lua_State* pt_state,
360  const std::string& str_key,
361  Real f_data) {
362  lua_pushstring(pt_state, str_key.c_str());
363  lua_pushnumber(pt_state, f_data );
364  lua_settable (pt_state, -3 );
365  }
366 
367  /****************************************/
368  /****************************************/
369 
370  void CLuaUtility::AddToTable(lua_State* pt_state,
371  const std::string& str_key,
372  const std::string& str_data){
373  lua_pushstring(pt_state, str_key.c_str() );
374  lua_pushstring(pt_state, str_data.c_str());
375  lua_settable (pt_state, -3 );
376  }
377 
378  /****************************************/
379  /****************************************/
380 
381  void CLuaUtility::AddToTable(lua_State* pt_state,
382  int n_key,
383  Real f_data) {
384  lua_pushnumber(pt_state, n_key );
385  lua_pushnumber(pt_state, f_data);
386  lua_settable (pt_state, -3 );
387  }
388 
389  /****************************************/
390  /****************************************/
391 
392  void CLuaUtility::AddToTable(lua_State* pt_state,
393  const std::string& str_key,
394  const CRadians& c_data) {
395  lua_pushstring(pt_state, str_key.c_str() );
396  lua_pushnumber(pt_state, c_data.GetValue());
397  lua_settable (pt_state, -3 );
398  }
399 
400  /****************************************/
401  /****************************************/
402 
403  void CLuaUtility::AddToTable(lua_State* pt_state,
404  int n_key,
405  const CRadians& c_data) {
406  lua_pushnumber(pt_state, n_key );
407  lua_pushnumber(pt_state, c_data.GetValue());
408  lua_settable (pt_state, -3 );
409  }
410 
411  /****************************************/
412  /****************************************/
413 
414  void CLuaUtility::AddToTable(lua_State* pt_state,
415  const std::string& str_key,
416  const CVector2& c_data) {
417  StartTable(pt_state, str_key );
418  AddToTable(pt_state, "_type", TYPE_VECTOR2 );
419  AddToTable(pt_state, "x", c_data.GetX());
420  AddToTable(pt_state, "y", c_data.GetY());
421  EndTable (pt_state );
422  }
423 
424  /****************************************/
425  /****************************************/
426 
427  void CLuaUtility::AddToTable(lua_State* pt_state,
428  int n_key,
429  const CVector2& c_data) {
430  StartTable(pt_state, n_key );
431  AddToTable(pt_state, "_type", TYPE_VECTOR2 );
432  AddToTable(pt_state, "x", c_data.GetX());
433  AddToTable(pt_state, "y", c_data.GetY());
434  EndTable (pt_state );
435  }
436 
437  /****************************************/
438  /****************************************/
439 
440  void CLuaUtility::AddToTable(lua_State* pt_state,
441  const std::string& str_key,
442  const CVector3& c_data) {
443  StartTable(pt_state, str_key );
444  AddToTable(pt_state, "_type", TYPE_VECTOR3 );
445  AddToTable(pt_state, "x", c_data.GetX());
446  AddToTable(pt_state, "y", c_data.GetY());
447  AddToTable(pt_state, "z", c_data.GetZ());
448  EndTable (pt_state );
449  }
450 
451  /****************************************/
452  /****************************************/
453 
454  void CLuaUtility::AddToTable(lua_State* pt_state,
455  int n_key,
456  const CVector3& c_data) {
457  StartTable(pt_state, n_key );
458  AddToTable(pt_state, "_type", TYPE_VECTOR3 );
459  AddToTable(pt_state, "x", c_data.GetX());
460  AddToTable(pt_state, "y", c_data.GetY());
461  AddToTable(pt_state, "z", c_data.GetZ());
462  EndTable (pt_state );
463  }
464 
465  /****************************************/
466  /****************************************/
467 
468  void CLuaUtility::AddToTable(lua_State* pt_state,
469  const std::string& str_key,
470  const CQuaternion& c_data) {
471  CRadians cAngle;
472  CVector3 cAxis;
473  c_data.ToAngleAxis(cAngle, cAxis);
474  StartTable(pt_state, str_key );
475  AddToTable(pt_state, "_type", TYPE_QUATERNION);
476  AddToTable(pt_state, "angle", cAngle );
477  AddToTable(pt_state, "axis", cAxis );
478  EndTable (pt_state );
479  }
480 
481  /****************************************/
482  /****************************************/
483 
484  void CLuaUtility::AddToTable(lua_State* pt_state,
485  int n_key,
486  const CQuaternion& c_data) {
487  CRadians cAngle;
488  CVector3 cAxis;
489  c_data.ToAngleAxis(cAngle, cAxis);
490  StartTable(pt_state, n_key );
491  AddToTable(pt_state, "_type", TYPE_QUATERNION);
492  AddToTable(pt_state, "angle", cAngle );
493  AddToTable(pt_state, "axis", cAxis );
494  EndTable (pt_state );
495  }
496 
497  /****************************************/
498  /****************************************/
499 
500  void CLuaUtility::AddToTable(lua_State* pt_state,
501  const std::string& str_key,
502  const CColor& c_data) {
503  StartTable(pt_state, str_key );
504  AddToTable(pt_state, "_type", TYPE_COLOR );
505  AddToTable(pt_state, "red", c_data.GetRed() );
506  AddToTable(pt_state, "green", c_data.GetGreen());
507  AddToTable(pt_state, "blue", c_data.GetBlue() );
508  EndTable (pt_state );
509  }
510 
511  /****************************************/
512  /****************************************/
513 
514  void CLuaUtility::AddToTable(lua_State* pt_state,
515  int n_key,
516  const CColor& c_data) {
517  StartTable(pt_state, n_key );
518  AddToTable(pt_state, "_type", TYPE_COLOR );
519  AddToTable(pt_state, "red", c_data.GetRed() );
520  AddToTable(pt_state, "green", c_data.GetGreen());
521  AddToTable(pt_state, "blue", c_data.GetBlue() );
522  EndTable (pt_state );
523  }
524 
525  /****************************************/
526  /****************************************/
527 
528  int CLuaUtility::LOGWrapper(lua_State* pt_state) {
529  return LoggerWrapper(LOG, pt_state);
530  }
531 
532  /****************************************/
533  /****************************************/
534 
535  int CLuaUtility::LOGERRWrapper(lua_State* pt_state) {
536  return LoggerWrapper(LOGERR, pt_state);
537  }
538 
539  /****************************************/
540  /****************************************/
541 
542  int CLuaUtility::LoggerWrapper(CARGoSLog& c_log,
543  lua_State* pt_state) {
544  /* Get number of arguments */
545  UInt32 unArgc = lua_gettop(pt_state);
546  /* Send arguments to log one by one */
547  UInt32 unType;
548  for(UInt32 i = 1; i <= unArgc; ++i) {
549  unType = lua_type(pt_state, i);
550  switch(unType) {
551  case LUA_TBOOLEAN: c_log << lua_toboolean(pt_state, i); break;
552  case LUA_TNUMBER: c_log << lua_tonumber (pt_state, i); break;
553  case LUA_TSTRING: c_log << lua_tostring (pt_state, i); break;
554  default: c_log << lua_typename (pt_state, unType); break;
555  }
556  }
557  c_log << std::endl;
558  /* No result is calculated */
559  return 0;
560  }
561 
562  /****************************************/
563  /****************************************/
564 
565 }
The RNG.
Definition: rng.h:90
void ToAngleAxis(CRadians &c_angle, CVector3 &c_vector) const
Definition: quaternion.h:143
static void AddToTable(lua_State *pt_state, const std::string &str_key, void *pt_data)
Adds a pointer to a chunk of data with the given string key to the table located at the top of the st...
bool Bernoulli(Real f_true=0.5)
Returns a random value from a Bernoulli distribution.
Definition: rng.cpp:80
signed int SInt32
32-bit signed integer.
Definition: datatypes.h:93
int LuaRNGExponential(lua_State *pt_state)
int LuaRNGUniform(lua_State *pt_state)
Definition: lua_utility.cpp:47
A 3D vector class.
Definition: vector3.h:29
int LuaRNGGaussian(lua_State *pt_state)
int LuaRNGUniformInt(lua_State *pt_state)
Definition: lua_utility.cpp:83
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
CARGoSLog LOG(std::cout, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_GREEN))
Definition: argos_log.h:179
Real GetX() const
Returns the x coordinate of this vector.
Definition: vector2.h:78
static void RegisterRNG(lua_State *pt_state, CRandom::CRNG *pc_rng)
Registers the given random number generator in the Lua state.
Real GetX() const
Returns the x coordinate of this vector.
Definition: vector3.h:93
static bool LoadScript(lua_State *pt_state, const std::string &str_filename)
Loads the given Lua script.
void PrintStackEntry(CARGoSLog &c_log, lua_State *pt_state, SInt32 n_index)
static bool CallLuaFunction(lua_State *pt_state, const std::string &str_function)
Calls a parameter-less function in the Lua script.
Real GetY() const
Returns the y coordinate of this vector.
Definition: vector3.h:109
UInt8 GetGreen() const
Returns the green channel of the color.
Definition: color.h:90
Real GetY() const
Returns the y coordinate of this vector.
Definition: vector2.h:94
void Reset()
Reset the RNG.
Definition: rng.cpp:68
int LuaRNGBernoulli(lua_State *pt_state)
Definition: lua_utility.cpp:22
It defines the basic type CRadians, used to store an angle value in radians.
Definition: angles.h:42
unsigned int UInt32
32-bit unsigned integer.
Definition: datatypes.h:97
CRadians Uniform(const CRange< CRadians > &c_range)
Returns a random value from a uniform distribution.
Definition: rng.cpp:87
static void PrintGlobals(CARGoSLog &c_log, lua_State *pt_state)
Prints the global Lua symbols on the specified log.
static void PrintStack(CARGoSLog &c_log, lua_State *pt_state)
Prints the Lua stack on the specified log.
A 2D vector class.
Definition: vector2.h:25
void RecursivePrintGlobals(CARGoSLog &c_log, lua_State *pt_state, size_t un_depth)
UInt8 GetRed() const
Returns the red channel of the color.
Definition: color.h:79
CARGoSLog LOGERR(std::cerr, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_RED))
Definition: argos_log.h:180
static void RegisterLoggerWrapper(lua_State *pt_state)
Registers LOG and LOGERR in the Lua state.
The basic color type.
Definition: color.h:25
Real Exponential(Real f_mean)
Returns a random value from an exponential distribution.
Definition: rng.cpp:123
Real GetValue() const
Returns the value in radians.
Definition: angles.h:111
static void StartTable(lua_State *pt_state, const std::string &str_key)
Adds a table with the given string key to the table located at the top of the stack.
Real Gaussian(Real f_std_dev, Real f_mean=0.0f)
Returns a random value from a Gaussian distribution.
Definition: rng.cpp:131
UInt8 GetBlue() const
Returns the blue channel of the color.
Definition: color.h:101
static void OpenRobotStateTable(lua_State *pt_state, const std::string &str_key)
Opens a table in the robot state, creating it if it does not exist.
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
static void CloseRobotStateTable(lua_State *pt_state)
Closes a table in the robot state.
Real GetZ() const
Returns the z coordinate of this vector.
Definition: vector3.h:125
static void EndTable(lua_State *pt_state)
Adds a table to the Lua stack.
SInt32 Floor(Real f_value)
Rounds the passed floating-point value to the closest lower integer.
Definition: general.h:140