ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Creating the turtlesim environment through code.

asked 2012-01-27 00:00:45 -0600

Index gravatar image

updated 2012-01-27 04:13:08 -0600

Hi all. I've just started using ROS yesterday - i've completed the 15 or so beginner tutorials that utilize turtlesim. I've begun writing my own .cpp file - since i'm a beginner this is all pretty new to me. I'm trying to figure out how to create the actual turtlesim simulator window from C++ code. This sounds like it would be easy so can anyone help? I've been looking at several of the files in the documentation but there isn't a real clear answer.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-01-27 00:52:27 -0600

DimitriProsser gravatar image

updated 2012-01-27 00:55:21 -0600

The turtlesim window is a separate executable. Typically, C++ does not support running executable from code. Typically you have to use the system() command to do so. But, there is also a system called rosspawn that might just do what you want it to do.

I'm not sure what the end goal is, but there are a couple of options I can think of:

If you're trying to launch turtlesim at the same time as one of your own executables, I would suggest roslaunch.

If you're looking to do something that you cannot do via turtlesim's topics and services, I would suggest looking at the code for turtlesim in the turtlesim package (probably in the src directory). You might be able to modify it to your needs.

If you edit your question to be more specific as to the goal, I might be able to help further.

edit flag offensive delete link more

Comments

Thanks, using a launch file and roslaunch worked! I just want to learn the basics and build from there - I am a beginner after all. After looking at the sample source .cpp files, there doesn't seem to be a clear way to just simply move the robot forward or turn - can you help me with that?
Index gravatar image Index  ( 2012-01-27 04:15:18 -0600 )edit
I would start a new question for that so that others can benefit from it.
DimitriProsser gravatar image DimitriProsser  ( 2012-01-27 05:42:19 -0600 )edit

Question Tools

Stats

Asked: 2012-01-27 00:00:45 -0600

Seen: 807 times

Last updated: Jan 27 '12