forked from robotology/yarp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyarp.i
1973 lines (1618 loc) · 60.4 KB
/
yarp.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
// SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
// SPDX-License-Identifier: BSD-3-Clause
//////////////////////////////////////////////////////////////////////////
//
// This is a configuration file to explain YARP to SWIG
//
// SWIG, for the most part, understands YARP auto-magically.
// There are a few things that need to be explained:
// + use of multiple inheritance
// + use of names that clash with special names in Java/Python/Perl/...
// + use of templates
%module(directors="1") yarp
%define SWIG_PREPROCESSOR_SHOULD_SKIP_THIS %enddef
// YARP_conf
%{
#include <yarp/conf/version.h>
#include <yarp/conf/compiler.h>
#include <yarp/conf/system.h>
#include <yarp/conf/api.h>
#include <yarp/conf/numeric.h>
#include <yarp/conf/string.h>
#include <yarp/conf/environment.h>
#include <yarp/conf/dirs.h>
%}
%include "yarp/conf/version.h"
%import "yarp/conf/compiler.h"
%import "yarp/conf/system.h"
%import "yarp/conf/api.h"
%import "yarp/conf/numeric.h"
%include "yarp/conf/string.h"
%include "yarp/conf/environment.h"
%include "yarp/conf/dirs.h"
// YARP_os
%{
#include <yarp/os/api.h>
%}
%import <yarp/os/api.h>
// YARP_sig
%{
#include <yarp/sig/api.h>
%}
%import <yarp/sig/api.h>
// YARP_dev
%{
#include <yarp/dev/api.h>
%}
%import <yarp/dev/api.h>
#if !defined (SWIGMATLAB)
%feature("director") yarp::os::PortReader;
%feature("director") yarp::os::RFModule;
%feature("director") yarp::os::Thread;
#endif
%feature("autodoc", "1");
#if defined (SWIGPYTHON) || defined (SWIGRUBY)
%include <argcargv.i>
%apply (int ARGC, char **ARGV) { (int argc, char *argv[]) }
#elif defined (SWIGLUA)
%include "lua/argcargv.i"
%apply (int ARGC, char **ARGV) { (int argc, char *argv[]) }
#endif
%include <stdint.i>
%include <std_vector.i>
// Try to translate std::string to native equivalents
%include "std_string.i"
#if defined(SWIGCSHARP)
// Get .NET pointers instead of swig generated types (useful when dealing with images)
%typemap(ctype) unsigned char * "unsigned char *"
%typemap(imtype) unsigned char * "System.IntPtr"
%typemap(cstype) unsigned char * "System.IntPtr"
%typemap(csin) unsigned char * "$csinput"
%typemap(in) unsigned char * %{ $1 = $input; %}
%typemap(out) unsigned char * %{ $result = $1; %}
%typemap(csout) unsigned char * { return $imcall; }
// there's a big CSHARP virtual/override muddle
// we just bypass the issue for now
%csmethodmodifiers write "public new";
%csmethodmodifiers check "public new";
%csmethodmodifiers check "public new";
%csmethodmodifiers find "public new";
%csmethodmodifiers findGroup "public new";
%csmethodmodifiers toString "public new";
%csmethodmodifiers lastRead "public new";
%csmethodmodifiers isClosed "public new";
%csmethodmodifiers read "public new";
%csmethodmodifiers setReplier "public new";
%csmethodmodifiers onRead "public virtual";
%csmethodmodifiers getPendingReads "public new";
%csmethodmodifiers setStrict "public new";
%csmethodmodifiers useCallback "public new";
%csmethodmodifiers onCommencement "public virtual";
%csmethodmodifiers disableCallback "public virtual";
%csmethodmodifiers acquire "public virtual";
%csmethodmodifiers release "public virtual";
%csmethodmodifiers isNull "public virtual";
%csmethodmodifiers setTargetPeriod "public new";
#endif
// Deal with abstract base class problems, where SWIG guesses
// incorrectly at whether a class can be instantiated or not
%feature("notabstract") Port;
%feature("notabstract") Value;
%feature("notabstract") BufferedPort;
%feature("notabstract") Bottle;
%feature("notabstract") Property;
%feature("notabstract") Stamp;
%feature("notabstract") RpcClient;
%feature("notabstract") RpcServer;
%feature("abstract") Portable;
%feature("abstract") PortReader;
%feature("abstract") PortWriter;
%feature("abstract") Searchable;
%feature("abstract") Contactable;
%feature("abstract") UnbufferedContactable;
%feature("abstract") AbstractContactable;
// Deal with overridden method clashes, simply by ignoring them.
// At some point, these methods should get renamed so they are still
// available.
%ignore *::check(const std::string& key, Value *& result) const;
%ignore *::check(const std::string& key, Value *& result, const std::string& comment) const;
%rename(where_c) *::where();
%rename(seed_c) *::seed(int seed); // perl clash
%ignore *::setKp(double);
%ignore *::setKi(double);
%ignore *::setKd(double);
%ignore *::setKff(double);
%ignore *::setScale(double);
%ignore *::setOffset(double);
%rename(attach_rpc_server) *::attach(yarp::os::RpcServer&);
%rename(open_str) yarp::dev::PolyDriver::open(const std::string& txt);
#if defined(SWIGCSHARP)
// there's a big CSHARP virtual/override muddle
// we just bypass the issue for now
%csmethodmodifiers write "public new";
%csmethodmodifiers check "public new";
%csmethodmodifiers check "public new";
%csmethodmodifiers find "public new";
%csmethodmodifiers findGroup "public new";
%csmethodmodifiers toString "public new";
%csmethodmodifiers lastRead "public new";
%csmethodmodifiers isClosed "public new";
%csmethodmodifiers read "public new";
%csmethodmodifiers setReplier "public new";
%csmethodmodifiers onRead "public new";
%csmethodmodifiers getPendingReads "public new";
%csmethodmodifiers setStrict "public new";
%csmethodmodifiers useCallback "public new";
#endif
// Deal with method name conflicts
#ifndef SWIGJAVA
%rename(toString_c) *::toString() const;
#endif
// python conflict
#ifdef SWIGPYTHON
%rename(yield_c) *::yield();
#endif
// java conflict
#ifdef SWIGJAVA
%rename(wait_c) *::wait();
%rename(clone_c) *::clone() const;
%rename(toString_c) *::toString() const;
#endif
#ifdef SWIGTCL
%rename(configure_c) *::configure();
#endif
//////////////////////////////////////////////////////////////////////////
// Clean up a few unimportant things that give warnings
// abstract methods just confuse SWIG
%ignore yarp::os::BufferedPort::open; // let Contactable::open show
%ignore yarp::os::Port::open; // let Contactable::open show
%ignore yarp::os::RpcClient::open;
// operator= does not get translated well
%ignore *::operator=;
%ignore yarp::PortReaderBuffer;
%ignore yarp::sig::Image::operator()(int,int) const;
%ignore yarp::sig::Image::pixel(int,int) const;
%ignore yarp::sig::Image::getRow(int) const;
%ignore yarp::sig::Image::getIplImage() const;
%ignore yarp::sig::Image::getReadType() const;
%ignore yarp::sig::VectorOf<double>::getType() const;
%ignore yarp::sig::VectorOf<double>::VectorOf(std::initializer_list<double>);
%ignore yarp::sig::VectorOf<int>::getType() const;
%ignore yarp::sig::VectorOf<int>::VectorOf(std::initializer_list<int>);
%ignore yarp::os::Property::put(const char *,Value *);
%ignore yarp::os::Bottle::add(Value *);
%rename(toString) std::string::operator const char *() const;
%rename(isEqual) *::operator==;
%rename(notEqual) *::operator!=;
%rename(access) *::operator();
//%ignore yarp::os::PortReader::read;
// Deal with some shadowing in python
#ifdef SWIGPYTHON
%ignore yarp::os::Property::fromCommand(int, char const *[]);
%ignore yarp::os::Property::fromCommand(int, char const *[], bool);
%ignore yarp::os::Property::fromCommand(int, char const *[], bool, bool);
#endif
// Deal with some clash in perl involving the name "seed"
%{
#define _SEARCH_H // strange perl clash
// careful shuffling to deal with perl clash on seed name
#ifdef seed
#define seed_c seed
#undef seed
#endif
#include <yarp/os/Random.h>
#ifdef seed_c
#define seed seed_c
#endif
// Bring in the header files that are important to us
#include <vector>
#include <yarp/os/all.h>
#include <yarp/sig/all.h>
#include <yarp/dev/all.h>
// Sometimes ACE redefines main() - we don't want that
#ifdef main
#undef main
#endif
// Bring in the main important namespace
using namespace yarp::os;
using namespace yarp::sig;
using namespace yarp::sig::file;
using namespace yarp::dev;
%}
#ifdef SWIGPYTHON
%{
#include <Python.h>
void setExternal(yarp::sig::Image *img, PyObject* mem, int w, int h) {
#if PY_VERSION_HEX >= 0x02070000
Py_buffer img_buffer;
int reply;
reply = PyObject_GetBuffer(mem, &img_buffer, PyBUF_SIMPLE);
// exit if the buffer could not be read
if (reply != 0)
{
fprintf(stderr, "Could not read Python buffers: error %d\n", reply);
return;
}
img->setExternal((void*)img_buffer.buf, w, h);
// release the Python buffers
PyBuffer_Release(&img_buffer);
#else
fprintf(stderr, "Your python version is not supported\n");
#endif
}
void setExternal2(yarp::sig::Image *img, PyObject* mem, int w, int h) {
setExternal(img,mem,w,h);
}
%}
#endif
// Define macros for handling the multiple analog sensors interfaces
%include macrosForMultipleAnalogSensors.i
// Define typemaps for Matrix before including it
#ifdef SWIGPYTHON
%include "typemaps.i"
%typemap(in) (int matrix_i_row, int matrix_i_col) {
if (!PyTuple_Check($input)) {
PyErr_SetString(PyExc_ValueError, "Error: expecting a tuple (m[1,2] is equivalent to m[(1,2)])");
return NULL;
}
if (PyTuple_Size($input) != 2 ) {
PyErr_SetString(PyExc_ValueError, "Matrix elements are accessed by using two integers m[i_row,i_col]");
return NULL;
}
$1 = (int)PyInt_AsLong(PyTuple_GetItem($input,0)); /* int i */
$2 = (int)PyInt_AsLong(PyTuple_GetItem($input,1)); /* int j */
};
#endif
%include <yarp/os/NetInt8.h>
%include <yarp/os/NetInt16.h>
%include <yarp/os/NetInt32.h>
%include <yarp/os/NetInt64.h>
%include <yarp/os/PortReport.h>
%include <yarp/os/Contact.h>
%include <yarp/os/ConnectionReader.h>
%include <yarp/os/ConnectionWriter.h>
%include <yarp/os/PortReader.h>
%include <yarp/os/PortWriter.h>
%include <yarp/os/Portable.h>
%include <yarp/os/Searchable.h>
%include <yarp/os/Value.h>
%include <yarp/os/Vocab.h>
%include <yarp/os/BinPortable.h>
%include <yarp/os/BufferedPort.h>
%include <yarp/os/Contact.h>
%include <yarp/os/Contactable.h>
%include <yarp/os/UnbufferedContactable.h>
%include <yarp/os/Port.h>
%include <yarp/os/AbstractContactable.h>
%include <yarp/os/Contact.h>
%include <yarp/os/Network.h>
%include <yarp/os/PortablePair.h>
%include <yarp/os/PortReaderCreator.h>
%include <yarp/os/Property.h>
%include <yarp/os/Bottle.h>
%include <yarp/os/TypedReader.h>
%include <yarp/os/TypedReaderCallback.h>
%include <yarp/os/TypedReaderThread.h>
%include <yarp/os/PortReaderBuffer.h>
%include <yarp/os/PortWriterBuffer.h>
%include <yarp/os/Random.h>
%include <yarp/os/Searchable.h>
%include <yarp/os/Semaphore.h>
%include <yarp/os/Thread.h>
%include <yarp/os/PeriodicThread.h>
%include <yarp/os/Time.h>
%include <yarp/os/RFModule.h>
%include <yarp/os/Stamp.h>
%include <yarp/os/NameStore.h>
%include <yarp/os/Searchable.h>
%include <yarp/os/ContactStyle.h>
%include <yarp/os/ResourceFinder.h>
%include <yarp/os/RpcServer.h>
%include <yarp/os/RpcClient.h>
%include <yarp/os/DummyConnector.h>
%include <yarp/os/Things.h>
%include <yarp/os/QosStyle.h>
%include <yarp/os/Log.h>
%include <yarp/os/LogStream.h>
%include <yarp/os/Wire.h>
%include <yarp/os/WireLink.h>
#ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
%include <yarp/os/RateThread.h>
#endif
%define MAKE_COMMS(name)
%feature("notabstract") yarp::os::BufferedPort<name>;
%feature("notabstract") BufferedPort ## name;
#if !defined (SWIGMATLAB)
%feature("director") yarp::os::TypedReaderCallback<name>;
%feature("director") yarp::os::TypedReaderCallback<yarp::os::name>;
#endif
%template(TypedReader ## name) yarp::os::TypedReader<name>;
%template(name ## Callback) yarp::os::TypedReaderCallback<name>;
%template(BufferedPort ## name) yarp::os::BufferedPort<name>;
%enddef
MAKE_COMMS(Property)
MAKE_COMMS(Bottle)
%include <yarp/sig/Image.h>
%include <yarp/sig/ImageFile.h>
%include <yarp/sig/Sound.h>
%include <yarp/sig/Matrix.h>
%include <yarp/sig/Vector.h>
%include <yarp/os/IConfig.h>
%include <yarp/dev/DeviceDriver.h>
%include <yarp/dev/PolyDriver.h>
%include <yarp/dev/Drivers.h>
%include <yarp/dev/IFrameGrabberImage.h>
%include <yarp/dev/IFrameGrabberControls.h>
%include <yarp/dev/IFrameGrabberControlsDC1394.h>
%include <yarp/dev/IFrameWriterImage.h>
%include <yarp/dev/AudioVisualInterfaces.h>
%include <yarp/dev/ControlBoardInterfaces.h>
%include <yarp/dev/IAxisInfo.h>
%include <yarp/dev/IAmplifierControl.h>
%include <yarp/dev/IControlDebug.h>
%include <yarp/dev/IControlLimits.h>
%include <yarp/dev/ControlBoardPid.h>
%include <yarp/dev/CartesianControl.h>
%include <yarp/dev/GazeControl.h>
%include <yarp/dev/IPositionControl.h>
%include <yarp/dev/IEncoders.h>
%include <yarp/dev/CalibratorInterfaces.h>
%include <yarp/dev/ControlBoardPid.h>
%include <yarp/dev/IControlMode.h>
%include <yarp/dev/IInteractionMode.h>
%include <yarp/dev/IJointFault.h>
%include <yarp/dev/IEncodersTimed.h>
%include <yarp/dev/IMotor.h>
%include <yarp/dev/IMotorEncoders.h>
%include <yarp/dev/ITorqueControl.h>
%include <yarp/dev/IImpedanceControl.h>
%include <yarp/dev/IVelocityControl.h>
%include <yarp/dev/IPWMControl.h>
%include <yarp/dev/ICurrentControl.h>
%include <yarp/dev/IAnalogSensor.h>
%include <yarp/dev/IRemoteVariables.h>
%include <yarp/dev/IPidControl.h>
%include <yarp/dev/IPositionDirect.h>
%include <yarp/dev/MultipleAnalogSensorsInterfaces.h>
#ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
%include <yarp/dev/FrameGrabberControl2.h>
%include <yarp/dev/IControlMode2.h>
#endif
#ifndef YARP_NO_DEPRECATED // Since YARP 3.5.0
%include <yarp/dev/IFrameGrabber.h>
%include <yarp/dev/IFrameGrabberRgb.h>
#endif YARP_NO_DEPRECATED // Since YARP 3.5.0
%template(DVector) std::vector<double>;
%template(BVector) std::vector<bool>;
%template(SVector) std::vector<std::string>;
%template(IVector) std::vector<int>;
%template(ShortVector) std::vector<short int>;
#ifdef SWIGMATLAB
// Extend IVector for handling conversion of vectors from and to Matlab
%include "matlab/vectors_fromTo_matlab.i"
#endif
#if defined(SWIGCSHARP)
SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(Pid,yarp::dev::Pid)
#endif
%template(PidVector) std::vector<yarp::dev::Pid>;
//////////////////////////////////////////////////////////////////////////
// Match Java toString behaviour
%extend yarp::os::Bottle {
std::string toString() {
return self->toString().c_str();
}
}
%extend yarp::os::Value {
std::string toString() {
return self->toString().c_str();
}
}
%extend yarp::os::Property {
std::string toString() {
return self->toString().c_str();
}
}
//////////////////////////////////////////////////////////////////////////
// Deal with some templated classes
//
// We have to shuffle things around a little bit
// ImageRgb = ImageOf<PixelRgb>
// BufferedPortImageRgb = BufferedPort<ImageOf<PixelRgb> >
// BufferedPortBottle = BufferedPort<Bottle>
// BufferedPortProperty = BufferedPort<Property>
// BufferedPortImageRgbFloat = BufferedPort<ImageOf<PixelRgbFloat> >
%{
typedef yarp::sig::ImageOf<yarp::sig::PixelRgb> ImageRgb;
typedef yarp::os::TypedReader<ImageRgb> TypedReaderImageRgb;
typedef yarp::os::TypedReaderCallback<ImageRgb> TypedReaderCallbackImageRgb;
typedef yarp::os::BufferedPort<ImageRgb> BufferedPortImageRgb;
%}
%{
typedef yarp::sig::ImageOf<yarp::sig::PixelRgba> ImageRgba;
typedef yarp::os::TypedReader<ImageRgba> TypedReaderImageRgba;
typedef yarp::os::TypedReaderCallback<ImageRgba> TypedReaderCallbackImageRgba;
typedef yarp::os::BufferedPort<ImageRgba> BufferedPortImageRgba;
%}
%{
typedef yarp::sig::ImageOf<yarp::sig::PixelMono> ImageMono;
typedef yarp::os::TypedReader<ImageMono> TypedReaderImageMono;
typedef yarp::os::TypedReaderCallback<ImageMono> TypedReaderCallbackImageMono;
typedef yarp::os::BufferedPort<ImageMono> BufferedPortImageMono;
%}
%{
typedef yarp::sig::ImageOf<yarp::sig::PixelMono16> ImageMono16;
typedef yarp::os::TypedReader<ImageMono16> TypedReaderImageMono16;
typedef yarp::os::TypedReaderCallback<ImageMono16> TypedReaderCallbackImageMono16;
typedef yarp::os::BufferedPort<ImageMono16> BufferedPortImageMono16;
%}
%{
typedef yarp::sig::ImageOf<yarp::sig::PixelInt> ImageInt;
typedef yarp::os::TypedReader<ImageInt> TypedReaderImageInt;
typedef yarp::os::TypedReaderCallback<ImageInt> TypedReaderCallbackImageInt;
typedef yarp::os::BufferedPort<ImageInt> BufferedPortImageInt;
%}
%{
typedef yarp::os::TypedReader<Sound> TypedReaderSound;
typedef yarp::os::TypedReaderCallback<Sound> TypedReaderCallbackSound;
typedef yarp::os::BufferedPort<Sound> BufferedPortSound;
%}
%inline
%{
typedef yarp::sig::VectorOf<double> Vector;
typedef yarp::sig::VectorOf<int> VectorInt;
%}
%{
typedef yarp::os::TypedReader<Vector> TypedReaderVector;
typedef yarp::os::TypedReaderCallback<Vector> TypedReaderCallbackVector;
typedef yarp::os::BufferedPort<Vector> BufferedPortVector;
%}
%feature("notabstract") ImageRgb;
%feature("notabstract") yarp::os::BufferedPort<ImageRgb>;
%feature("notabstract") BufferedPortImageRgb;
%feature("notabstract") ImageRgba;
%feature("notabstract") yarp::os::BufferedPort<ImageRgba>;
%feature("notabstract") BufferedPortImageRgba;
%feature("notabstract") ImageMono;
%feature("notabstract") yarp::os::BufferedPort<ImageMono>;
%feature("notabstract") BufferedPortImageMono;
%feature("notabstract") ImageMono16;
%feature("notabstract") yarp::os::BufferedPort<ImageMono16>;
%feature("notabstract") BufferedPortImageMono16;
%feature("notabstract") ImageInt;
%feature("notabstract") yarp::os::BufferedPort<ImageInt>;
%feature("notabstract") BufferedPortImageInt;
%feature("notabstract") Sound;
%feature("notabstract") yarp::os::BufferedPort<Sound>;
%feature("notabstract") BufferedPortSound;
%feature("notabstract") Vector;
%feature("notabstract") yarp::os::BufferedPort<Vector>;
%feature("notabstract") BufferedPortVector;
%template(ImageRgb) yarp::sig::ImageOf<yarp::sig::PixelRgb>;
%template(TypedReaderImageRgb) yarp::os::TypedReader<yarp::sig::ImageOf<yarp::sig::PixelRgb> >;
%template(TypedReaderCallbackImageRgb) yarp::os::TypedReaderCallback<yarp::sig::ImageOf<yarp::sig::PixelRgb> >;
%template(BufferedPortImageRgb) yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> >;
%template(ImageRgba) yarp::sig::ImageOf<yarp::sig::PixelRgba>;
%template(TypedReaderImageRgba) yarp::os::TypedReader<yarp::sig::ImageOf<yarp::sig::PixelRgba> >;
%template(TypedReaderCallbackImageRgba) yarp::os::TypedReaderCallback<yarp::sig::ImageOf<yarp::sig::PixelRgba> >;
%template(BufferedPortImageRgba) yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgba> >;
%template(ImageMono) yarp::sig::ImageOf<yarp::sig::PixelMono>;
%template(TypedReaderImageMono) yarp::os::TypedReader<yarp::sig::ImageOf<yarp::sig::PixelMono> >;
%template(TypedReaderCallbackImageMono) yarp::os::TypedReaderCallback<yarp::sig::ImageOf<yarp::sig::PixelMono> >;
%template(BufferedPortImageMono) yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelMono> >;
%template(ImageMono16) yarp::sig::ImageOf<yarp::sig::PixelMono16>;
%template(TypedReaderImageMono16) yarp::os::TypedReader<yarp::sig::ImageOf<yarp::sig::PixelMono16> >;
%template(TypedReaderCallbackImageMono16) yarp::os::TypedReaderCallback<yarp::sig::ImageOf<yarp::sig::PixelMono16> >;
%template(BufferedPortImageMono16) yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelMono16> >;
%template(ImageInt) yarp::sig::ImageOf<yarp::sig::PixelInt>;
%template(TypedReaderImageInt) yarp::os::TypedReader<yarp::sig::ImageOf<yarp::sig::PixelInt> >;
%template(TypedReaderCallbackImageInt) yarp::os::TypedReaderCallback<yarp::sig::ImageOf<yarp::sig::PixelInt> >;
%template(BufferedPortImageInt) yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelInt> >;
#if !defined (SWIGMATLAB)
%feature("director") yarp::os::TypedReaderCallback<Sound>;
%feature("director") yarp::os::TypedReaderCallback<yarp::sig::Sound>;
#endif
%template(TypedReaderSound) yarp::os::TypedReader<yarp::sig::Sound >;
%template(TypedReaderCallbackSound) yarp::os::TypedReaderCallback<yarp::sig::Sound>;
%template(BufferedPortSound) yarp::os::BufferedPort<yarp::sig::Sound >;
%template(Vector) yarp::sig::VectorOf<double>;
#if SWIG_VERSION < 0x030012
%rename(VectorIterator) yarp::sig::VectorOf<double>::iterator;
%rename(VectorConstIterator) yarp::sig::VectorOf<double>::const_iterator;
#endif
%template(TypedReaderVector) yarp::os::TypedReader<yarp::sig::VectorOf<double> >;
%template(TypedReaderCallbackVector) yarp::os::TypedReaderCallback<yarp::sig::VectorOf<double> >;
%template(BufferedPortVector) yarp::os::BufferedPort<yarp::sig::VectorOf<double> >;
%template(VectorInt) yarp::sig::VectorOf<int>;
%template(TypedReaderVectorInt) yarp::os::TypedReader<yarp::sig::VectorOf<int> >;
%template(TypedReaderCallbackVectorInt) yarp::os::TypedReaderCallback<yarp::sig::VectorOf<int> >;
%template(BufferedPortVectorInt) yarp::os::BufferedPort<yarp::sig::VectorOf<int> >;
// Add getPixel and setPixel methods to access float values
%extend yarp::sig::ImageOf<yarp::sig::PixelFloat> {
float getPixel(int x, int y) {
return self->pixel(x,y);
}
void setPixel(int x, int y, float v) {
self->pixel(x,y) = v;
}
}
// Add getPixel and setPixel methods to access int values
%extend yarp::sig::ImageOf<yarp::sig::PixelInt> {
int getPixel(int x, int y) {
return self->pixel(x,y);
}
void setPixel(int x, int y, int v) {
self->pixel(x,y) = v;
}
}
%extend yarp::sig::Sound{
std::vector<short int> sound2VecNonInterleaved()
{
int samples=self->getSamples();
int channels=self->getChannels();
std::vector<short int> vec;
vec.reserve(samples*channels);
for (size_t c = 0; c < channels; c++)
{
for (size_t t = 0; t < samples; t++)
{
vec.push_back(self->get(t, c));
}
}
return vec;
}
void vecNonInterleaved2Sound(std::vector<short int> vec,int samples,int channels)
{
for (size_t c = 0; c < channels; c++)
{
for (size_t t = 0; t <samples; t++)
{
self->set(vec[t+samples*c],t, c);
}
}
return;
}
std::vector<short int> sound2VecInterleaved()
{
int samples=self->getSamples();
int channels=self->getChannels();
std::vector<short int> vec;
vec.reserve(samples*channels);
for (size_t t = 0; t < samples; t++)
{
for (size_t c = 0; c < channels; c++)
{
vec.push_back(self->get(t, c));
}
}
return vec;
}
void vecInterleaved2Sound(std::vector<short int> vec,int samples,int channels)
{
for (size_t t = 0; t < channels; t++)
{
for (size_t c = 0; c <samples; c++)
{
self->set(vec[c+t*channels],t, c);
}
}
return;
}
}
%{
typedef yarp::sig::ImageOf<yarp::sig::PixelFloat> ImageFloat;
typedef yarp::os::TypedReader<ImageFloat> TypedReaderImageFloat;
typedef yarp::os::TypedReaderCallback<ImageFloat> TypedReaderCallbackImageFloat;
typedef yarp::os::BufferedPort<ImageFloat> BufferedPortImageFloat;
%}
%feature("notabstract") ImageFloat;
%feature("notabstract") yarp::os::BufferedPort<ImageFloat>;
%feature("notabstract") BufferedPortImageFloat;
%template(ImageFloat) yarp::sig::ImageOf<yarp::sig::PixelFloat>;
%template(TypedReaderImageFloat) yarp::os::TypedReader<yarp::sig::ImageOf<yarp::sig::PixelFloat> >;
%template(TypedReaderCallbackImageFloat) yarp::os::TypedReaderCallback<yarp::sig::ImageOf<yarp::sig::PixelFloat> >;
%template(BufferedPortImageFloat) yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelFloat> >;
// Add getPixel and setPixel methods to access float values
// %extend yarp::sig::ImageOf<yarp::sig::PixelRgbFloat> {
// float getPixel(int x, int y) {
// return self->pixel(x,y);
// }
//
// void setPixel(int x, int y, float v) {
// self->pixel(x,y) = v;
// }
// }
%{
typedef yarp::sig::ImageOf<yarp::sig::PixelRgbFloat> ImageRgbFloat;
typedef yarp::os::TypedReader<ImageRgbFloat> TypedReaderImageRgbFloat;
typedef yarp::os::TypedReaderCallback<ImageRgbFloat> TypedReaderCallbackImageRgbFloat;
typedef yarp::os::BufferedPort<ImageRgbFloat> BufferedPortImageRgbFloat;
%}
%feature("notabstract") ImageRgbFloat;
%feature("notabstract") yarp::os::BufferedPort<ImageRgbFloat>;
%feature("notabstract") BufferedPortImageRgbFloat;
%template(ImageRgbFloat) yarp::sig::ImageOf<yarp::sig::PixelRgbFloat>;
%template(TypedReaderImageRgbFloat) yarp::os::TypedReader<yarp::sig::ImageOf<yarp::sig::PixelRgbFloat> >;
%template(TypedReaderCallbackImageRgbFloat) yarp::os::TypedReaderCallback<yarp::sig::ImageOf<yarp::sig::PixelRgbFloat> >;
%template(BufferedPortImageRgbFloat) yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgbFloat> >;
//////////////////////////////////////////////////////////////////////////
// Deal with poor translation of interface inheritance in current SWIG
%extend yarp::os::Port {
bool write(Bottle& data) {
return self->write(*((PortWriter*)(&data)));
}
bool write(Property& data) {
return self->write(*((PortWriter*)(&data)));
}
bool write(yarp::sig::ImageOf<yarp::sig::PixelRgb>& data) {
return self->write(*((PortWriter*)(&data)));
}
bool write(yarp::sig::ImageOf<yarp::sig::PixelFloat>& data) {
return self->write(*((PortWriter*)(&data)));
}
bool write(Bottle& data1, Bottle& data2) {
return self->write(*((PortWriter*)(&data1)), *((PortReader*)(&data2)));
}
bool write(Bottle& data1, yarp::sig::ImageOf<yarp::sig::PixelFloat>& data2){
return self->write(*((PortWriter*)(&data1)), *((PortReader*)(&data2)));
}
bool reply(Bottle& data) {
return self->reply(*((PortWriter*)(&data)));
}
}
%extend yarp::os::RpcClient {
bool write(Bottle& data1, Bottle& data2) {
return self->write(*((PortWriter*)(&data1)), *((PortReader*)(&data2)));
}
}
%extend yarp::os::Contactable {
bool setEnvelope(Portable& data) {
return self->setEnvelope(*((PortWriter*)(&data)));
}
}
//////////////////////////////////////////////////////////////////////////
// Deal with PolyDriver idiom that doesn't translate too well
%define CAST_POLYDRIVER_TO_INTERFACE(interface)
yarp::dev:: ## interface *view ## interface ## () {
yarp::dev:: ## interface *result;
self->view(result);
return result;
}
%enddef
%extend yarp::dev::PolyDriver {
CAST_POLYDRIVER_TO_INTERFACE(IFrameGrabberImage)
CAST_POLYDRIVER_TO_INTERFACE(IPositionControl)
CAST_POLYDRIVER_TO_INTERFACE(IVelocityControl)
CAST_POLYDRIVER_TO_INTERFACE(IEncoders)
CAST_POLYDRIVER_TO_INTERFACE(IEncodersTimed)
CAST_POLYDRIVER_TO_INTERFACE(IMotor)
CAST_POLYDRIVER_TO_INTERFACE(IMotorEncoders)
CAST_POLYDRIVER_TO_INTERFACE(IPidControl)
CAST_POLYDRIVER_TO_INTERFACE(IAmplifierControl)
CAST_POLYDRIVER_TO_INTERFACE(IControlLimits)
CAST_POLYDRIVER_TO_INTERFACE(ICartesianControl)
CAST_POLYDRIVER_TO_INTERFACE(IGazeControl)
CAST_POLYDRIVER_TO_INTERFACE(IImpedanceControl)
CAST_POLYDRIVER_TO_INTERFACE(ITorqueControl)
CAST_POLYDRIVER_TO_INTERFACE(IControlMode)
CAST_POLYDRIVER_TO_INTERFACE(IJointFault)
#ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
yarp::dev::IControlMode *viewIControlMode2() {
yarp::dev::IControlMode *result;
self->view(result);
return result;
}
#endif
CAST_POLYDRIVER_TO_INTERFACE(IInteractionMode)
CAST_POLYDRIVER_TO_INTERFACE(IPWMControl)
CAST_POLYDRIVER_TO_INTERFACE(ICurrentControl)
CAST_POLYDRIVER_TO_INTERFACE(IAnalogSensor)
#ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
yarp::dev::IFrameGrabberControls *viewIFrameGrabberControls2() {
yarp::dev::IFrameGrabberControls *result;
self->view(result);
return result;
}
#endif
CAST_POLYDRIVER_TO_INTERFACE(IFrameGrabberControls)
CAST_POLYDRIVER_TO_INTERFACE(IPositionDirect)
CAST_POLYDRIVER_TO_INTERFACE(IRemoteVariables)
CAST_POLYDRIVER_TO_INTERFACE(IAxisInfo)
// These views are currently disabled in SWIG + java generator since they are
// useless without the EXTENDED_ANALOG_SENSOR_INTERFACE part.
// See also https://github.com/robotology/yarp/issues/1770
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
CAST_POLYDRIVER_TO_INTERFACE(IThreeAxisGyroscopes)
CAST_POLYDRIVER_TO_INTERFACE(IThreeAxisLinearAccelerometers)
CAST_POLYDRIVER_TO_INTERFACE(IThreeAxisMagnetometers)
CAST_POLYDRIVER_TO_INTERFACE(IOrientationSensors)
CAST_POLYDRIVER_TO_INTERFACE(ITemperatureSensors)
CAST_POLYDRIVER_TO_INTERFACE(ISixAxisForceTorqueSensors)
CAST_POLYDRIVER_TO_INTERFACE(IContactLoadCellArrays)
CAST_POLYDRIVER_TO_INTERFACE(IEncoderArrays)
CAST_POLYDRIVER_TO_INTERFACE(ISkinPatches)
#endif
// you'll need to add an entry for every interface you wish
// to use
}
//////////////////////////////////////////////////////////////////////////
// Deal with ControlBoardInterfaces pointer arguments that don't translate
%extend yarp::dev::IImpedanceControl {
int getAxes() {
int buffer;
bool ok = self->getAxes(&buffer);
if (!ok) return 0;
return buffer;
}
bool getImpedance(int j, std::vector<double>& stiffness, std::vector<double>& damping) {
return self->getImpedance(j, &stiffness[0], &damping[0]);
}
bool getImpedanceOffset(int j, std::vector<double>& data) {
return self->getImpedanceOffset(j, &data[0]);
}
bool getCurrentImpedanceLimit(int j, std::vector<double>& min_stiff, std::vector<double>& max_stiff, std::vector<double>& min_damp, std::vector<double>& max_damp) {
return self->getCurrentImpedanceLimit(j, &min_stiff[0], &max_stiff[0], &min_damp[0], &max_damp[0]);
}
}
%extend yarp::dev::IPositionControl {
int getAxes() {
int buffer;
bool ok = self->getAxes(&buffer);
if (!ok) return 0;
return buffer;
}
bool positionMove(std::vector<double>& data) {
return self->positionMove(&data[0]);
}
bool positionMove(int n_joint, std::vector<int>& joints, std::vector<double>& data) {
return self->positionMove(n_joint, &joints[0], &data[0]);
}
bool relativeMove(std::vector<double>& data) {
return self->relativeMove(&data[0]);
}
bool relativeMove(int n_joint, std::vector<int>& joints, std::vector<double>& data) {
return self->relativeMove(n_joint, &joints[0], &data[0]);
}
bool setRefSpeeds(std::vector<double>& data) {
return self->setRefSpeeds(&data[0]);
}
bool setRefSpeeds(int n_joint, std::vector<int>& joints, std::vector<double>& data) {
return self->setRefSpeeds(n_joint, &joints[0], &data[0]);
}
bool getRefSpeed(int j, std::vector<double>& data) {
return self->getRefSpeed(j, &data[0]);
}
bool getRefSpeeds(std::vector<double>& data) {
return self->getRefSpeeds(&data[0]);
}
bool getRefSpeeds(int n_joint, std::vector<int>& joints, std::vector<double>& data) {
return self->getRefSpeeds(n_joint, &joints[0], &data[0]);
}
bool setRefAccelerations(std::vector<double>& data) {
return self->setRefAccelerations(&data[0]);
}
bool setRefAccelerations(int n_joint, std::vector<int>& joints, std::vector<double>& data) {
return self->setRefAccelerations(n_joint, &joints[0], &data[0]);
}
bool getRefAcceleration(int j, std::vector<double>& data) {
return self->getRefAcceleration(j, &data[0]);
}
bool getRefAccelerations(std::vector<double>& data) {
return self->getRefAccelerations(&data[0]);
}
bool getRefAccelerations(int n_joint, std::vector<int>& joints, std::vector<double>& data) {
return self->getRefAccelerations(n_joint, &joints[0], &data[0]);
}
bool checkMotionDone() {
bool result;
bool ok = self->checkMotionDone(&result);
if(!ok) { return 1; } //In case of error tell the motion has been completed
return result;
}
bool checkMotionDone(std::vector<bool>& flag) {
// complication: vector<bool> is packed in C++
// and isn't a regular container.
std::vector<char> data(flag.size());
bool result = self->checkMotionDone((bool*)(&data[0]));
for (size_t i=0; i<data.size(); i++) {
flag[i] = data[i]!=0;
}
return result;
}
bool checkMotionDone(int i, std::vector<bool>& flag) {
std::vector<char> data(flag.size());
bool result = self->checkMotionDone(i,(bool*)(&data[0]));
for (size_t i=0; i<data.size(); i++) {
flag[i] = data[i]!=0;
}
return result;
}
bool checkMotionDone(int n_joint, std::vector<int>& joints, std::vector<bool>& flag) {
std::vector<char> data(n_joint);
bool result = self->checkMotionDone(n_joint, &joints[0], (bool*)(&data[0]));
for (size_t i=0; i<data.size(); i++) {
flag[i] = data[i]!=0;
}
return result;
}
bool isMotionDone(int i) {
bool buffer;
self->checkMotionDone(i,&buffer);
return buffer;
}
bool isMotionDone() {
int buffer;
self->getAxes(&buffer);
bool data = true;