Skip to content

Commit

Permalink
Merge pull request #6397 from cyberbotics/sync-master-43d0358fb
Browse files Browse the repository at this point in the history
Merge master into develop
  • Loading branch information
Benjamin Délèze authored Oct 2, 2023
2 parents be022be + 469022c commit 779ffd0
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
4 changes: 3 additions & 1 deletion docs/reference/changelog-r2023.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Released on XXX XXth, 2023.
- Fixed translation, rotation and scale displayed in the Position tab of the Node viewer in the scene tree ([#6309](https://github.com/cyberbotics/webots/pull/6309)).
- Replaced the [Mesh](mesh.md) bounding object of the ROSbot XL by [Boxes](box.md) ([#6326](https://github.com/cyberbotics/webots/pull/6326)).
- Fixed a crash when [IndexedLineSet](indexedlineset.md) has `coord` but no `coordIndex` ([#6359](https://github.com/cyberbotics/webots/pull/6359)).

- Fixed values returned by the [Receiver.getEmitterDirection](https://cyberbotics.com/doc/reference/receiver?tab-language=python#wb_receiver_get_emitter_direction) Python method ([#6394](https://github.com/cyberbotics/webots/pull/6394)).
- Fixed recognition of omnidirectional cameras with fov > pi/2 in [WbObjectDetection] ([#6396](https://github.com/cyberbotics/webots/pull/6396)).

## Webots R2023b
Released on June 28th, 2023.
- New Features
Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def signal_strength(self) -> float:
return wb.wb_receiver_get_signal_strength(self._tag)

@property
def emitter_direction(self):
return wb.wb_receiver_get_emitter_direction(self._tag)
def emitter_direction(self) -> List[float]:
return wb.wb_receiver_get_emitter_direction(self._tag)[:3]

@property
def channel(self) -> int:
Expand Down
44 changes: 25 additions & 19 deletions src/controller/launcher/webots_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,54 +169,60 @@ static bool get_webots_home() {
// Gets and stores the path to the latest installed version of Matlab on the system.
static bool get_matlab_path() {
struct dirent *directory_entry; // Pointer for directory entry

#ifdef __APPLE__
const char *matlab_directory = "/Applications/";
const char *matlab_version_wc = "MATLAB_R20";
#else
const char *matlab_version_wc = "R20";
#ifdef _WIN32
const char *matlab_exec_suffix = "/bin/matlab";
#elif _WIN32
const char *matlab_directory = "C:\\Program Files\\MATLAB\\";
const char *matlab_version_wc = "R20";
const char *matlab_exec_suffix = "\\bin\\matlab.exe";
#else // __linux__
#elif __linux__
const char *matlab_directory = "/usr/local/MATLAB/";
const char *matlab_version_wc = "R20";
const char *matlab_exec_suffix = "/bin/matlab";
#endif
#else
#error "OS not supported!"
#endif

DIR *directory = opendir(matlab_directory);
#ifndef __APPLE__
if (directory == NULL) {
fprintf(stderr, "No installation of MATLAB available.\n");
#ifdef __APPLE__
fprintf(stderr, "Could not open Applications folder to search for MATLAB installation. Please specify it manually using "
"the option '--matlab-path'.\n");
#else
fprintf(stderr, "No installation of MATLAB found. Please specify it manually using the option '--matlab-path'.\n");
#endif
return false;
}
#endif

// Get latest available Matlab version
char *latest_version = NULL;
while ((directory_entry = readdir(directory)) != NULL) {
const size_t directory_name_size = strlen(directory_entry->d_name) + 1;
if (strncmp(matlab_version_wc, directory_entry->d_name, strlen(matlab_version_wc)) == 0) {
if (!latest_version)
if (!latest_version) {
latest_version = malloc(directory_name_size);
else if (strcmp(latest_version, directory_entry->d_name) < 0)
memset(latest_version, '\0', directory_name_size);
strncpy(latest_version, directory_entry->d_name, directory_name_size);
strncpy(latest_version, directory_entry->d_name, directory_name_size);
} else if (strcmp(latest_version, directory_entry->d_name) < 0) {
char *tmp = realloc(latest_version, directory_name_size);
if (tmp)
latest_version = tmp;
strncpy(latest_version, directory_entry->d_name, directory_name_size);
}
}
}
closedir(directory);
if (!latest_version) {
fprintf(stderr, "No installation of MATLAB available.\n");
fprintf(stderr, "No installation of MATLAB found. Please specify it manually using the option '--matlab-path'.\n");
return false;
}

#ifdef __APPLE__
const size_t matlab_path_size = snprintf(NULL, 0, "%s%s", matlab_directory, latest_version) + 1;
matlab_path = malloc(matlab_path_size);
sprintf(matlab_path, "%s%s", matlab_directory, latest_version);
#else
const size_t matlab_path_size = snprintf(NULL, 0, "%s%s%s", matlab_directory, latest_version, matlab_exec_suffix) + 1;
matlab_path = malloc(matlab_path_size);
sprintf(matlab_path, "%s%s%s", matlab_directory, latest_version, matlab_exec_suffix);
#endif
printf("Using the latest available MATLAB instance: %s\n", matlab_path);

free(latest_version);
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/webots/nodes/utils/WbObjectDetection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ WbObjectDetection::WbObjectDetection(WbSolid *device, WbSolid *object, const int
mMaxRange(maxRange),
mOdeGeomData(NULL),
mHorizontalFieldOfView(horizontalFieldOfView),
mIsOmniDirectional(mHorizontalFieldOfView > M_PI),
mIsOmniDirectional(mHorizontalFieldOfView > M_PI_2),
mOcclusion(occlusion) {
if (mOcclusion == ONE_RAY) {
const WbVector3 devicePosition = mDevice->position();
Expand Down Expand Up @@ -420,7 +420,7 @@ bool WbObjectDetection::isWithinBounds(const WbAffinePlane *frustumPlanes, const
}

objectRelativePosition = deviceInverseRotation * (objectPosition - devicePosition);
if (!mIsOmniDirectional && mHorizontalFieldOfView <= M_PI_2) {
if (!mIsOmniDirectional) {
// do not recompute the object size and position if partly outside in case of fovX > PI
// (a more complete computation will be needed and currently it seems to work quite well as-is)
objectSize.setY(objectSize.y() - outsidePart[RIGHT] - outsidePart[LEFT]);
Expand Down
2 changes: 1 addition & 1 deletion src/webots/nodes/utils/WbObjectDetection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class WbObjectDetection {
QList<double> mRaysCollisionDepth; // rays collision depth
QList<dGeomID> mRayGeoms; // rays that checks collision of this packet
double mHorizontalFieldOfView;
bool mIsOmniDirectional; // is sensor omnidirectional (horizontal FOV < PI/2)
bool mIsOmniDirectional; // is sensor omnidirectional (horizontal FOV > PI/2)
int mOcclusion;
};

Expand Down

0 comments on commit 779ffd0

Please sign in to comment.