gazebo.i

来自「机器人人3D仿真工具,可以加入到Simbad仿真环境下应用。」· I 代码 · 共 104 行

I
104
字号
%module gazebo%{#include "gazebo.h"%}// Provide array (read) access%typemap(out) double [ANY] {  int i;  $result = PyList_New($1_dim0);  for (i = 0; i < $1_dim0; i++)   {    PyObject *o = PyFloat_FromDouble((double) $1[i]);    PyList_SetItem($result,i,o);  }}// Provide array access doubly-dimensioned arrays%typemap(out) double [ANY][ANY] {  int i, j;  $result = PyList_New($1_dim0);  for (i = 0; i < $1_dim0; i++)   {    PyObject *l = PyList_New($1_dim1);    for (j = 0; j < $1_dim1; j++)    {      PyObject *o = PyFloat_FromDouble((double) $1[i][j]);      PyList_SetItem(l,j,o);    }    PyList_SetItem($result,i,l);  }}// Provide array (write) access%typemap(in) double [ANY] (double temp[$1_dim0]){  int i;  if (!PySequence_Check($input))  {    PyErr_SetString(PyExc_ValueError,"Expected a sequence");    return NULL;  }  if (PySequence_Length($input) != $1_dim0)   {    PyErr_SetString(PyExc_ValueError,"Size mismatch. Expected $1_dim0 elements");    return NULL;  }  for (i = 0; i < $1_dim0; i++)   {    PyObject *o = PySequence_GetItem($input,i);    if (PyNumber_Check(o))     {      temp[i] = (double) PyFloat_AsDouble(o);    }     else     {      PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");            return NULL;    }  }  $1 = temp;}// Provide write access to arrays that are structure members%typemap(memberin) double [ANY]{  int i;  for (i = 0; i < $1_dim0; i++)    $1[i] = $input[i];}// Provide read access for string data%typemap(out) char [ANY] {  $result = PyString_FromString($1);}// TODO: tighten up this test// Provide read access for image data%typemap(out) unsigned char [ANY] {  $result = PyString_FromStringAndSize($1, $1_dim0);}// TODO: tighten up this test; could match to almost anything// Provide read access for image data%typemap(out) float [ANY] {  $result = PyString_FromStringAndSize((void*) $1, $1_dim0);} //%include "../../gazebo.h"%include "gazebo_oo.i"

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?