Objectives

In this assignment, you will create a ROS node that both subscribes to a topic for input and publishes to a NEW topic as output. Here are the specifications for this new node:

  • It should be in the same package you used in Lab 1.2
  • It should subscribe to the pose output of turtlesim
  • For each message that your node receives on this topic, calculate the distance traveled by the turtle (see lecture slides) and publish a single message to a new topic (name is your choice) that:
    • Uses the std_msgs/Float32 message type
    • Includes the distance value
  • Create a new launch file that will:
    • Start this new node
    • Include your Lab 1.2 launch file (see tip below)
    • Include an instruction to make “ros2 topic echo” run for your chosen output topic (see tip below)
  • Do NOT change any previous code (i.e. your Lab 1.2 submission) unless told to after it is graded.
  • Push your code to GitHub with a tag for this assignment, as in Lab 1.2.

Make sure you test this code thoroughly so you know that it works. You can test the odometry by running your node using ros2 run and test the entire assignment using ros2 launch and the launch file you provided.

Submission Instructions

Complete the Qualtrics survey containing:

  1. Your name, repo URL, and the tag for this assignment
  2. The command that starts your nodes for this assignment, ie:
    ros2 launch <package> <launch_file>
  3. The name of the node you created
  4. The name of the topic that your node publishes to
  5. Additional questions about ROS programming
  6. Any difficulties you had with this assignment

Rubric

6 points – Subscribes to turtlesim/sim pose topic
6 points – Publishes to specifications
18 points – Launch file and launcher script meet objectives
6 points – Tag applied in git
24 points – Answers given in survey (3 points per question)

Tip

Launch files have many powerful options, but some are a bit hidden. To make it easier for you, you can use some or all of this template for this assignment, filling in components as needed.

from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import IncludeLaunchDescription
from launch.actions import ExecuteProcess
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import PathJoinSubstitution, TextSubstitution
from launch_ros.substitutions import FindPackageShare

def generate_launch_description():
    return LaunchDescription([
        IncludeLaunchDescription(
            PythonLaunchDescriptionSource([
                PathJoinSubstitution([
                    FindPackageShare('<PACKAGE_NAME>'),
                    '<LAB1.2_LAUNCH_FILE_NAME>'
                ])
            ])
        ),
        Node(
            package='<PACKAGE_NAME>',
            namespace='turtlesim1',
            executable='<LAB1.3_NODE_NAME>',
            name='<YOUR_CHOICE>'
        ),
        ExecuteProcess(
            cmd=[
                'ros2',
                'topic',
                'echo',
                '<TOPIC_NAME>',
                'std_msgs/Float32'
            ],
            shell=True,
            output='screen'
        )
    ])