Python

If you want to recreate it in python, the file structure will be this

 ros2_ws/
  src/
    py_float/ #be creative and change the name
      listener_float_py.py
      talker_float_py.py
      package.xml
      setup.py

import sys

import rclpy

from rclpy.qos import qos_profile_default

def chatter_callback(msg):
    print('I heard: [%s]' % msg.data)

def main(args=None):
    if args is None:
        args = sys.argv

    rclpy.init(args)

    from std_msgs.msg import Float32

    node = rclpy.create_node('listener_float_py')

    sub = node.create_subscription(Float32, 'chatter', chatter_callback, qos_profile_default)
    assert sub  # prevent unused warning

    while rclpy.ok():
        rclpy.spin_once(node)

if __name__ == '__main__':
    main()

import sys
from time import sleep

import rclpy

from rclpy.qos import qos_profile_default

def main(args=None):
    if args is None:
        args = sys.argv

    rclpy.init(args)

    from std_msgs.msg import Float32

    node = rclpy.create_node('talker_float_py')

    chatter_pub = node.create_publisher(Float32, 'chatter', qos_profile_default)

    msg = Float32()

    i = 1
    while True:
        msg.data = float(i)
        i += 0.5
        print('Publishing: "{0}"'.format(msg.data))
        chatter_pub.publish(msg)
        sleep(1)

if __name__ == '__main__':
    main()

<?xml version="1.0"?>
<package format="2">
  <name>py_float</name>
  <version>0.0.0</version>
  <description>Package containing examples of how to use the rclpy API.</description>
  <maintainer email="esteve@osrfoundation.org">Esteve Fernandez</maintainer>
  <license>Apache License 2.0</license>

  <exec_depend>rclpy</exec_depend>
  <exec_depend>std_msgs</exec_depend>

  <test_depend>ament_copyright</test_depend>
  <test_depend>ament_pep257</test_depend>
  <test_depend>ament_pep8</test_depend>
  <test_depend>ament_pyflakes</test_depend>
  <test_depend>rclpy</test_depend>
  <test_depend>std_msgs</test_depend>

  <export>
    <build_type>ament_python</build_type>
  </export>
</package>

from setuptools import setup

setup(
    name='py_float',
    version='0.0.0',
    packages=[],
    py_modules=['listener_float_py', 'talker_float_py'],
    install_requires=['setuptools'],
    author='Esteve Fernandez',
    author_email='esteve@osrfoundation.org',
    maintainer='Esteve Fernandez',
    maintainer_email='esteve@osrfoundation.org',
    keywords=['ROS'],
    classifiers=[
        'Intended Audience :: Developers',
        'License :: OSI Approved :: Apache Software License',
        'Programming Language :: Python',
        'Topic :: Software Development',
    ],
    description='Package containing examples of how to use the rclpy API.',
    license='Apache License, Version 2.0',
    test_suite='test',
    entry_points={
        'console_scripts': [
            'listener_float_py = listener_float_py:main',
            'talker_float_py = talker_float_py:main',
        ],
    },
)

The next command will build and install the new package

$ cd ~/ros2_ws
$ ament build --symlink-install --only-package py_float

Now you only need to run two terminals at the same time the following:

$ . ./ros2_ws/install/setup.bash
$ talker_float_py
$ . ./ros2_ws/install/setup.bash
$ listener_float_py

Do you need more computing capacity? Stay tuned