cogimon / cogimon.github.io

COGIMON Top-Level Documentation
GNU Lesser General Public License v3.0
1 stars 4 forks source link

Deployer "if-else" #28

Open ndehio opened 7 years ago

ndehio commented 7 years ago

When writing ops-files for the deployer, I am missing a very simple "if-else" feature. Without that feature it is annoying and time consuming to quickly test different controller options for the same scenario (e.g. connecting portA or portB to another component, for example for sending a Jacobian with/without orientational part)

ndehio commented 7 years ago

The solution is actually pretty simple... (thanks to my masterstudent William!) @xwavex, please add this following example for spawning multiple robots at once (demonstrating the if-else feature and a for loop) to the documentation.

############################################################################# import("rtt_gazebo_embedded"); import("rtt-gazebo-robot-sim"); require("os"); require("print");

loadComponent("gazebo","RTTGazeboEmbedded"); setActivity("gazebo",0,10,ORO_SCHED_OTHER); gazebo.argv = strings("--verbose"); gazebo.add_plugin("libRTTGazeboClockPlugin.so"); gazebo.configure(); gazebo.start(); gazebo.toggleDynamicsSimulation(false);

var string path_model_urdf = os.getenv("GAZEBO_MODEL_PATH")+"/kuka-lwr-4plus/model.urdf"; var string path_model_srdf = os.getenv("GAZEBO_MODEL_PATH")+"/kuka-lwr-4plus/model.srdf"; var int numRobots = 3; var array arr = (1)*numRobots; var int i = 0; for (i = 0; i < numRobots; i = i + 1 ) { arr[i] = i; loadComponent("robot_gazebo"+i,"cogimon::robotSim"); setActivity("robot_gazebo"+i,0,10,ORO_SCHED_OTHER); eval("gazebo.spawn_model_at_pos(\"robotmodel"+i+"\", \"model://kuka-lwr-4plus\", "+i+","+i+",0);"); eval("robot_gazebo"+i+".getModel(\"robotmodel"+i+"\");"); eval("robot_gazebo"+i+".loadURDFAndSRDF(\""+path_model_urdf+"\", \""+path_model_srdf+"\");"); eval("robot_gazebo"+i+".configure();"); eval("robot_gazebo"+i+".setControlMode(\"full_arm\", \"JointTorqueCtrl\");"); }

gazebo.toggleDynamicsSimulation(true);

var int test = 42; var string msg = ""; if (test == 42) then { msg = "######### true #########"; } else { msg = "######### false #########"; } print.ln(msg);