Skip to content

Commit

Permalink
Feature extern controllers launcher (#5629)
Browse files Browse the repository at this point in the history
* Create webots_controller.c

* Update webots_controller.c

* Update allocations to malloc

* add consts

* cleanup + remove const of env variable

* Add controller launcher to makefile

* ignore webots-controller executable

* Add clean and copy to makefile

* ignore executable

* Move launcher to controller folder

* Update .gitignore

* Clean webots makefile

* Improve string handling

* fix gitignore

* Add to tests

* initialize chars

* fix end of line

* cleanup

* Add matlab compatibility + fix memory

* Add missing options

* cleanup

* Fix matlab and start runtime.ini

* Add pseudocode

* runtime ini paths

* parse env variables + cleanup

* Cleanup

* add memory free + cleanup

* fix source error

* fscanf width limit

* fix sprintf

* fix sprintf

* Update webots_controller.c

* fix realloc check

* Fix comment + multiple variable in runtime ini

* Improve robustness

* Add windows support

* Update webots_controller.c

* Fix memory runtime ini line

* Fix paths on Windows

* clang format

* Documentation

* cleanup

* options

* doc

* update msg in webots console

* Update use cases to launcher

* typo

* Add new example

* WEBOTS HOME

* Add snap information

* simplify command

* Add matlab section

* Example webots_home

* indent

* indent

* indent

* Update running-extern-robot-controllers.md

* Revert "indent"

This reverts commit 94fd79e.

* example fix

* indent

* Remove warnings on macOS and add launcher to distrib

* new macOS distrib locaiton

* execve

* Replace system by spawnvpe on windows

* python space robustness

* Fix runtime ini

* restrict process.h to windows

* replace execve by execvp

* Improve java

* cleanup

* Cleanup + changelog

* Add func description

* Fix compilation

* Add current relative path to controller + change working dir

* Fix java no path

* cleanup + fix matlab

* Simplify controller path

* Cleanup

* fix double free

* fix double free

* Remove duplicate free

* Update scripts/packaging/files_core.txt

Co-authored-by: Olivier Michel <[email protected]>

* Update docs/guide/running-extern-robot-controllers.md

Co-authored-by: Olivier Michel <[email protected]>

* Update src/controller/launcher/webots_controller.c

Co-authored-by: Olivier Michel <[email protected]>

* Apply suggestions from code review

Co-authored-by: ad-daniel <[email protected]>

* one line per sentence doc

* occurence to occurrence

* simplify realloc

* static func and var + fix free

* Update src/controller/launcher/webots_controller.c

Co-authored-by: Olivier Michel <[email protected]>

* Update src/controller/launcher/webots_controller.c

Co-authored-by: Olivier Michel <[email protected]>

* Update src/controller/launcher/webots_controller.c

Co-authored-by: Olivier Michel <[email protected]>

* Apply suggestions from code review

Co-authored-by: Olivier Michel <[email protected]>

* fix clang format

* cleanup

* clean doc

* fix free realloc

* minor

* test

* Update example doc

* add carriage return in doc

* fix doc

* fix doc

* More carriage returns in help msg

* Duplicate string and change realloc order

* Add forward slash compatibility on Windows

* Add python unbuffered

* Add robustness against spaces in robot name

* Improve multiple controllers error msg

* doc

* Enhance comments in code

* Update src/controller/launcher/webots_controller.c

Co-authored-by: Olivier Michel <[email protected]>

---------

Co-authored-by: Olivier Michel <[email protected]>
Co-authored-by: ad-daniel <[email protected]>
  • Loading branch information
3 people authored Feb 3, 2023
1 parent d8ce5db commit 699328c
Show file tree
Hide file tree
Showing 11 changed files with 1,042 additions and 163 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Thumbs.db
/.clang-format
/msys64
/webots
/webots-controller
/webots.lnk
/webots_debug_output.txt
/util
Expand Down
255 changes: 97 additions & 158 deletions docs/guide/running-extern-robot-controllers.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/reference/changelog-r2023.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Webots R2023b
Released on ??
- New Features
- Added a new launcher to simplify the start of extern controllers ([#5629](https://github.com/cyberbotics/webots/pull/5629)).
- Cleanup
- Deprecated the C and MATLAB API functions `wb_supervisor_node_enable/disable_contact_point_tracking` in favor of `wb_supervisor_node_enable/disable_contact_points_tracking` to be more consistent with other APIs ([#5633](https://github.com/cyberbotics/webots/pull/5633)).
- Enhancements
Expand Down
2 changes: 2 additions & 0 deletions scripts/packaging/files_core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ src/controller/matlab/
src/controller/matlab/mgenerate.py

webots [exe,linux] # on Windows, we create a shortcut in setup.iss, on macOS, we create it in mac_distro.py
webots-controller [linux]
bin/webots-bin [linux]
bin/qt.conf [linux]

Expand Down Expand Up @@ -468,6 +469,7 @@ Contents/Frameworks/QtXml.framework/Versions/A/Resources/Info.plist [mac]
Contents/Info.plist [mac]
Contents/MacOS/ [mac]
Contents/MacOS/webots [exe,mac]
Contents/MacOS/webots-controller [exe,mac]
Contents/Resources/ [mac]
Contents/Resources/qt.conf [mac]
Contents/Resources/webots.rsrc [mac]
Expand Down
5 changes: 5 additions & 0 deletions src/controller/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ release debug profile clean:
@echo "# Java controller library ("$@")"
@echo "#"
@+make -s -C java $@
@echo "#"
@echo "# Matlab controller library ("$@")"
@echo "#"
@+make -s -C matlab $@
@echo "#"
@echo "# Controller launcher ("$@")"
@echo "#"
@+make -s -C launcher $@
48 changes: 48 additions & 0 deletions src/controller/launcher/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 1996-2023 Cyberbotics Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ifeq ($(WEBOTS_HOME),)
WEBOTS_HOME_PATH = ../../..
else
null :=
space := $(null) $(null)
WEBOTS_HOME_PATH?=$(subst $(space),\ ,$(strip $(subst \,/,$(WEBOTS_HOME))))
endif

default:
@echo "Type one of the following (OSTYPE is \""$(OSTYPE)"\"):"
@echo " make debug for debug (with gdb symbols)"
@echo " make profile for profiling (with gprof information)"
@echo " make release for final release"
@echo " make clean remove build directory"

include $(WEBOTS_HOME_PATH)/resources/Makefile.include

ifeq ($(OSTYPE),windows)
CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/msys64/mingw64/bin/webots-controller.exe
else ifeq ($(OSTYPE),darwin)
CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/Contents/MacOS/webots-controller
else
CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/webots-controller
endif

.PHONY: release debug profile

release debug profile: $(CONTROLLER_LAUNCHER)

$(CONTROLLER_LAUNCHER): webots_controller.c
@echo "# compiling" $<
@gcc $(CFLAGS) webots_controller.c -o $@

FILES_TO_REMOVE += $(CONTROLLER_LAUNCHER)
Loading

0 comments on commit 699328c

Please sign in to comment.