Repository to provide out-of-the-box examples to work with RViz and Python.
Clone this repository to your catkin workspace:
$ git clone git@github.com:hpoleselo/rviz-python-basics.git
Make it:
$ catkin_make
Make sure the recent-downloaded package is available in your local:
$ rospack find rviz_with_python
Make sure the Python script is executable:
$ roscd rviz_with_python/src
$ chmod +x publish_spheres.py
A launch file will be written to avoid following all those steps to reproduce the functionality, anyways following these steps are useful to understand what's going on under the hood:
- Run ROS:
$ roscore
- Create a transform
/tf
tree by publishing a static transformation between two frames that will start to exist from the moment we publish them:
$ rosrun tf static_transform_publisher 0 0 0 0 0 0 1 map sphere 10
Basically we're saying the map frame is on the same XYZ and orientation as the sphere frame.
- Run RViz:
$ rosrun rviz rviz
- On RViz, make sure to click on
Add
->Marker
->Ok
:
- Run the sphere publisher script (file has to be executable):
$ rosrun rviz_with_python publish_spheres.py
Could be done without being in the package and by running Python directly:
$ python3 sphere_publisher.py
We should get the following result:
Although the launch file is already created, I must get somethings right:
$ roslaunch rviz_with_python sphere_publisher.launch