http://answers.ros.org/question/28557...
Check out the above question and following answers.
Or you could always just fork and give a command using system or one of the exec* functions.
something like
pid_t child = fork()
if (child == 0){
system("rosrun gazebo spawn_model -file <path to xml/urdf file> -urdf -model <model_name>");
}
As to how to control the robot. Just publish to the topics the robot is listening to.
I've been using ros hydro and indigo to simulate and control a Turtlebot 2.0.
What I do is launch the gazebo simulator and turtlebot urdf model using
roslaunch turtlebot_gazebo turtlebot_empty_world.launch
and then run my own programs I created with roscpp that issues commands through the cmd_vel_mux topic
and listens to the various sensors.