Skip to content

Commit 69681a9

Browse files
authored
[Java Controller API] Fix Length of Arrays Returned by CameraRecognitionObject.getColors() (cyberbotics#6564)
* fix CameraRecognitionObject.getColors * fix getColor implementation * update to conform more closely to existing API * update changelog
1 parent e3a5f1f commit 69681a9

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

docs/reference/changelog-r2024.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ Released on December **th, 2023.
1111
- Bug Fixes
1212
- Fixed error message on Windows when `libssl-3-x64.dll` was added to `PATH` ([#6553](https://github.com/cyberbotics/webots/pull/6553)).
1313
- Fixed length of arrays returned by `getPose()` in Java ([#6556](https://github.com/cyberbotics/webots/pull/6556)).
14+
- Fixed length of arrays returned by `CameraRecognitionObject.getColors()` in Java ([#6564](https://github.com/cyberbotics/webots/pull/6564))
15+

src/controller/java/controller.i

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,15 @@ using namespace std;
8585
$result = SWIG_JavaArrayOutDouble(jenv, $1, 9);
8686
else if (test == "getPose")
8787
$result = SWIG_JavaArrayOutDouble(jenv, $1, 16);
88-
else if (test != "getLookupTable")
88+
else if (test != "colors" && test != "getLookupTable")
8989
$result = SWIG_JavaArrayOutDouble(jenv, $1, 3);
9090
}
9191
%apply double[] {double *};
9292

93+
%typemap(out) double *colors {
94+
$result = SWIG_JavaArrayOutDouble(jenv, (double *) $1, arg1->number_of_colors*3);
95+
}
96+
9397
%typemap(out) const double *getLookupTable {
9498
$result = SWIG_JavaArrayOutDouble(jenv, (double *) $1, arg1->getLookupTableSize()*3);
9599
}

0 commit comments

Comments
 (0)