Skip to content

Commit a324b59

Browse files
author
Murilo Marinho
committed
[nodes] Removing mentions to PyCharm.
1 parent 92a25a0 commit a324b59

2 files changed

Lines changed: 36 additions & 44 deletions

File tree

docs/source/create_python_node_from_scratch.rst

Lines changed: 35 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,29 @@ Creating a Python Node from scratch (for :program:`ament_python`)
1515
Let us add an additional Node to our :program:`ament_python` package that actually uses ROS2 functionality.
1616
These are the steps that must be taken, in general, to add a new Node.
1717

18+
File structure
19+
--------------
20+
21+
In this section, we will be modifying or creating the following files.
22+
23+
.. code-block:: console
24+
:emphasize-lines: 2,5,10
25+
26+
python_package_with_a_node
27+
|-- package.xml
28+
|-- python_package_with_a_node
29+
| |-- __init__.py
30+
| |-- print_forever_node.py
31+
| `-- sample_python_node.py
32+
|-- resource
33+
| `-- python_package_with_a_node
34+
|-- setup.cfg
35+
|-- setup.py
36+
`-- test
37+
|-- test_copyright.py
38+
|-- test_flake8.py
39+
`-- test_pep257.py
40+
1841
.. _Handling dependencies:
1942

2043
Handling dependencies (:file:`package.xml`)
@@ -30,69 +53,31 @@ By no coincidence, the :file:`package.xml` has the :code:`.xml` extension, meani
3053

3154
Let us add the dependency between the :code:`<license>` and :code:`<test_depend>` tags. This is not a strict requirement but is where it commonly is for standard packages.
3255

33-
:download:`~/ros2_tutorial_workspace/src/python_package_with_a_node/package.xml <../../ros2_tutorial_workspace/src/python_package_with_a_node/package.xml>`
56+
:download:`package.xml <../../ros2_tutorial_workspace/src/python_package_with_a_node/package.xml>`
3457

3558
.. literalinclude:: ../../ros2_tutorial_workspace/src/python_package_with_a_node/package.xml
3659
:language: xml
3760
:linenos:
3861
:emphasize-lines: 10
3962

40-
After you modify the workspace, build it once
41-
---------------------------------------------
42-
43-
.. warning:
44-
45-
Depending on the particulars of the workspace you are (re)building, :program:`PyCharm` will only be able to recognize certain changes if it is restarted from a properly sourced terminal.
46-
47-
After you add a new dependency to :file:`package.xml`, nothing really changes in the workspace unless a new build is performed.
48-
49-
In addition, when programming with new dependencies, unless you rebuild the workspace, :program:`PyCharm` will not recognize the libraries, and autocomplete will not work.
50-
51-
So,
52-
53-
#. close :program:`PyCharm`.
54-
#. Run (in the terminal you used to run :program:`PyCharm` before)
55-
.. include:: the_canonical_build_command.rst
56-
#. Re-open pycharm
57-
.. code:: console
58-
59-
pycharm_ros2
60-
61-
6263
Creating the Node
6364
-----------------
6465

6566
In the directory :file:`src/python_package_with_a_node/python_package_with_a_node`, create a new file called :file:`print_forever_node.py`. Copy and paste the following contents into the file.
6667

67-
:download:`~/ros2_tutorial_workspace/src/python_package_with_a_node/python_package_with_a_node/print_forever_node.py <../../ros2_tutorial_workspace/src/python_package_with_a_node/python_package_with_a_node/print_forever_node.py>`
68+
:download:`print_forever_node.py <../../ros2_tutorial_workspace/src/python_package_with_a_node/python_package_with_a_node/print_forever_node.py>`
6869

6970
.. literalinclude:: ../../ros2_tutorial_workspace/src/python_package_with_a_node/python_package_with_a_node/print_forever_node.py
7071
:language: python
7172
:linenos:
7273
:lines: 24-
7374

74-
By now, this should be enough for you to be able to run the node in :program:`PyCharm`. You can right-click it and choose :guilabel:`D&ebug print_forever_node`. This will output
75-
76-
.. code :: console
77-
78-
[INFO] [1753518435.025424000] [print_forever]: Printed 0 times.
79-
[INFO] [1753518435.509299083] [print_forever]: Printed 1 times.
80-
[INFO] [1753518436.009566292] [print_forever]: Printed 2 times.
81-
[INFO] [1753518436.509644292] [print_forever]: Printed 3 times.
82-
[INFO] [1753518437.009296251] [print_forever]: Printed 4 times.
83-
84-
To finish, press the :guilabel:`Stop` button or press :kbd:`CTRL+F2` on :program:`PyCharm`. The node will exit gracefully with
85-
86-
.. code :: console
87-
88-
Process finished with exit code 0
89-
9075
.. _Making rosrun work:
9176

9277
Making :command:`ros2 run` work
9378
-------------------------------
9479

95-
Even though you can run the new node in :program:`PyCharm`, we need an additional step to make it deployable in a place where :command:`ros2 run` can find it.
80+
We need an additional step to make it deployable in a place where :command:`ros2 run` can find it.
9681

9782
To do so, we modify the :code:`console_scripts` key in the :code:`entry_points` dictionary defined in :file:`setup.py`, to have our new node, as follows
9883

@@ -116,19 +101,25 @@ The format is straightforward, as follows
116101
:code:`main` The function, within the script, that will be called. In general, :code:`main`.
117102
================================== ===================================================================================
118103

119-
Once again, we have to refresh the workspace so we run
104+
Build and source
105+
----------------
106+
107+
We can build and source the workspace with the following command.
120108

121109
.. include:: the_canonical_build_command.rst
122110

111+
Test
112+
----
113+
123114
And, with that, we can run
124115

125-
.. code :: console
116+
.. code-block:: console
126117
127118
ros2 run python_package_with_a_node print_forever_node
128119
129120
which will output, as expected
130121

131-
.. code :: console
122+
.. code-block:: console
132123
133124
[INFO] [1753518652.646459087] [print_forever]: Printed 0 times.
134125
[INFO] [1753518653.131078795] [print_forever]: Printed 1 times.

docs/source/source_after_build.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ folder will hold, for instance, launch files and other installable files that mi
5454

5555
.. code-block:: console
5656
57+
python_package_with_a_node/
5758
|-- lib
5859
| `-- python_package_with_a_node
5960
| `-- sample_python_node

0 commit comments

Comments
 (0)