Skip to content

Commit

Permalink
Merge pull request #945 from cyberbotics/sync-master-ac8a68382ac8a748…
Browse files Browse the repository at this point in the history
…910852f5c5c0074e96d82418

Sync libcontroller master
  • Loading branch information
omichel authored Jul 22, 2024
2 parents f137797 + b140929 commit 4448c16
Show file tree
Hide file tree
Showing 55 changed files with 290 additions and 285 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern "C" {
#endif

void wbu_generic_robot_window_parse_device_command(char *token, char *tokens);
bool wbu_generic_robot_window_parse_device_control_command(char *first_token, char *tokens);
bool wbu_generic_robot_window_parse_device_control_command(const char *first_token, char *tokens);
bool wbu_generic_robot_window_handle_messages(const char *message);
void wbu_generic_robot_window_init();
void wbu_generic_robot_window_update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern "C" {
#endif

char *wbu_string_strsep(char **stringp, const char *delim);
char *wbu_string_replace(char *value, char *before, char *after);
char *wbu_string_replace(char *value, const char *before, const char *after);

#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void wbu_car_init() {
// Parse vehicle caracteristics from the beginning of the data string
char engine_type;
int engine_sound_length;
char *sub_data_string = (char *)wb_robot_get_custom_data();
const char *sub_data_string = wb_robot_get_custom_data();
i = sscanf(sub_data_string, "%lf %lf %lf %lf %lf %lf %lf %c %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %d %d",
&instance->wheelbase, &instance->track_front, &instance->track_rear, &instance->front_wheel_radius,
&instance->rear_wheel_radius, &instance->brake_coefficient, &instance->defaultDampingConstant, &engine_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ static void update_engine_sound() {
}
if (rpm < instance->car->engine_min_rpm)
rpm = instance->car->engine_min_rpm;
// cppcheck-suppress variableScope
double pitch = rpm / instance->car->engine_sound_rpm_reference;
if (stop_sound)
wb_speaker_stop(instance->engine_speaker, instance->car->engine_sound);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ $(WRAPPER_OBJECT): $(WRAPPER)
@$(CXX) $(CFLAGS2) $(INCLUDES) $(JAVA_INCLUDES) $< -o "$@"

$(WRAPPER_OBJECT_ARM64): $(WRAPPER)
@$(CXX) -target arm64-apple-macos11 $(CFLAGS2) $(INCLUDES) $(JAVA_INCLUDES) $< -o "$@"
@$(CXX) -target arm64-apple-macos12 $(CFLAGS2) $(INCLUDES) $(JAVA_INCLUDES) $< -o "$@"

$(WRAPPER_OBJECT_X86_64): $(WRAPPER)
@$(CXX) -target x86_64-apple-macos11 $(CFLAGS2) $(INCLUDES) $(JAVA_INCLUDES) $< -o "$@"
@$(CXX) -target x86_64-apple-macos12 $(CFLAGS2) $(INCLUDES) $(JAVA_INCLUDES) $< -o "$@"

%.so: $(WRAPPER_OBJECT)
@mkdir -p $(WEBOTS_CONTROLLER_LIB_PATH)/java
Expand All @@ -102,8 +102,8 @@ $(WRAPPER_OBJECT_X86_64): $(WRAPPER)
@$(CXX) -shared -mwindows -Wl,--add-stdcall-alias -Wl,--enable-auto-import -O -lm $< $(LIB) -o "$@"

%.jnilib: $(WRAPPER_OBJECT_ARM64) $(WRAPPER_OBJECT_X86_64)
@$(CXX) -target arm64-apple-macos11 $(CFLAGS1) -bundle $(WRAPPER_OBJECT_ARM64) $(LIB) -o lib$(MODULE_NAME)-arm64.jnilib
@$(CXX) -target x86_64-apple-macos11 $(CFLAGS1) -bundle $(WRAPPER_OBJECT_X86_64) $(LIB) -o lib$(MODULE_NAME)-x86_64.jnilib
@$(CXX) -target arm64-apple-macos12 $(CFLAGS1) -bundle $(WRAPPER_OBJECT_ARM64) $(LIB) -o lib$(MODULE_NAME)-arm64.jnilib
@$(CXX) -target x86_64-apple-macos12 $(CFLAGS1) -bundle $(WRAPPER_OBJECT_X86_64) $(LIB) -o lib$(MODULE_NAME)-x86_64.jnilib
@mkdir -p $(WEBOTS_CONTROLLER_LIB_PATH)/java
@lipo -create -output "$@" lib$(MODULE_NAME)-arm64.jnilib lib$(MODULE_NAME)-x86_64.jnilib
@codesign -s - "$@"
Expand Down
36 changes: 18 additions & 18 deletions webots_ros2_driver/webots/resources/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ endif
ifneq ($(C_SOURCES)$(CXX_SOURCES),)
ifdef BUILD_EXECUTABLE
MAIN_TARGET = $(NAME)$(EXE_EXTENSION)
X86_64_LINKER = -target x86_64-apple-macos11
ARM64_LINKER = -target arm64-apple-macos11
X86_64_LINKER = -target x86_64-apple-macos12
ARM64_LINKER = -target arm64-apple-macos12
else
ifdef BUILD_STATIC_LIBRARY
MAIN_TARGET ?= $(LIB_PREFIX)$(NAME)$(STATIC_LIB_EXTENSION)
else
MAIN_TARGET ?= $(LIB_PREFIX)$(NAME)$(SHARED_LIB_EXTENSION)
X86_64_LINKER = -target x86_64-apple-macos11
ARM64_LINKER = -target arm64-apple-macos11
X86_64_LINKER = -target x86_64-apple-macos12
ARM64_LINKER = -target arm64-apple-macos12
endif
endif
endif
Expand Down Expand Up @@ -321,8 +321,8 @@ endif

ifeq ($(OSTYPE),darwin)
ifdef NO_FAT_BINARY
WBCFLAGS += -target $(PROCESSOR)-apple-macos11
DYNAMIC_LINK_FLAGS += -target $(PROCESSOR)-apple-macos11
WBCFLAGS += -target $(PROCESSOR)-apple-macos12
DYNAMIC_LINK_FLAGS += -target $(PROCESSOR)-apple-macos12
endif
WBCFLAGS += -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION)
DYNAMIC_LINK_FLAGS += -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION)
Expand Down Expand Up @@ -355,7 +355,7 @@ ifdef USE_CXX
endif
endif
ifeq ($(OSTYPE),darwin)
WBCFLAGS += -stdlib=libc++
WBCXXFLAGS += -stdlib=libc++
DYNAMIC_LINK_FLAGS += -stdlib=libc++
endif
else
Expand Down Expand Up @@ -600,15 +600,15 @@ $(BUILD_GOAL_DIR)/%.d:%.c

$(BUILD_GOAL_DIR)/%.d:%.cc
@echo "# updating" $(notdir $@)
$(SILENT)$(CXX) $(INCLUDE) $(WBCFLAGS) $(CFLAGS -MM $< -MT $(addprefix $(BUILD_GOAL_DIR)/,$(notdir $(<:.cc=.o))) > $@
$(SILENT)$(CXX) $(INCLUDE) $(WBCFLAGS) $(WBCXXFLAGS) $(CFLAGS) -MM $< -MT $(addprefix $(BUILD_GOAL_DIR)/,$(notdir $(<:.cc=.o))) > $@

$(BUILD_GOAL_DIR)/%.d:%.c++
@echo "# updating" $(notdir $@)
$(SILENT)$(CXX) $(INCLUDE) $(WBCFLAGS) $(CFLAGS) -MM $< -MT $(addprefix $(BUILD_GOAL_DIR)/,$(notdir $(<:.c++=.o))) > $@
$(SILENT)$(CXX) $(INCLUDE) $(WBCFLAGS) $(WBCXXFLAGS) $(CFLAGS) -MM $< -MT $(addprefix $(BUILD_GOAL_DIR)/,$(notdir $(<:.c++=.o))) > $@

$(BUILD_GOAL_DIR)/%.d:%.cpp
@echo "# updating" $(notdir $@)
$(SILENT)$(CXX) $(INCLUDE) $(WBCFLAGS) $(CFLAGS) -MM $< -MT $(addprefix $(BUILD_GOAL_DIR)/,$(notdir $(<:.cpp=.o))) > $@
$(SILENT)$(CXX) $(INCLUDE) $(WBCFLAGS) $(WBCXXFLAGS) $(CFLAGS) -MM $< -MT $(addprefix $(BUILD_GOAL_DIR)/,$(notdir $(<:.cpp=.o))) > $@

# dependencies
ifdef GOAL
Expand All @@ -627,35 +627,35 @@ $(BUILD_GOAL_DIR)/%.o:%.c

$(BUILD_GOAL_DIR)/x86_64/%.o:%.c
@echo "# compiling" $(notdir $<) "(x86_64)"
$(SILENT)$(CC) -c -target x86_64-apple-macos11 $(WBCFLAGS) $(CFLAGS) $(INCLUDE) $< -o $@
$(SILENT)$(CC) -c -target x86_64-apple-macos12 $(WBCFLAGS) $(CFLAGS) $(INCLUDE) $< -o $@

$(BUILD_GOAL_DIR)/arm64/%.o:%.c
@echo "# compiling" $(notdir $<) "(arm64)"
$(SILENT)$(CC) -c -target arm64-apple-macos11 $(WBCFLAGS) $(CFLAGS) $(INCLUDE) $< -o $@
$(SILENT)$(CC) -c -target arm64-apple-macos12 $(WBCFLAGS) $(CFLAGS) $(INCLUDE) $< -o $@

$(BUILD_GOAL_DIR)/%.o:%.cc
@echo "# compiling" $(notdir $<)
$(SILENT)$(CXX) -c $(WBCFLAGS) $(CFLAGS) $(CXXFLAGS) $(INCLUDE) $< -o $@
$(SILENT)$(CXX) -c $(WBCFLAGS) $(WBCXXFLAGS) $(CFLAGS) $(CXXFLAGS) $(INCLUDE) $< -o $@

$(BUILD_GOAL_DIR)/%.o:%.c++
@echo "# compiling" $(notdir $<)
$(SILENT)$(CXX) -c $(WBCFLAGS) $(CFLAGS) $(CXXFLAGS) $(INCLUDE) $< -o $@
$(SILENT)$(CXX) -c $(WBCFLAGS) $(WBCXXFLAGS) $(CFLAGS) $(CXXFLAGS) $(INCLUDE) $< -o $@

$(BUILD_GOAL_DIR)/%.o:%.cpp
@echo "# compiling" $(notdir $<)
$(SILENT)$(CXX) -c $(WBCFLAGS) $(CFLAGS) $(CXXFLAGS) $(INCLUDE) $< -o $@
$(SILENT)$(CXX) -c $(WBCFLAGS) $(WBCXXFLAGS) $(CFLAGS) $(CXXFLAGS) $(INCLUDE) $< -o $@

$(BUILD_GOAL_DIR)/x86_64/%.o:%.cpp
@echo "# compiling" $(notdir $<) "(x86_64)"
$(SILENT)$(CXX) -c -target x86_64-apple-macos11 $(WBCFLAGS) $(CFLAGS) $(CXXFLAGS) $(INCLUDE) $< -o $@
$(SILENT)$(CXX) -c -target x86_64-apple-macos12 $(WBCFLAGS) $(WBCXXFLAGS) $(CFLAGS) $(CXXFLAGS) $(INCLUDE) $< -o $@

$(BUILD_GOAL_DIR)/arm64/%.o:%.cpp
@echo "# compiling" $(notdir $<) "(arm64)"
$(SILENT)$(CXX) -c -target arm64-apple-macos11 $(WBCFLAGS) $(CFLAGS) $(CXXFLAGS) $(INCLUDE) $< -o $@
$(SILENT)$(CXX) -c -target arm64-apple-macos12 $(WBCFLAGS) $(WBCXXFLAGS) $(CFLAGS) $(CXXFLAGS) $(INCLUDE) $< -o $@

$(BUILD_GOAL_DIR_EMCC)/%.o:%.cpp
@echo "# compiling with emcc " $(notdir $<)
$(SILENT)emcc -O3 -c $(WBCFLAGS) $(CFLAGS) $(CXXFLAGS) $(INCLUDE) $< -o $(@)
$(SILENT)emcc -O3 -c $(WBCFLAGS) $(WBCXXFLAGS) $(CFLAGS) $(CXXFLAGS) $(INCLUDE) $< -o $(@)

###-----------------------------------------------------------------------------
### How to clean up the directory
Expand Down
4 changes: 2 additions & 2 deletions webots_ros2_driver/webots/resources/Makefile.os.include
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ endif

ifeq ($(OSTYPE),darwin)

SUPPORTED_SDK = 11 12
MACOSX_MIN_SDK_VERSION = 11
SUPPORTED_SDK = 12 13 14
MACOSX_MIN_SDK_VERSION = 12
ECHO = echo
# cf. https://stackoverflow.com/a/30225756/2210777
MACOSX_SDK_PATH = $(shell xcrun --sdk macosx --show-sdk-path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ void wbu_generic_robot_window_parse_device_command(char *token, char *tokens) {
};
}

bool wbu_generic_robot_window_parse_device_control_command(char *first_token, char *tokens) {
bool wbu_generic_robot_window_parse_device_control_command(const char *first_token, char *tokens) {
if (strcmp(first_token, "device-control-mode") != 0)
return false;
WbNodeType type = WB_NODE_NO_NODE;

char *token = NULL;
const char *token = NULL;
while ((token = wbu_string_strsep(&tokens, ":"))) {
if (type == WB_NODE_NO_NODE) {
type = stringToDeviceType(token);
Expand Down
10 changes: 5 additions & 5 deletions webots_ros2_driver/webots/src/controller/c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ LIBCONTROLLER_VERSION := "$(shell cat $(WEBOTS_HOME_PATH)/resources/version.txt)
endif

ifeq ($(OSTYPE),darwin)
CFLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -fpascal-strings -Wno-deprecated-declarations -I/Developer/Headers/FlatCarbon -Wall -fno-common -D LIBCONTROLLER_VERSION='$(LIBCONTROLLER_VERSION)'
CFLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -fpascal-strings -Wno-deprecated-declarations -Wno-single-bit-bitfield-constant-conversion -I/Developer/Headers/FlatCarbon -Wall -fno-common -D LIBCONTROLLER_VERSION='$(LIBCONTROLLER_VERSION)'
INCLUDE = -I$(WEBOTS_HOME_PATH)/include/controller/c -I$(WEBOTS_HOME_PATH)/include
LD_FLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -dynamiclib -install_name @rpath/Contents/lib/controller/libController.dylib -compatibility_version 1.0 -current_version 1.0.0
SHARED_LIBS = -lz
Expand Down Expand Up @@ -155,12 +155,12 @@ $(TARGET): $(OBJDIR)/x86_64/libController.dylib $(OBJDIR)/arm64/libController.dy

$(OBJDIR)/x86_64/libController.dylib: $(X86_64_OBJECTS)
@echo "# linking "$@" (x86_64)"
@$(CC) $(LD_FLAGS) -target x86_64-apple-macos11 -o $@ $(X86_64_OBJECTS) $(SHARED_LIBS)
@$(CC) $(LD_FLAGS) -target x86_64-apple-macos12 -o $@ $(X86_64_OBJECTS) $(SHARED_LIBS)
@chmod a-x $@

$(OBJDIR)/arm64/libController.dylib: $(ARM64_OBJECTS)
@echo "# linking "$@" (arm64)"
@$(CC) $(LD_FLAGS) -target arm64-apple-macos11 -o $@ $(ARM64_OBJECTS) $(SHARED_LIBS)
@$(CC) $(LD_FLAGS) -target arm64-apple-macos12 -o $@ $(ARM64_OBJECTS) $(SHARED_LIBS)
@chmod a-x $@

endif
Expand All @@ -180,11 +180,11 @@ $(OBJDIR)/%.o:%.c

$(OBJDIR)/arm64/%o:%c
@echo "# compiling "$<" (arm64)"
@$(CC) -c -target arm64-apple-macos11 $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) $< -o $(OBJDIR)/arm64/$(notdir $@)
@$(CC) -c -target arm64-apple-macos12 $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) $< -o $(OBJDIR)/arm64/$(notdir $@)

$(OBJDIR)/x86_64/%o:%c
@echo "# compiling "$<" (x86_64)"
@$(CC) -c -target x86_64-apple-macos11 $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) $< -o $(OBJDIR)/x86_64/$(notdir $@)
@$(CC) -c -target x86_64-apple-macos12 $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) $< -o $(OBJDIR)/x86_64/$(notdir $@)

$(OBJDIR)/%.d:%.c
@echo "# updating "$(notdir $@)
Expand Down
20 changes: 10 additions & 10 deletions webots_ros2_driver/webots/src/controller/c/abstract_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,50 +120,50 @@ void wb_abstract_camera_enable(WbDevice *d, int sampling_period) {
robot_mutex_unlock();
}

int wb_abstract_camera_get_sampling_period(WbDevice *d) {
int wb_abstract_camera_get_sampling_period(const WbDevice *d) {
int sampling_period = 0;
robot_mutex_lock();
AbstractCamera *ac = d->pdata;
const AbstractCamera *ac = d->pdata;
if (ac)
sampling_period = ac->sampling_period;
robot_mutex_unlock();
return sampling_period;
}

int wb_abstract_camera_get_height(WbDevice *d) {
int wb_abstract_camera_get_height(const WbDevice *d) {
int result = -1;
robot_mutex_lock();
AbstractCamera *ac = d->pdata;
const AbstractCamera *ac = d->pdata;
if (ac)
result = ac->height;
robot_mutex_unlock();
return result;
}

int wb_abstract_camera_get_width(WbDevice *d) {
int wb_abstract_camera_get_width(const WbDevice *d) {
int result = -1;
robot_mutex_lock();
AbstractCamera *ac = d->pdata;
const AbstractCamera *ac = d->pdata;
if (ac)
result = ac->width;
robot_mutex_unlock();
return result;
}

double wb_abstract_camera_get_fov(WbDevice *d) {
double wb_abstract_camera_get_fov(const WbDevice *d) {
double result = NAN;
robot_mutex_lock();
AbstractCamera *ac = d->pdata;
const AbstractCamera *ac = d->pdata;
if (ac)
result = ac->fov;
robot_mutex_unlock();
return result;
}

double wb_abstract_camera_get_near(WbDevice *d) {
double wb_abstract_camera_get_near(const WbDevice *d) {
double result = NAN;
robot_mutex_lock();
AbstractCamera *ac = d->pdata;
const AbstractCamera *ac = d->pdata;
if (ac)
result = ac->camnear;
robot_mutex_unlock();
Expand Down
10 changes: 5 additions & 5 deletions webots_ros2_driver/webots/src/controller/c/abstract_camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ unsigned char *wbr_abstract_camera_get_image_buffer(WbDevice *d);
void abstract_camera_allocate_image(WbDevice *d, int size);

void wb_abstract_camera_enable(WbDevice *d, int sampling_period);
int wb_abstract_camera_get_sampling_period(WbDevice *d);
int wb_abstract_camera_get_height(WbDevice *d);
int wb_abstract_camera_get_width(WbDevice *d);
double wb_abstract_camera_get_fov(WbDevice *d);
double wb_abstract_camera_get_near(WbDevice *d);
int wb_abstract_camera_get_sampling_period(const WbDevice *d);
int wb_abstract_camera_get_height(const WbDevice *d);
int wb_abstract_camera_get_width(const WbDevice *d);
double wb_abstract_camera_get_fov(const WbDevice *d);
double wb_abstract_camera_get_near(const WbDevice *d);

#endif // ABSTRACT_CAMERA_PRIVATE_H
12 changes: 6 additions & 6 deletions webots_ros2_driver/webots/src/controller/c/accelerometer.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static void accelerometer_read_answer(WbDevice *d, WbRequest *r) {
int wb_accelerometer_get_lookup_table_size(WbDeviceTag tag) {
int result = 0;
robot_mutex_lock();
Accelerometer *dev = accelerometer_get_struct(tag);
const Accelerometer *dev = accelerometer_get_struct(tag);
if (dev)
result = dev->lookup_table_size;
else
Expand All @@ -87,9 +87,9 @@ int wb_accelerometer_get_lookup_table_size(WbDeviceTag tag) {
}

const double *wb_accelerometer_get_lookup_table(WbDeviceTag tag) {
double *result = NULL;
const double *result = NULL;
robot_mutex_lock();
Accelerometer *dev = accelerometer_get_struct(tag);
const Accelerometer *dev = accelerometer_get_struct(tag);
if (dev)
result = dev->lookup_table;
else
Expand Down Expand Up @@ -158,7 +158,7 @@ void wb_accelerometer_enable(WbDeviceTag tag, int sampling_period) {
}

void wb_accelerometer_disable(WbDeviceTag tag) {
Accelerometer *acc = accelerometer_get_struct(tag);
const Accelerometer *acc = accelerometer_get_struct(tag);
if (acc)
wb_accelerometer_enable(tag, 0);
else
Expand All @@ -168,7 +168,7 @@ void wb_accelerometer_disable(WbDeviceTag tag) {
int wb_accelerometer_get_sampling_period(WbDeviceTag tag) {
int sampling_period = 0;
robot_mutex_lock();
Accelerometer *acc = accelerometer_get_struct(tag);
const Accelerometer *acc = accelerometer_get_struct(tag);
if (acc)
sampling_period = acc->sampling_period;
else
Expand All @@ -180,7 +180,7 @@ int wb_accelerometer_get_sampling_period(WbDeviceTag tag) {
const double *wb_accelerometer_get_values(WbDeviceTag tag) {
const double *result = NULL;
robot_mutex_lock();
Accelerometer *acc = accelerometer_get_struct(tag);
const Accelerometer *acc = accelerometer_get_struct(tag);
if (acc) {
if (acc->sampling_period == 0)
fprintf(stderr, "Error: %s() called for a disabled device! Please use: wb_accelerometer_enable().\n", __FUNCTION__);
Expand Down
6 changes: 3 additions & 3 deletions webots_ros2_driver/webots/src/controller/c/altimeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void wb_altimeter_enable(WbDeviceTag tag, int sampling_period) {
}

void wb_altimeter_disable(WbDeviceTag tag) {
Altimeter *altimeter = altimeter_get_struct(tag);
const Altimeter *altimeter = altimeter_get_struct(tag);
if (altimeter)
wb_altimeter_enable(tag, 0);
else
Expand All @@ -120,7 +120,7 @@ void wb_altimeter_disable(WbDeviceTag tag) {
int wb_altimeter_get_sampling_period(WbDeviceTag tag) {
int sampling_period = 0;
robot_mutex_lock();
Altimeter *altimeter = altimeter_get_struct(tag);
const Altimeter *altimeter = altimeter_get_struct(tag);
if (altimeter)
sampling_period = altimeter->sampling_period;
else
Expand All @@ -132,7 +132,7 @@ int wb_altimeter_get_sampling_period(WbDeviceTag tag) {
double wb_altimeter_get_value(WbDeviceTag tag) {
double result = NAN;
robot_mutex_lock();
Altimeter *altimeter = altimeter_get_struct(tag);
const Altimeter *altimeter = altimeter_get_struct(tag);
if (altimeter) {
if (altimeter->sampling_period <= 0)
fprintf(stderr, "Error: %s() called for a disabled device! Please use: wb_altimeter_enable().\n", __FUNCTION__);
Expand Down
4 changes: 2 additions & 2 deletions webots_ros2_driver/webots/src/controller/c/brake.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void wb_brake_set_damping_constant(WbDeviceTag tag, double damping_constant) {
return;
}

Brake *b = brake_get_struct(tag);
const Brake *b = brake_get_struct(tag);
if (!b) {
fprintf(stderr, "Error: %s(): invalid device tag.\n", __FUNCTION__);
return;
Expand All @@ -129,7 +129,7 @@ void wb_brake_set_damping_constant(WbDeviceTag tag, double damping_constant) {
WbJointType wb_brake_get_type(WbDeviceTag tag) {
WbJointType type = WB_ROTATIONAL;
robot_mutex_lock();
Brake *b = brake_get_struct(tag);
const Brake *b = brake_get_struct(tag);
if (b)
type = b->type;
else
Expand Down
Loading

0 comments on commit 4448c16

Please sign in to comment.