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