python function not found

Visto 43 veces
Saltar al primer mensaje no leído

Davide Picchi

no leída,
20 ago 2014, 16:08:0220/8/14
a ros-by-...@googlegroups.com
Hello Patrick,
in your script (nav_test.py) you wrote the following line of code:

80 rospy.wait_for_message('initialpose', PoseWithCovarianceStamped)

the idea is to save the initialpose from Rviz into a variable.
Since I m going to write all those tutorial on C++ (as exercise) I cannot find any similar function for C++ in the API classes. Even for python I couldnt find any API documentation. Can you plase tell me where to take a look?
To be honest I found something with that name: http://docs.ros.org/hydro/api/roscpp/html/namespaceros_1_1topic.html But I m not sure that I can use that function. How could I save the Rviz Pose into a variable?

There is another thing. I read and read many times the 8.5.4 Running the Navigation Test in Simulation p. 113 in your first book (Hydro).
Regarding your explanation you say when and how launch the launch files, but you don t say when is it time to fire the above script.
I mean...reading the text is not really clear.

Thank you very much in advance!
Regards

Patrick Goebel

no leída,
21 ago 2014, 11:30:1821/8/14
a ros-by-...@googlegroups.com
Hi Davide,

The line below simply waits until a message is published on the /initialpose topic.  This is a blocking statement and the script won't proceed until a message is received.  Once the user sets the initial pose in RViz, the corresponding pose message is published on this topic and the script proceeds to the next two lines which are:

self.last_location = Pose()
rospy.Subscriber('initialpose', PoseWithCovarianceStamped, self.update_initial_pose)


The first line just initializes the self.last_location variable for later use.  The second line subscribes to the /initialpose topic and passes any received messages to the callback function self.update_initial_pose which looks like:

def update_initial_pose(self, initial_pose):

   self.initial_pose = initial_pose


So the callback simply sets the variable self.initial_pose to the incoming message.

These lines have their equivalents in the C++ API.  I suggest looking at the online tutorial Writing a Simple Publisher and Subscriber (C++).  In particular, you will need the subscriber code.

As for Section 8.5.4, the nav_test.py script is run when the fake_nav_test.launch file is run.  ROS launch files can be used to fire up nodes (scripts and binaries) and set parameters.  If you look near the end of the fake_nav_test.launch file, you will see these lines:

  <!-- Start the navigation test -->
  <node pkg="rbx1_nav" type="nav_test.py" name="nav_test" output="screen">
    <param name="rest_time" value="1" />
    <param name="fake_test" value="true" />
  </node
>

This is where the actual nav_test.py script is run while also setting the parameters rest_time to 1 and fake_test = true.  Note that the nodes in a ROS launch file are not necessary run in the same order as they appear in the launch file which is one of the reasons we block the nav_test.py script until we receive a message on the /initialpose topic.

Please see the roslaunch tutorial for more details on using ROS launch files.

As a general note, the ROS By Example books assume you have read through the online Beginner's Tutorials that cover basics.  These tutorials are well written and cover both the Python and C++ APIs for the basic ROS concepts.

--patrick

Davide Picchi

no leída,
21 ago 2014, 15:56:5321/8/14
a ros-by-...@googlegroups.com
Hey man!
Thank you sooooo much!! You have me explained the script really really really good.

Anyway. i understand, maybe it could be frustrating to answer always the same questions. Trust me, I started with ROS one month ago and I did the beginner's Tutorials sooo many times..... The Tutorials explain lots of stuff and are very detailed. They teach one a lot of basilar functions of ROS. But they fails to give the reader how one should think in ROS. In order to solve a problem using ROS you have not do just the tutorials, you should digest how ROS works and think in the right way of the programmer, who the tutorials did. I think that is the point. And now I can confirm I found the python script not clear because I write my programs in C++ and am really really new in python. Trying to understand the meaning of the code and why you did something like that instead of that, I failed to recognize, what those commands really do.
Now that you told me exactly what the meaning of those lines of code, I can understand much better how it works.

Thank you very much again!
Regards






--
You received this message because you are subscribed to the Google Groups "ros-by-example" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ros-by-exampl...@googlegroups.com.
Visit this group at http://groups.google.com/group/ros-by-example.
For more options, visit https://groups.google.com/d/optout.



--

Patrick Goebel

no leída,
21 ago 2014, 19:49:5621/8/14
a ros-by-...@googlegroups.com
Hi Davide,

Glad it's making more sense now!

--patrick
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos