Skip to content

Commit

Permalink
change api of log_depth_image
Browse files Browse the repository at this point in the history
  • Loading branch information
makeecat committed Nov 6, 2024
1 parent 72570df commit 07dd003
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
23 changes: 8 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2587,27 +2587,20 @@ pub fn log_mesh(
/// log depth image data to the rerun recording stream
/// # Arguments
/// * `rec` - The rerun::RecordingStream instance
/// * `depth_image` - The depth image data
/// * `resolution` - The width and height of the depth image
/// * `min_depth` - The minimum depth value
/// * `max_depth` - The maximum depth value
/// * `cam` - The Camera instance
/// # Errors
/// * If the data cannot be logged to the recording stream
/// # Example
/// ```no_run
/// use peng_quad::log_depth_image;
/// use peng_quad::{log_depth_image, Camera};
/// let rec = rerun::RecordingStreamBuilder::new("log.rerun").connect().unwrap();
/// let depth_image = vec![0.0; 640 * 480];
/// log_depth_image(&rec, &depth_image, (640usize, 480usize), 0.0, 1.0).unwrap();
/// let camera = Camera::new((640, 480), 0.1, 100.0, 60.0);
/// log_depth_image(&rec, &camera).unwrap();
/// ```
pub fn log_depth_image(
rec: &rerun::RecordingStream,
depth_image: &[f32],
resolution: (usize, usize),
min_depth: f32,
max_depth: f32,
) -> Result<(), SimulationError> {
let (width, height) = resolution;
pub fn log_depth_image(rec: &rerun::RecordingStream, cam: &Camera) -> Result<(), SimulationError> {
let (width, height) = (cam.resolution.0, cam.resolution.1);
let (min_depth, max_depth) = (cam.near, cam.far);
let depth_image = &cam.depth_buffer;
let mut image = rerun::external::ndarray::Array::zeros((height, width, 3));
let depth_range = max_depth - min_depth;
image
Expand Down
14 changes: 4 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn main() -> Result<(), SimulationError> {
}
imu.update(quad.time_step)?;
let (true_accel, true_gyro) = quad.read_imu()?;
let (_measured_accel, _measured_gyro) = imu.read(true_accel, true_gyro)?;
let (measured_accel, measured_gyro) = imu.read(true_accel, true_gyro)?;
if i % (config.simulation.simulation_frequency / config.simulation.log_frequency) == 0 {
if config.render_depth {
camera.render_depth(
Expand All @@ -163,17 +163,11 @@ fn main() -> Result<(), SimulationError> {
&quad,
&desired_position,
&desired_velocity,
&_measured_accel,
&_measured_gyro,
&measured_accel,
&measured_gyro,
)?;
if config.render_depth {
log_depth_image(
rec,
&camera.depth_buffer,
camera.resolution,
camera.near,
camera.far,
)?;
log_depth_image(rec, &camera)?;
log_pinhole_depth(
rec,
&camera,
Expand Down

0 comments on commit 07dd003

Please sign in to comment.