webots_launcher.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright 1996-2020 Cyberbotics Ltd.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 """This launcher simply start Webots."""
18 
19 import optparse
20 import os
21 import sys
22 import subprocess
23 
24 optParser = optparse.OptionParser()
25 optParser.add_option("--world", dest="world", default="", help="Path to the world to load.")
26 optParser.add_option("--mode", dest="mode", default="realtime", help="Startup mode.")
27 optParser.add_option("--no-gui", dest="noGui", default="false", help="Start Webots with minimal GUI.")
28 options, args = optParser.parse_args()
29 
30 if 'WEBOTS_HOME' not in os.environ:
31  sys.exit('WEBOTS_HOME environment variable not defined.')
32 command = [os.path.join(os.environ['WEBOTS_HOME'], 'webots'), '--mode=' + options.mode, options.world]
33 if options.noGui == 'true':
34  command.append('--stdout')
35  command.append('--stderr')
36  command.append('--batch')
37  command.append('--no-sandbox')
38  command.append('--minimize')
39 
40 subprocess.call(command)


webots_ros
Author(s): Cyberbotics
autogenerated on Fri Sep 4 2020 03:55:03