ci_footbot_gripper_actuator.cpp
Go to the documentation of this file.
1 
8 
9 #ifdef ARGOS_WITH_LUA
10 #include <argos3/core/wrappers/lua/lua_utility.h>
11 #endif
12 
13 namespace argos {
14 
15  /****************************************/
16  /****************************************/
17 
21 
24 
25  /****************************************/
26  /****************************************/
27 
28 #ifdef ARGOS_WITH_LUA
29  /*
30  * The stack must have no values
31  */
32  int LuaGripperLockPositive(lua_State* pt_lua_state) {
33  /* Get wheel speed from stack */
34  if(lua_gettop(pt_lua_state) != 0) {
35  return luaL_error(pt_lua_state, "robot.gripper.lock_positive() expects no arguments");
36  }
37  /* Perform action */
38  CLuaUtility::GetDeviceInstance<CCI_FootBotGripperActuator>(pt_lua_state, "gripper")->LockPositive();
39  return 0;
40  }
41 
42  /*
43  * The stack must have no values
44  */
45  int LuaGripperLockNegative(lua_State* pt_lua_state) {
46  /* Get wheel speed from stack */
47  if(lua_gettop(pt_lua_state) != 0) {
48  return luaL_error(pt_lua_state, "robot.gripper.lock_negative() expects no arguments");
49  }
50  /* Perform action */
51  CLuaUtility::GetDeviceInstance<CCI_FootBotGripperActuator>(pt_lua_state, "gripper")->LockNegative();
52  return 0;
53  }
54 
55  /*
56  * The stack must have no values
57  */
58  int LuaGripperUnlock(lua_State* pt_lua_state) {
59  /* Get wheel speed from stack */
60  if(lua_gettop(pt_lua_state) != 0) {
61  return luaL_error(pt_lua_state, "robot.gripper.unlock() expects no arguments");
62  }
63  /* Perform action */
64  CLuaUtility::GetDeviceInstance<CCI_FootBotGripperActuator>(pt_lua_state, "gripper")->Unlock();
65  return 0;
66  }
67 #endif
68 
69  /****************************************/
70  /****************************************/
71 
73  m_cAperture(UNLOCKED) {}
74 
75  /****************************************/
76  /****************************************/
77 
79  m_cAperture = c_aperture;
81  APERTURE_RANGE.TruncValue(m_cAperture);
82  }
83 
84  /****************************************/
85  /****************************************/
86 
89  }
90 
91  /****************************************/
92  /****************************************/
93 
96  }
97 
98  /****************************************/
99  /****************************************/
100 
103  }
104 
105  /****************************************/
106  /****************************************/
107 
108 #ifdef ARGOS_WITH_LUA
109  void CCI_FootBotGripperActuator::CreateLuaState(lua_State* pt_lua_state) {
110  CLuaUtility::OpenRobotStateTable (pt_lua_state, "gripper" );
111  CLuaUtility::AddToTable (pt_lua_state, "_instance", this );
112  CLuaUtility::AddToTable (pt_lua_state, "lock_positive", &LuaGripperLockPositive);
113  CLuaUtility::AddToTable (pt_lua_state, "lock_negative", &LuaGripperLockNegative);
114  CLuaUtility::AddToTable (pt_lua_state, "unlock", &LuaGripperUnlock );
115  CLuaUtility::CloseRobotStateTable(pt_lua_state );
116  }
117 #endif
118 
119  /****************************************/
120  /****************************************/
121 
122 }
#define ARGOS_PI
To be used when initializing static variables.
Definition: angles.h:32
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
CRange< CRadians > APERTURE_RANGE(CCI_FootBotGripperActuator::LOCKED_NEGATIVE, CCI_FootBotGripperActuator::LOCKED_POSITIVE)
It defines the basic type CRadians, used to store an angle value in radians.
Definition: angles.h:42
CRadians & SignedNormalize()
Normalizes the value in the range [-PI:PI].
Definition: angles.h:137
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 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.
void SetAperture(const CRadians &c_aperture)
Sets the gripper aperture.
void Unlock()
Unlock gripper: objects are released.
void LockNegative()
Sets gripper aperture to lock, negative direction.
void LockPositive()
Sets gripper aperture to lock, positive direction.