build details

# Creating a ROS Publisher

Modified 2020-07-23 by Dev Ramesh

Modified 5 days ago by Dev Ramesh

Student version

Hardware -

• Basestation

• Build Parts 1 and 2 completed

Previous Lesson

Knowledge - Python loops

Skills -

• Create custom ROS messages

• Create ROS publishers

• Use ROS commands

## Creating a ROS Publisher

### STANDARDS: Next Generation Science Standards (NGSS) and International Society for Technology in Education (ISTE)

Modified 2020-07-23 by Dev Ramesh

NGSS: HS - ETS1 - 2: Design a solution to a complex real-world problem by breaking it down into smaller, more manageable problems that can be solved through engineering.

NGSS: HS - PS4 - 2: Evaluate questions about the advantages of using a digital transmission and storage of information.

ISTE: 5. c.: Break problems into component parts, extract key information, and develop descriptive models to understand complex systems or facilitate problem-solving

### Assessments and Evidence of Understanding

Modified 2020-04-16 by Garrett Warren

### AGENDA (Brief Summary of Activities)

Modified 2020-04-16 by Garrett Warren

### Differentiation (strategies for grouping, ELL, and inclusion)

Modified 2020-04-16 by Garrett Warren

### Advanced preparation/Materials/Set Up (Including Misconceptions)

Modified 2020-09-08 by unknown

Teacher Materials

Basestation, drone build

Classroom Set Up

Teachers can write a DO NOW on the board for students to open the python file that read and print sensor values written in the sensor lesson.

## SCRIPT OF TEACHING AND LEARNING ACTIVITIES

Modified 2020-04-16 by Garrett Warren

### Introducing The Lesson

Modified 2020-09-08 by unknown

Review the code of reading sensor values in the student book.

Hook

How should we make this information useful to other parts of the robots?

ROS!

### Main Lesson

Modified 2020-09-08 by unknown

Teacher uses this tutorial to explain how to creat ROS messages.

Two types of messages that might need more explaining:

1. Header: The header contains a timestamp and coordinate frame information that is commonly used in ROS

2. Float: More precise measurement than integers

Then, students follow the teacher step by step to create a ROS publisher, which is detailed in the student book.

### Ending The Lesson

Modified 2 days ago by unknown

Time to visualize our progress!

Open up a new terminal, start up roscore by typing `roscore` and hit enter in order to get nodes running.

Navigate back to the previous terminal, run the code. We can see it is still printing sensor values.

What about the publisher we just created?

Open another terminal, run `rostopic list` and see the `distance` topic we just created. Then we run `rostopic info distance` to see the message type (Range) and where it is published from (infrared_node). Lastly, run `rostopic echo distance` to show the message we just created in the terminal! (It should be Range messages with data label)

How can we show our calibrated value (instead of the default) on the web interface?

According to the operations manual, before taking flight, after students start the flight code by hitting `./start`, they might hit “tick 5” to go to the infrared node and hit ‘Ctrl + C’ to stop it. Next, they might run their own script `python ~/ws/src/pidrone_pkg/ir.py`. Now the image shown on the web interface uses the value from the publisher they just wrote!

Useful Resources and References

Python Loops

ROS Tutorial on Creating Publisher and Subscriber