ARGoS 3
A parallel, multi-engine simulator for swarm robotics
ci_footbot_turret_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
13namespace argos {
14
15 /****************************************/
16 /****************************************/
17
18 const CRange<SInt32> CCI_FootBotTurretActuator::SPEED_RANGE(-4,4);
19 const CRange<Real> CCI_FootBotTurretActuator::NORMALIZED_SPEED_RANGE(-1.0,1.0);
20
21 /****************************************/
22 /****************************************/
23
24#ifdef ARGOS_WITH_LUA
25 int LuaTurretSetRotation(lua_State* pt_lua_state) {
26 /* Check parameters */
27 if(lua_gettop(pt_lua_state) != 1) {
28 return luaL_error(pt_lua_state, "robot.turret.set_rotation() expects 1 argument");
29 }
30 luaL_checktype(pt_lua_state, 1, LUA_TNUMBER);
31 /* Perform action */
33 SetRotation(CRadians(lua_tonumber(pt_lua_state, 1)));
34 return 0;
35 }
36#endif
37
38#ifdef ARGOS_WITH_LUA
39 int LuaTurretSetRotationSpeed(lua_State* pt_lua_state) {
40 /* Check parameters */
41 if(lua_gettop(pt_lua_state) != 1) {
42 return luaL_error(pt_lua_state, "robot.turret.set_rotation_speed() expects 1 argument");
43 }
44 luaL_checktype(pt_lua_state, 1, LUA_TNUMBER);
45 /* Perform action */
47 SetRotationSpeed(lua_tonumber(pt_lua_state, 1));
48 return 0;
49 }
50#endif
51
52#ifdef ARGOS_WITH_LUA
53 int LuaTurretSetSpeedControlMode(lua_State* pt_lua_state) {
54 /* Check parameters */
55 if(lua_gettop(pt_lua_state) != 0) {
56 return luaL_error(pt_lua_state, "robot.turret.set_speed_control_mode() expects no arguments");
57 }
58 /* Perform action */
60 SetSpeedControlMode();
61 return 0;
62 }
63#endif
64
65#ifdef ARGOS_WITH_LUA
66 int LuaTurretSetPositionControlMode(lua_State* pt_lua_state) {
67 /* Check parameters */
68 if(lua_gettop(pt_lua_state) != 0) {
69 return luaL_error(pt_lua_state, "robot.turret.set_position_control_mode() expects no arguments");
70 }
71 /* Perform action */
73 SetPositionControlMode();
74 return 0;
75 }
76#endif
77
78#ifdef ARGOS_WITH_LUA
79 int LuaTurretSetPassiveMode(lua_State* pt_lua_state) {
80 /* Check parameters */
81 if(lua_gettop(pt_lua_state) != 0) {
82 return luaL_error(pt_lua_state, "robot.turret.set_passive_mode() expects no arguments");
83 }
84 /* Perform action */
86 SetPassiveMode();
87 return 0;
88 }
89#endif
90
91 /****************************************/
92 /****************************************/
93
98
99 /****************************************/
100 /****************************************/
101
105
106 /****************************************/
107 /****************************************/
108
112
113 /****************************************/
114 /****************************************/
115
119
120 /****************************************/
121 /****************************************/
122
123#ifdef ARGOS_WITH_LUA
124 void CCI_FootBotTurretActuator::CreateLuaState(lua_State* pt_lua_state) {
125 CLuaUtility::OpenRobotStateTable(pt_lua_state, "turret");
126 CLuaUtility::AddToTable(pt_lua_state, "_instance", this);
127 CLuaUtility::AddToTable(pt_lua_state, "set_rotation", &LuaTurretSetRotation);
128 CLuaUtility::AddToTable(pt_lua_state, "set_rotation_speed", &LuaTurretSetRotationSpeed);
129 CLuaUtility::AddToTable(pt_lua_state, "set_position_control_mode", &LuaTurretSetPositionControlMode);
130 CLuaUtility::AddToTable(pt_lua_state, "set_speed_control_mode", &LuaTurretSetSpeedControlMode);
131 CLuaUtility::AddToTable(pt_lua_state, "set_passive_mode", &LuaTurretSetPassiveMode);
133 }
134#endif
135
136 /****************************************/
137 /****************************************/
138
139}
The namespace containing all the ARGoS related code.
Definition ci_actuator.h:12
virtual void CreateLuaState(lua_State *pt_lua_state)=0
Creates the Lua state for this actuator.
It defines the basic type CRadians, used to store an angle value in radians.
Definition angles.h:42
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.
static T * GetDeviceInstance(lua_State *pt_state, const std::string &str_key)
Returns a pointer to the instance to the wanted device.
void SetPassiveMode()
Sets the turret control mode to passive.
static const CRange< SInt32 > SPEED_RANGE
void SetActiveWithRotation(const CRadians &c_angle)
Sets the turret control mode to active, and sets the target rotation to the given one.
void SetSpeedControlMode()
Sets the turret control mode to speed control.
virtual void SetMode(ETurretModes e_mode)=0
Sets the turret control mode Modes are: angular position control, rotation speed control,...
virtual void SetRotation(const CRadians &c_angle)=0
Sets the turret rotation Turret rotation is expressed in radians, positive values rotate the turret c...
static const CRange< Real > NORMALIZED_SPEED_RANGE
void SetPositionControlMode()
Sets the turret control mode to position control.