Skip to content

Makes reading from line sensor more robust, and updates the calibration procedure - #145

Open
hello-ola wants to merge 15 commits into
mainfrom
refactor/line_sensor_refactor
Open

Makes reading from line sensor more robust, and updates the calibration procedure #145
hello-ola wants to merge 15 commits into
mainfrom
refactor/line_sensor_refactor

Conversation

@hello-ola

@hello-ola hello-ola commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

This PR has the following updates

  1. pixart_j3_reader.py — the decode path was rewritten:
  • 5.09 vs 5.11 are now decoded, not averaged in. These were being treated as distances but they are actually codes. Decode now returns ranges (NaN at every non-measurement bin) plus a per-bin codes array. All sentinel logic lives in one place, protocol.py.
  • Bin order and bus map come from robot params, not hardcoded. A wrong bin order mirrors every reading left-to-right and nothing downstream can detect it, so missing params raise rather than default.
  • The reader no longer dies permanently. A serial error used to set is_valid = False and leak the descriptor; since the port is opened exclusive=True, every reopen then failed with "device busy" and the subsystem stayed dead until reboot. Now it closes, marks sensors dead, and retries on a 0.5→5 s backoff (reader_restarts).
  • Bad JSON no longer kills the stream — truncated reports / lost newlines are recovered or counted (decode_errors).
  • Per-sensor liveness. A stopped sensor used to keep its last ranges forever, indistinguishable from a flat floor.
  • Runtime on/off — set_streaming(), set_sensor_enabled(); neither persists.
  1. Added new scripts for easier inspection of the line sensors: stretch_line_sensor_ranges, stretch_line_sensor_z_band and stretch_line_sensor_hz_check.

All line sensor tools go through line_sensor/connect.py: use the server if up, else open /dev/hello-pixart-j3 directly.

  1. Updated the calibration script
REx_line_sensor_calibrate --all --inspect      # quick floor check only, ~2 s
REx_line_sensor_calibrate --all                # inspect, then record + save
REx_line_sensor_calibrate --all --dry-run
REx_line_sensor_calibrate --recompute <session_id>   # no robot needed
  1. add a REx_line_sensor_migrate_tares if people want to migrate the older version.

  2. stretch_system_check
    Line sensor section now always reports the hz and passes if hz > 25.

Cleanup

  • REx_line_sensor_display removed
  • line_sensor_model_ae.py, line_sensor_model_ck.py, line_sensor_vel_limit.py removed, along with the commented-out line_sensor_vel_limit params.

To test:
0. test that the migration works. after installing the new version. make sure you dont have a tare folder in calibration_line_sensors. after restarting the server if you have linesensor loop enabled or after running stertch_line_sensor* script it should create a tare file from your old data.

  1. Run calibration on different floors. Use stretch_line_sensor_ranges to see whether the robot's current position reports a lot of 5.11 points, then run the inspection, it should tell you to find another floor if it does. Move to a white floor, check the 5.11 points again, and rerun the inspection; it should pass.
stretch_line_sensor_ranges
REx_line_sensor_calibrate --all --inspect
  1. With a good run, make sure the tare is saved to the fixed path and that each tare records a config fingerprint (bus map, flip, report count, geometry, code mapping), and that the session shows up under stretch_user.
REx_line_sensor_calibrate --all
ls ~/stretch_user/stretch-se4-XXXX/calibration_line_sensors/tare/
cat ~/stretch_user/stretch-se4-XXXX/calibration_line_sensors/tare/sensor_0_tare.yaml
ls ~/stretch_user/stretch-se4-XXXX/calibration_line_sensors/sessions/

  1. Make sure the new scripts run both with and without stretch_body_server running. Drive the base around and check that obstacles register.

stretch_line_sensor_ranges
stretch_line_sensor_z_band
stretch_line_sensor_hz_check
stretch_line_sensor_viz_3d

And system check reports correctly if line sensors are up or not.
stretch_system_check
if stretch_body_server doesnt enable line sensor, make sure line sensor dont fail they measure the hz directly and say that the loop is not enabled

@hello-ola hello-ola changed the title Refactor/line sensor refactor Made reading from line sensor more robust, and updated the calibration procedure Aug 13, 2026
@hello-ola hello-ola changed the title Made reading from line sensor more robust, and updated the calibration procedure Makes reading from line sensor more robust, and updates the calibration procedure Aug 13, 2026
@hello-robot-shehab

Copy link
Copy Markdown
Contributor

Works as expected!

$ REx_line_sensor_calibrate --all --inspect
body server is not serving line_sensor_loop -- opening /dev/hello-pixart-j3 directly
[08/14/2026 19:35:07] [line_sensor_loop] [INFO]: Starting LineSensorLoop...
[08/14/2026 19:35:07] [line_sensor_loop] [INFO]: -------- Starting Line_sensor_loop with PID 16670 --------
[08/14/2026 19:35:07] [line_sensor_loop] [WARNING]: sensor_0: NO TARE (missing)
[08/14/2026 19:35:07] [line_sensor_loop] [WARNING]: sensor_1: NO TARE (missing)
[08/14/2026 19:35:07] [line_sensor_loop] [WARNING]: sensor_2: NO TARE (missing)
[08/14/2026 19:35:07] [line_sensor_loop] [WARNING]: sensor_3: NO TARE (missing)
[08/14/2026 19:35:07] [line_sensor_loop] [WARNING]: sensor_4: NO TARE (missing)
[08/14/2026 19:35:07] [line_sensor_loop] [WARNING]: sensor_5: NO TARE (missing)
[08/14/2026 19:35:07] [line_sensor_loop] [INFO]: Line sensor calibration: 0/6 sensors loaded
reading /dev/hello-pixart-j3 directly (no body server on the sensors)

Place the robot on a clean, flat, light-coloured floor with
nothing within ~0.5 m of the base.
ideal flat-floor range 0.229646 m (axial_depth_constant_v1)
inspecting the floor (60 frames)...
recording: 100%|██████████████████████████████████████████████████████████████████████| 60/60 [00:01<00:00, 30.60frame/s]

floor inspection:
  sensor_0: OK    floor 100.0%  5.11   0.0%  5.09   0.0%  off-window   0.0%  bins-would-pass 100.0%
  sensor_1: OK    floor 100.0%  5.11   0.0%  5.09   0.0%  off-window   0.0%  bins-would-pass 100.0%
  sensor_2: OK    floor 100.0%  5.11   0.0%  5.09   0.0%  off-window   0.0%  bins-would-pass 100.0%
  sensor_3: OK    floor 100.0%  5.11   0.0%  5.09   0.0%  off-window   0.0%  bins-would-pass 100.0%
  sensor_4: OK    floor 100.0%  5.11   0.0%  5.09   0.0%  off-window   0.0%  bins-would-pass 100.0%
  sensor_5: OK    floor 100.0%  5.11   0.0%  5.09   0.0%  off-window   0.0%  bins-would-pass 100.0%
  => floor looks usable for calibration
[08/14/2026 19:35:09] [line_sensor_loop] [INFO]: Line_sensor_loop EXIT!
[08/14/2026 19:35:09] [line_sensor_loop] [INFO]: Exiting Line_sensor_loop Loop

$ REx_line_sensor_calibrate --all
body server is not serving line_sensor_loop -- opening /dev/hello-pixart-j3 directly
[08/14/2026 19:37:48] [line_sensor_loop] [INFO]: Starting LineSensorLoop...
[08/14/2026 19:37:48] [line_sensor_loop] [INFO]: -------- Starting Line_sensor_loop with PID 16795 --------
[08/14/2026 19:37:48] [line_sensor_loop] [WARNING]: sensor_0: NO TARE (missing)
[08/14/2026 19:37:48] [line_sensor_loop] [WARNING]: sensor_1: NO TARE (missing)
[08/14/2026 19:37:48] [line_sensor_loop] [WARNING]: sensor_2: NO TARE (missing)
[08/14/2026 19:37:48] [line_sensor_loop] [WARNING]: sensor_3: NO TARE (missing)
[08/14/2026 19:37:48] [line_sensor_loop] [WARNING]: sensor_4: NO TARE (missing)
[08/14/2026 19:37:48] [line_sensor_loop] [WARNING]: sensor_5: NO TARE (missing)
[08/14/2026 19:37:48] [line_sensor_loop] [INFO]: Line sensor calibration: 0/6 sensors loaded
reading /dev/hello-pixart-j3 directly (no body server on the sensors)

Place the robot on a clean, flat, light-coloured floor with
nothing within ~0.5 m of the base.
ideal flat-floor range 0.229646 m (axial_depth_constant_v1)
inspecting the floor (60 frames)...
recording: 100%|██████████████████████████████████████████████████████████████████████| 60/60 [00:01<00:00, 30.66frame/s]

floor inspection:
  sensor_0: OK    floor 100.0%  5.11   0.0%  5.09   0.0%  off-window   0.0%  bins-would-pass 100.0%
  sensor_1: OK    floor 100.0%  5.11   0.0%  5.09   0.0%  off-window   0.0%  bins-would-pass 100.0%
  sensor_2: OK    floor 100.0%  5.11   0.0%  5.09   0.0%  off-window   0.0%  bins-would-pass 100.0%
  sensor_3: OK    floor 100.0%  5.11   0.0%  5.09   0.0%  off-window   0.0%  bins-would-pass 100.0%
  sensor_4: OK    floor 100.0%  5.11   0.0%  5.09   0.0%  off-window   0.0%  bins-would-pass 100.0%
  sensor_5: OK    floor 100.0%  5.11   0.0%  5.09   0.0%  off-window   0.0%  bins-would-pass 100.0%
  => floor looks usable for calibration
recording 300 distinct frames for: sensor_0, sensor_1, sensor_2, sensor_3, sensor_4, sensor_5
recording: 100%|████████████████████████████████████████████████████████████████████| 300/300 [00:09<00:00, 30.22frame/s]
session: /home/shehab/stretch_user/stretch-se4-4024/calibration_line_sensors/sessions/20260814193750

=== sensor_0 ===
  frames: 300 distinct of 300 requested in 9.93s (30.22/s); 3862 duplicate polls skipped
  samples: valid 96000 (100.00%)  no-return 5.11 0 (0.00%)  beyond-limit 5.09 0 (0.00%)
  out-of-window (a real return, but not floor): 0   other invalid: 0
  bins accepted: 320/320 (need 288; 270 valid frames per bin)
  median offset -30.65 mm   per-bin MAD median/p95/max 0.00/1.00/1.00 mm
  ~ median tare across accepted bins is -30.6 mm; a uniform shift that large is a geometry PARAMETER error rather than sensor bias -- emitter_height_above_floor_mm is probably wrong
  sensor_0: SAVED /home/shehab/stretch_user/stretch-se4-4024/calibration_line_sensors/tare/sensor_0_tare.yaml

=== sensor_1 ===
  frames: 300 distinct of 300 requested in 9.93s (30.22/s); 3862 duplicate polls skipped
  samples: valid 96000 (100.00%)  no-return 5.11 0 (0.00%)  beyond-limit 5.09 0 (0.00%)
  out-of-window (a real return, but not floor): 0   other invalid: 0
  bins accepted: 320/320 (need 288; 270 valid frames per bin)
  median offset -22.65 mm   per-bin MAD median/p95/max 0.00/1.00/1.00 mm
  ~ median tare across accepted bins is -22.6 mm; a uniform shift that large is a geometry PARAMETER error rather than sensor bias -- emitter_height_above_floor_mm is probably wrong
  sensor_1: SAVED /home/shehab/stretch_user/stretch-se4-4024/calibration_line_sensors/tare/sensor_1_tare.yaml

=== sensor_2 ===
  frames: 300 distinct of 300 requested in 9.93s (30.22/s); 3862 duplicate polls skipped
  samples: valid 96000 (100.00%)  no-return 5.11 0 (0.00%)  beyond-limit 5.09 0 (0.00%)
  out-of-window (a real return, but not floor): 0   other invalid: 0
  bins accepted: 320/320 (need 288; 270 valid frames per bin)
  median offset -23.65 mm   per-bin MAD median/p95/max 0.25/1.00/1.00 mm
  ~ median tare across accepted bins is -23.6 mm; a uniform shift that large is a geometry PARAMETER error rather than sensor bias -- emitter_height_above_floor_mm is probably wrong
  sensor_2: SAVED /home/shehab/stretch_user/stretch-se4-4024/calibration_line_sensors/tare/sensor_2_tare.yaml

=== sensor_3 ===
  frames: 300 distinct of 300 requested in 9.93s (30.22/s); 3862 duplicate polls skipped
  samples: valid 96000 (100.00%)  no-return 5.11 0 (0.00%)  beyond-limit 5.09 0 (0.00%)
  out-of-window (a real return, but not floor): 0   other invalid: 0
  bins accepted: 320/320 (need 288; 270 valid frames per bin)
  median offset -32.65 mm   per-bin MAD median/p95/max 0.00/1.00/1.00 mm
  ~ median tare across accepted bins is -32.6 mm; a uniform shift that large is a geometry PARAMETER error rather than sensor bias -- emitter_height_above_floor_mm is probably wrong
  sensor_3: SAVED /home/shehab/stretch_user/stretch-se4-4024/calibration_line_sensors/tare/sensor_3_tare.yaml

=== sensor_4 ===
  frames: 300 distinct of 300 requested in 9.93s (30.22/s); 3862 duplicate polls skipped
  samples: valid 96000 (100.00%)  no-return 5.11 0 (0.00%)  beyond-limit 5.09 0 (0.00%)
  out-of-window (a real return, but not floor): 0   other invalid: 0
  bins accepted: 320/320 (need 288; 270 valid frames per bin)
  median offset -31.65 mm   per-bin MAD median/p95/max 0.00/1.00/1.00 mm
  ~ median tare across accepted bins is -31.6 mm; a uniform shift that large is a geometry PARAMETER error rather than sensor bias -- emitter_height_above_floor_mm is probably wrong
  sensor_4: SAVED /home/shehab/stretch_user/stretch-se4-4024/calibration_line_sensors/tare/sensor_4_tare.yaml

=== sensor_5 ===
  frames: 300 distinct of 300 requested in 9.93s (30.22/s); 3862 duplicate polls skipped
  samples: valid 96000 (100.00%)  no-return 5.11 0 (0.00%)  beyond-limit 5.09 0 (0.00%)
  out-of-window (a real return, but not floor): 0   other invalid: 0
  bins accepted: 320/320 (need 288; 270 valid frames per bin)
  median offset -33.65 mm   per-bin MAD median/p95/max 0.00/1.00/1.00 mm
  ~ median tare across accepted bins is -33.6 mm; a uniform shift that large is a geometry PARAMETER error rather than sensor bias -- emitter_height_above_floor_mm is probably wrong
  sensor_5: SAVED /home/shehab/stretch_user/stretch-se4-4024/calibration_line_sensors/tare/sensor_5_tare.yaml

report: /home/shehab/stretch_user/stretch-se4-4024/calibration_line_sensors/sessions/20260814193750/calibration_report.yaml
[08/14/2026 19:38:01] [line_sensor_loop] [INFO]: Line_sensor_loop EXIT!
[08/14/2026 19:38:01] [line_sensor_loop] [INFO]: Exiting Line_sensor_loop Loop
shehab@stretch-se4-4024:~$ ls ~/stretch_user/stretch-se4-XXXX/calibration_line_sensors/tare/
cat ~/stretch_user/stretch-se4-XXXX/calibration_line_sensors/tare/sensor_0_tare.yaml
ls ~/stretch_user/stretch-se4-XXXX/calibration_line_sensors/sessions/
ls: cannot access '/home/shehab/stretch_user/stretch-se4-XXXX/calibration_line_sensors/tare/': No such file or directory
cat: /home/shehab/stretch_user/stretch-se4-XXXX/calibration_line_sensors/tare/sensor_0_tare.yaml: No such file or directory
ls: cannot access '/home/shehab/stretch_user/stretch-se4-XXXX/calibration_line_sensors/sessions/': No such file or directory
shehab@stretch-se4-4024:~$ ls ~/stretch_user/stretch-se4-4024/calibration_line_sensors/tare/
sensor_0_tare.yaml  sensor_1_tare.yaml  sensor_2_tare.yaml  sensor_3_tare.yaml  sensor_4_tare.yaml  sensor_5_tare.yaml
shehab@stretch-se4-4024:~$ cat ~/stretch_user/stretch-se4-4024/calibration_line_sensors/tare/sensor_0_tare.yaml
format_version: 2
sensor_name: sensor_0
sensor_index: 0
timestamp: '2026-08-14T19:38:00.906278'
session_id: '20260814193750'
stretch_body_version: ''
flip_range_ordering: true
n_bins: 320
n_frames: 300
ideal_range_m: 0.2296455885323982
ideal_range_per_bin: null
ideal_range_model: axial_depth_constant_v1
tare_offsets:
- -0.021645588532398202
- -0.0206455885323982
- -0.0206455885323982
- -0.0206455885323982
- -0.0196455885323982
- -0.0196455885323982
- -0.0196455885323982
- -0.0196455885323982
- -0.0196455885323982
- -0.021645588532398202
- -0.023645588532398204
- -0.025645588532398206
- -0.02664558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.025645588532398206
- -0.023645588532398204
- -0.022645588532398203
- -0.022645588532398203
- -0.022645588532398203
- -0.023645588532398204
- -0.024645588532398205
- -0.024645588532398205
- -0.024645588532398205
- -0.024645588532398205
- -0.024645588532398205
- -0.024645588532398205
- -0.023645588532398204
- -0.023645588532398204
- -0.023645588532398204
- -0.022645588532398203
- -0.022645588532398203
- -0.022645588532398203
- -0.022645588532398203
- -0.022645588532398203
- -0.023645588532398204
- -0.023645588532398204
- -0.023645588532398204
- -0.022645588532398203
- -0.022645588532398203
- -0.021645588532398202
- -0.022645588532398203
- -0.023645588532398204
- -0.023645588532398204
- -0.024645588532398205
- -0.023645588532398204
- -0.023645588532398204
- -0.023645588532398204
- -0.023645588532398204
- -0.024645588532398205
- -0.025645588532398206
- -0.02664558853239818
- -0.02664558853239818
- -0.02764558853239818
- -0.02764558853239818
- -0.02764558853239818
- -0.02764558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.02764558853239818
- -0.02764558853239818
- -0.02864558853239818
- -0.02864558853239818
- -0.02864558853239818
- -0.02864558853239818
- -0.02764558853239818
- -0.02764558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.025645588532398206
- -0.025645588532398206
- -0.025645588532398206
- -0.025645588532398206
- -0.025645588532398206
- -0.025645588532398206
- -0.025645588532398206
- -0.025645588532398206
- -0.025645588532398206
- -0.025645588532398206
- -0.025645588532398206
- -0.025645588532398206
- -0.025645588532398206
- -0.025645588532398206
- -0.025645588532398206
- -0.02664558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.02664558853239818
- -0.02764558853239818
- -0.02864558853239818
- -0.02964558853239818
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.030645588532398182
- -0.03164558853239818
- -0.032645588532398184
- -0.032645588532398184
- -0.032645588532398184
- -0.032645588532398184
- -0.03164558853239818
- -0.03164558853239818
- -0.03164558853239818
- -0.03164558853239818
- -0.03164558853239818
- -0.03164558853239818
- -0.03164558853239818
- -0.032645588532398184
- -0.032645588532398184
- -0.032645588532398184
- -0.032645588532398184
- -0.032645588532398184
- -0.032645588532398184
- -0.032645588532398184
- -0.033645588532398185
- -0.033645588532398185
- -0.033645588532398185
- -0.033645588532398185
- -0.033645588532398185
- -0.033645588532398185
- -0.033645588532398185
- -0.033645588532398185
- -0.033645588532398185
- -0.032645588532398184
- -0.032645588532398184
- -0.032645588532398184
- -0.032645588532398184
- -0.032645588532398184
- -0.032645588532398184
- -0.032645588532398184
- -0.032645588532398184
- -0.032645588532398184
- -0.032645588532398184
- -0.033645588532398185
- -0.033645588532398185
- -0.034645588532398186
- -0.034645588532398186
- -0.034645588532398186
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.034645588532398186
- -0.034645588532398186
- -0.034645588532398186
- -0.034645588532398186
- -0.034645588532398186
- -0.03564558853239819
- -0.03564558853239819
- -0.03564558853239819
- -0.03664558853239819
- -0.03664558853239819
- -0.03664558853239819
- -0.03764558853239819
- -0.03764558853239819
- -0.03764558853239819
- -0.03764558853239819
- -0.03764558853239819
- -0.03864558853239819
- -0.03864558853239819
- -0.03864558853239819
- -0.03864558853239819
- -0.03864558853239819
- -0.03864558853239819
- -0.03964558853239819
- -0.03964558853239819
- -0.04064558853239819
- -0.04064558853239819
- -0.04064558853239819
- -0.04164558853239819
- -0.04164558853239819
- -0.04164558853239819
- -0.04164558853239819
- -0.04264558853239819
- -0.04264558853239819
- -0.04264558853239819
- -0.043645588532398194
- -0.043645588532398194
- -0.043645588532398194
- -0.043645588532398194
- -0.043645588532398194
- -0.043645588532398194
- -0.043645588532398194
- -0.043645588532398194
- -0.043645588532398194
- -0.043645588532398194
- -0.044645588532398195
- -0.044645588532398195
- -0.045645588532398196
- -0.0466455885323982
- -0.0466455885323982
- -0.0466455885323982
- -0.0466455885323982
- -0.0466455885323982
- -0.0466455885323982
- -0.0466455885323982
- -0.045645588532398196
- -0.045645588532398196
- -0.044645588532398195
- -0.044645588532398195
- -0.043645588532398194
- -0.043645588532398194
- -0.043645588532398194
- -0.043645588532398194
- -0.043645588532398194
- -0.043645588532398194
- -0.043645588532398194
- -0.044645588532398195
tare_valid_mask:
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
null_rate_per_bin:
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
calibration_thresholds:
  min_range_m: 0.03
  max_range_m: 0.4
  min_valid_fraction: 0.9
  max_abs_tare_m: 0.1
  max_bin_mad_m: 0.005
  min_accepted_bin_fraction: 0.9
  min_frames: 100
  warn_median_offset_m: 0.01
calibration_summary:
  frames_used: 300
  bins_per_frame: 320
  total_bin_samples: 96000
  valid_samples: 96000
  no_return_samples: 0
  beyond_limit_samples: 0
  out_of_window_samples: 0
  other_invalid_samples: 0
  no_return_pct: 0.0
  beyond_limit_pct: 0.0
  bins_returned_at_least_once: 320
  bins_accepted_for_tare: 320
  bins_rejected_for_tare: 0
  required_accepted_bins: 288
  required_valid_frames_per_bin: 270
  run_sufficient: true
  median_accepted_offset_m: -0.030646
  bin_mad_m_median: 0.0
  bin_mad_m_p95: 0.001
  bin_mad_m_max: 0.001
  ideal_range_model: axial_depth_constant_v1
shehab@stretch-se4-4024:~$ ls ~/stretch_user/stretch-se4-4024/calibration_line_sensors/sessions/
20260814193750

@hello-robot-shehab hello-robot-shehab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image
$ stretch_line_sensor_hz_check
body server is not serving line_sensor_loop -- opening /dev/hello-pixart-j3 directly
[08/14/2026 19:40:42] [line_sensor_loop] [INFO]: Starting LineSensorLoop...
[08/14/2026 19:40:42] [line_sensor_loop] [INFO]: -------- Starting Line_sensor_loop with PID 17133 --------
[08/14/2026 19:40:43] [line_sensor_loop] [INFO]: Line sensor calibration: 6/6 sensors loaded
reading /dev/hello-pixart-j3 directly (no body server on the sensors)
settling ...
  settled after 1.5s

measuring 6 sensors for 30s ...
[08/14/2026 19:41:14] [line_sensor_loop] [INFO]: Line_sensor_loop EXIT!
[08/14/2026 19:41:14] [line_sensor_loop] [INFO]: Exiting Line_sensor_loop Loop

sensor     fresh Hz board Hz new frames  skips max gap backwards
sensor_0      30.10    30.10        903      0       1         0
sensor_1      30.13    30.13        904      0       1         0
sensor_2      30.10    30.10        903      0       1         0
sensor_3      30.10    30.10        903      0       1         0
sensor_4      30.10    30.10        903      0       1         0
sensor_5      30.13    30.13        904      0       1         0

server-reported rate_hz: 27.2   decode_errors: 0

PASS: every sensor is streaming new (never repeated, never backwards) frames at >= 29Hz
Image

@hello-robot-shehab hello-robot-shehab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on 4024, calibration works and line sensors seem to work well from driving around.

rs["timestamp"] = time.time()

# Filter out raw line sensor arrays
if 'line_sensor_loop' in rs and isinstance(rs['line_sensor_loop'], dict):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be just del rs['line_sensor_loop'] instead of this forloop?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants