Unit 02 · lab

Lab: Sensor Evidence Notebook

This lab turns one controlled range message into a complete evidence record.

The terminal is deterministic lesson state. It does not execute a live ROS installation or connect to hardware.

xterm.js terminal simulation

Build a bounded sensor-evidence record

Inspect a declared interface and one simulated message, then keep the result separate from a movement claim.

This is a controlled command simulator. It does not execute Java, ROS 2, shell commands, or network requests on your device.

Commands worth trying
  • source /opt/ros/jazzy/setup.bash
  • ros2 interface show sensor_msgs/msg/Range
  • ros2 topic echo /range --once
  • javac SensorEvidence.java
  • java SensorEvidence

Part 1: Define the Java representation

Start with this intended application representation:

String sensorId = "front-range";
double frontRangeMeters = 0.42;

In your notebook, record:

  • the Java type of each variable;
  • what each name communicates;
  • the unit of the numeric value;
  • one fact the declaration cannot prove about the source of 0.42.

Then add:

final double cautionDistanceMeters = 0.50;

Predict the value of:

boolean obstacleTooClose =
    frontRangeMeters < cautionDistanceMeters;

Do not label the result safe or unsafe. Name the rule that actually ran.

Part 2: Source the ROS environment

Run:

source /opt/ros/jazzy/setup.bash

If you skip this step and a ROS command fails, record that as an environment problem, not as evidence that the interface or topic is missing.

Part 3: Inspect the message contract

Run:

ros2 interface show sensor_msgs/msg/Range

Record at least these fields:

header
min_range
max_range
range

For each field, write its role in your own words.

Then answer:

Does displaying the interface prove that /range has published a message?

Your answer should be no, followed by an explanation of the difference between a type definition and runtime traffic.

Part 4: Inspect one message instance

Run:

ros2 topic echo /range --once

Record the supplied:

  • frame ID;
  • min_range;
  • max_range;
  • range.

Now write the exact interval check using the observed values.

For example, if the message contains:

min_range: 0.10
max_range: 2.00
range: 0.42

record:

0.10 <= 0.42 <= 2.00
insideDeclaredRange = true

Do not replace the calculation with “reading good.”

Part 5: Run the controlled Java evidence program

Run:

javac SensorEvidence.java
java SensorEvidence

Preserve the output in a separate notebook section labeled Java program evidence.

Then compare it with the ROS message record.

Answer:

  1. Which values appear in both records?
  2. Does matching output prove the Java program consumed the ROS message?
  3. What integration evidence would be required to prove that connection?

The correct answer to question 2 is no. Similar values are not a demonstrated data path.

Part 6: Add an invalid case by reasoning

The terminal gives you a clean message. Now analyze this supplied case without changing the terminal:

min_range: 0.10
max_range: 2.00
range: 3.70

Determine:

insideDeclaredRange
obstacleTooClose

Be careful with the second result. A reading can be outside the declared sensor range and also fail to trigger a “too close” threshold. That does not make the reading trustworthy.

Write the handling decision you would prefer:

  • use the value anyway;
  • reject and preserve the value for diagnosis;
  • replace it silently;
  • stop the entire program.

Choose one and justify it. The course's preferred investigation pattern is to reject the value for the intended calculation while preserving the evidence.

Part 7: Complete the Sensor Evidence Notebook

Your final notebook must contain:

Java representation

Types, names, values, and units.

ROS message contract

Message type and relevant field roles.

Observed message

Exact supplied values from the terminal.

Derived decisions

The interval check and caution threshold result.

Invalid-case analysis

The 3.70 m supplied case and your handling decision.

Still not demonstrated

At least three missing facts, such as physical sensor accuracy, freshness under real runtime conditions, Java-to-ROS integration, or hardware response.

Next evidence

Name the next observation you would collect if the question became: “Is /range producing a continuing stream rather than one supplied message?”

Success criteria

Another student should be able to reconstruct every calculation in your notebook, identify which records came from Java and which came from ROS 2, and point to the exact sentence where you stop making claims about the physical robot.

If the notebook ends with “the sensor works,” it is not finished. If it ends with a precise statement of what was observed and what remains unknown, it is doing its job.