Exemple #1
0
/*luadoc
@function model.getInputsCount(input)

Returns number of lines for given input 

@param input (unsigned number) input number (use 0 for Input1)

@retval number number of configured lines for given input

@status current Introduced in 2.0.0
*/
static int luaModelGetInputsCount(lua_State *L)
{
  unsigned int chn = luaL_checkunsigned(L, 1);
  int count = getInputsCount(chn);
  lua_pushinteger(L, count);
  return 1;
}
vect_n<double> manipulator_dynamics_model::getInput() const {
  vect_n<double> result(getInputsCount());
  
  unsigned int i = 0;
  for(std::vector< shared_ptr<system_input> >::const_iterator it = mInputs.begin(); it != mInputs.end(); ++it)
    for(unsigned int k = 0; k < (*it)->getInputCount(); ++k)
      result[i++] = (*it)->getInput(k);
  return result;
};
void RK_CALL manipulator_dynamics_model::setInput(const ReaK::vect_n<double>& aInput) {
  if(aInput.size() != getInputsCount())
    throw std::range_error("The size of the input-vector to the manipulator model is not correct!");
  
  unsigned int i = 0;
  for(std::vector< shared_ptr<system_input> >::iterator it = mInputs.begin(); it != mInputs.end(); ++it)
    for(unsigned int k = 0; k < (*it)->getInputCount(); ++k)
      (*it)->setInput(k,aInput[i++]);
};