diff --git a/src/start_coppeliasim.cpp b/src/start_coppeliasim.cpp index f8d84518377c548f49c9620621e3aff1c70eadc5..fdd3357c77e21b39e3f968cfee724768f0ab9bc8 100644 --- a/src/start_coppeliasim.cpp +++ b/src/start_coppeliasim.cpp @@ -1,11 +1,9 @@ /* - * start_webots.cpp + * coppeliasim_run.cpp * - * Starts the Webots Simulator using a system() call, so Webots can be + * Starts the coppeliasim Simulator using a system() call, so coppeliasim can be * started from a roslaunch file. * - * Date: September 2012 - * Authors: David Butterworth * */ @@ -42,50 +40,57 @@ #include <iostream> // stringstream /* -Define Webots executable name. -The full path will come from the PATH environment variable. -Prefix with 'optirun' for Linux NVidia Bumblebee graphics driver - -Webots command line arguments: - --minimize - --mode=run - --mode=stop - (http://www.cyberbotics.com/dvd/common/doc/webots/guide/section2.2.html) -*/ -#define WEBOTS_EXECUTABLE "webots --mode=run" -//#define WEBOTS_EXECUTABLE "optirun webots --mode=run" +coppeliasim command line arguments: +-h: runs CoppeliaSim in headless mode (i.e. without any GUI) + +-sXXX: automatically start the simulation. + with XXX represents an optional simulation time in milliseconds after which simulation should stop again. + +-q: automatically quits CoppeliaSim after the first simulation run ended. + +-gREMOTEAPISERVERSERVICE_PORT_DEBUG_PREENABLESYNC: the argument can be used to request + a continuous legacy remote API server service to be started at CoppeliaSim start-up. + For that to happen, replace in above string following: +PORT is the port number +DEBUG is the debug mode (set to TRUE or FALSE) +PREENABLESYNC allows to preenable the synchronous mode (set to TRUE or FALSE) + +-XXX.ttt: loads a CoppeliaSim scene. +-XXX.ttm: loads a CoppeliaSim model. +-XXX.brs: loads an XReality scene. +-XXX.brm: loads an XReality model. +*/ +#define COPPELIASIM_EXECUTABLE "cd ~/CoppeliaSim && ./coppeliaSim.sh" //----------------------------------------------------------------------------// int main(int argc, char **argv) { - // node name: webots - ros::init(argc, argv, "webots"); - - if ( argc != 2 ) - { - // no additional arguments, start Webots with previously opened world - ROS_INFO("Starting Webots simulator... \n"); - if (system(WEBOTS_EXECUTABLE)) {} - } - else - { - // additional arguments: - // argv[0] is full path to this ROS Node - // argv[1] is full path to world file - // argv[2] is full path to ROS log file - ROS_INFO("Starting Webots simulator... "); - ROS_INFO("Loading world: %s \n", argv[1]); - - std::stringstream ss; - ss << WEBOTS_EXECUTABLE << " " << argv[1]; - if (system( ss.str().c_str() )) {} + // node name: coppeliasim + ros::init(argc, argv, "coppeliasim"); + ROS_INFO("Starting coppeliasim simulator... "); + + std::stringstream ss; + switch (argc){ + case 2: + ss << COPPELIASIM_EXECUTABLE << " " << argv[1]; + break; + + case 3: + ss << COPPELIASIM_EXECUTABLE << " " << argv[1] << " " << argv[2]; + break; + + case 4: + ss << COPPELIASIM_EXECUTABLE << " " << argv[1] << " " << argv[2] << " " << argv[3]; + break; + + default: + ss << COPPELIASIM_EXECUTABLE ; } - // No need to ros::spin() - // When we quit Webots, ROS will register - // that the webots node is shutting down. + if (system( ss.str().c_str() )) {} + return 0; }