Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register bindings for new device interfaces #3003

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion bindings/yarp.i
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@
%include <stdint.i>
%include <std_vector.i>

// Try to translate std::string to native equivalents
// Try to translate std::string and std::pair to native equivalents
%include "std_string.i"
%include "std_pair.i"

#if defined(SWIGCSHARP)
// Get .NET pointers instead of swig generated types (useful when dealing with images)
Expand Down Expand Up @@ -427,6 +428,9 @@ MAKE_COMMS(Bottle)
%include <yarp/dev/IRemoteVariables.h>
%include <yarp/dev/IPidControl.h>
%include <yarp/dev/IPositionDirect.h>
%include <yarp/dev/ISpeechSynthesizer.h>
%include <yarp/dev/ISpeechTranscription.h>
%include <yarp/dev/ILLM.h>
%include <yarp/dev/MultipleAnalogSensorsInterfaces.h>

#ifndef YARP_NO_DEPRECATED // Since YARP 3.5.0
Expand All @@ -440,6 +444,8 @@ MAKE_COMMS(Bottle)
%template(SVector) std::vector<std::string>;
%template(IVector) std::vector<int>;
%template(ShortVector) std::vector<short int>;
%template() std::pair<std::string, std::string>;
%template(SPairVector) std::vector<std::pair<std::string, std::string>>;

#ifdef SWIGMATLAB
// Extend IVector for handling conversion of vectors from and to Matlab
Expand Down Expand Up @@ -818,6 +824,9 @@ typedef yarp::os::BufferedPort<ImageRgbFloat> BufferedPortImageRgbFloat;
CAST_POLYDRIVER_TO_INTERFACE(IPositionDirect)
CAST_POLYDRIVER_TO_INTERFACE(IRemoteVariables)
CAST_POLYDRIVER_TO_INTERFACE(IAxisInfo)
CAST_POLYDRIVER_TO_INTERFACE(ISpeechSynthesizer)
CAST_POLYDRIVER_TO_INTERFACE(ISpeechTranscription)
CAST_POLYDRIVER_TO_INTERFACE(ILLM)

// These views are currently disabled in SWIG + java generator since they are
// useless without the EXTENDED_ANALOG_SENSOR_INTERFACE part.
Expand Down Expand Up @@ -1543,6 +1552,44 @@ typedef yarp::os::BufferedPort<ImageRgbFloat> BufferedPortImageRgbFloat;
}
}

%extend yarp::dev::ISpeechSynthesizer {
bool getLanguage(std::vector<string>& language) {
return self->getLanguage(language[0]);
}

bool getVoice(std::vector<string>& voice) {
return self->getVoice(voice[0]);
}

bool getSpeed(std::vector<double>& speed) {
return self->getSpeed(speed[0]);
}

bool getPitch(std::vector<double>& pitch) {
return self->getPitch(pitch[0]);
}
}

%extend yarp::dev::ISpeechTranscription {
bool getLanguage(std::vector<string>& language) {
return self->getLanguage(language[0]);
}

bool transcribe(const yarp::sig::Sound& sound, std::vector<string>& transcription, std::vector<double>& score) {
return self->transcribe(sound, transcription[0], score[0]);
}
}

%extend yarp::dev::ILLM {
bool readPrompt(std::vector<string>& oPropmt) {
return self->readPrompt(oPropmt[0]);
}

bool ask(const std::string& question, std::vector<string>& answer) {
return self->ask(question, answer[0]);
}
}

// This is part is currently broken in SWIG + java generator since SWIG 3.0.3
// (last swig version tested: 3.0.12)
// See also https://github.com/robotology/yarp/issues/1770
Expand Down
3 changes: 3 additions & 0 deletions src/libYARP_dev/src/yarp/dev/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include <yarp/dev/ServiceInterfaces.h>
#include <yarp/dev/IWrapper.h>
#include <yarp/dev/IMultipleWrapper.h>
#include <yarp/dev/ISpeechSynthesizer.h>
#include <yarp/dev/ISpeechTranscription.h>
#include <yarp/dev/ILLM.h>

#ifndef YARP_NO_DEPRECATED // since YARP 3.5
#define YARP_INCLUDING_DEPRECATED_HEADER_YARP_DEV_FRAMEGRABBER_H_ON_PURPOSE
Expand Down
Loading