ARGoS  3
A parallel, multi-engine simulator for swarm robotics
plugins/robots/generic/control_interface/ci_differential_steering_actuator.cpp
Go to the documentation of this file.
00001 
00008 #include "ci_differential_steering_actuator.h"
00009 
00010 #ifdef ARGOS_WITH_LUA
00011 #include <argos3/core/wrappers/lua/lua_utility.h>
00012 #endif
00013 
00014 namespace argos {
00015 
00016    /****************************************/
00017    /****************************************/
00018 
00019 #ifdef ARGOS_WITH_LUA
00020    /*
00021     * The stack must have two values in this order:
00022     * 1. left wheel speed (a number)
00023     * 2. right wheel speed (a number)
00024     */
00025    int LuaSetLinearVelocity(lua_State* pt_lua_state) {
00026       /* Check parameters */
00027       if(lua_gettop(pt_lua_state) != 2) {
00028          return luaL_error(pt_lua_state, "robot.wheels.set_velocity() expects 2 arguments");
00029       }
00030       luaL_checktype(pt_lua_state, 1, LUA_TNUMBER);
00031       luaL_checktype(pt_lua_state, 2, LUA_TNUMBER);
00032       /* Perform action */
00033       CLuaUtility::GetDeviceInstance<CCI_DifferentialSteeringActuator>(pt_lua_state, "wheels")->
00034          SetLinearVelocity(lua_tonumber(pt_lua_state, 1),
00035                            lua_tonumber(pt_lua_state, 2));
00036       return 0;
00037    }
00038 #endif
00039    
00040    /****************************************/
00041    /****************************************/
00042 
00043 #ifdef ARGOS_WITH_LUA
00044    void CCI_DifferentialSteeringActuator::CreateLuaState(lua_State* pt_lua_state) {
00045       CLuaUtility::OpenRobotStateTable(pt_lua_state, "wheels");
00046       CLuaUtility::AddToTable(pt_lua_state, "_instance", this);
00047       CLuaUtility::AddToTable(pt_lua_state, "set_velocity", &LuaSetLinearVelocity);
00048       CLuaUtility::CloseRobotStateTable(pt_lua_state);
00049    }
00050 #endif
00051 
00052    /****************************************/
00053    /****************************************/
00054 
00055 }