Issue sending data from C++ to Python
Christian Gollwitzer
auriocus at gmx.de
Wed May 18 15:53:09 EDT 2022
Am 18.05.22 um 16:08 schrieb Pablo Martinez Ulloa:
> I have been using your C++ Python API, in order to establish a bridge from
> C++ to Python. We want to do this, as we have a tactile sensor, which only
> has a library developed in C++, but we want to obtain the data in real time
> in Python to perform tests with a robotic arm and gripper. The problem we
> are facing is with transmitting the data into Python. We are using the
> function Py_BuildValue, and it seems to be working, but only for sending
> one value at a time, and we want to transmit 54 numbers
The usual way to pass an array of numbers into Python is by means of a
Numpy Array. In order to do that, you need to include arrayobject.h and
then use PyArray_SimpleNew to create an array of numbers as a Python
object which you can return
https://numpy.org/devdocs/reference/c-api/array.html#c.PyArray_SimpleNew
Christian
More information about the Python-list
mailing list