// Entity model verification example — warehouse patrol robot
//
//   spanda entity verify rover-001 --config crates/spanda-config/tests/fixtures/warehouse/spanda.toml
//   spanda entity verify rover-001 --program examples/entity/entity_verify.sd --config .../spanda.toml

import trust.jetson;

hardware RoverV1 {
  sensors [ GPS, Lidar ];
  actuators [ DifferentialDrive ];
  connectivity [ WiFi ];
}

robot Rover {
  uses hardware RoverV1;
  sensor gps: GPS;
  sensor lidar: Lidar;
  actuator wheels: DifferentialDrive;

  exposes capabilities [ gps_navigation, obstacle_avoidance ];

  mission Patrol {
    requires capabilities [ gps_navigation, obstacle_avoidance ];
    patrol;
  }

  safety {
    max_speed = 0.5 m/s;
    stop_if lidar.nearest_distance < 0.5 m;
  }

  behavior patrol() {
    loop every 500ms {
      let scan = lidar.read();
      if scan.nearest_distance < 0.5 m {
        wheels.drive(linear: 0.0 m/s, angular: 0.0 rad/s);
      } else {
        wheels.drive(linear: 0.3 m/s, angular: 0.0 rad/s);
      }
    }
  }
}

fleet Warehouse {
  Rover;
}

deploy Rover to RoverV1;
