@@ -352,57 +352,78 @@ bool HeightScanInput::read(OnnxRuntime& runtime, RobotStateInterface& state, Com
352352 LOG_STREAM (ERROR, fmt::format (" Failed to get input buffer {}.{}" , key_, layer_name));
353353 return false ;
354354 }
355- copyToBuffer (maybe_scan.value ()->layers .at (layer_name), maybe_buffer.value ());
355+ copyToBuffer (maybe_scan.value ()->float_layers .at (layer_name), maybe_buffer.value ());
356356 }
357357 return true ;
358358}
359359
360- // Implementation of RangeImageInput methods
361- RangeImageInput::RangeImageInput (const std::string& key,
362- const metadata::RangeImageMetadata& metadata)
363- : key_(key), metadata_(metadata) {}
360+ // Implementation of SphericalImageInput methods
361+ SphericalImageInput::SphericalImageInput (const std::string& key, const std::string& sensor_name,
362+ const std::unordered_set<std::string>& channel_names,
363+ const metadata::SphericalImageMetadata& metadata)
364+ : key_(key), sensor_name_(sensor_name), channel_names_(channel_names), metadata_(metadata) {}
364365
365- bool RangeImageInput ::init (RobotStateInterface& state, CommandInterface&) {
366+ bool SphericalImageInput ::init (RobotStateInterface& state, CommandInterface&) {
366367 SphericalImageConfig config;
367368 config.v_res = static_cast <int >(metadata_.v_res );
368369 config.h_res = static_cast <int >(metadata_.h_res );
369370 config.v_fov_min_deg = metadata_.v_fov_min_deg ;
370371 config.v_fov_max_deg = metadata_.v_fov_max_deg ;
371372 config.unobserved_value = metadata_.unobserved_value ;
372- return state.initRangeImage (config);
373+ config.channel_names = channel_names_;
374+ return state.initSphericalImage (sensor_name_, config);
373375}
374376
375- bool RangeImageInput::read (OnnxRuntime& runtime, RobotStateInterface& state, CommandInterface&) {
376- auto maybe_buffer = runtime.inputBuffer <float >(key_);
377- if (!maybe_buffer.has_value ()) return false ;
378- auto maybe_image = state.rangeImage ();
379- if (!maybe_image.has_value ()) return false ;
380- copyToBuffer (maybe_image.value (), maybe_buffer.value ());
377+ bool SphericalImageInput::read (OnnxRuntime& runtime, RobotStateInterface& state,
378+ CommandInterface&) {
379+ auto maybe_image = state.sphericalImage (sensor_name_, channel_names_);
380+ if (!maybe_image.has_value ()) {
381+ LOG_STREAM (ERROR, " Failed to get spherical image data for SphericalImageInput" );
382+ return false ;
383+ }
384+ for (const auto & channel_name : channel_names_) {
385+ auto maybe_buffer = runtime.inputBuffer <float >(fmt::format (" {}.{}" , key_, channel_name));
386+ if (!maybe_buffer.has_value ()) {
387+ LOG_STREAM (ERROR, fmt::format (" Failed to get input buffer {}.{}" , key_, channel_name));
388+ return false ;
389+ }
390+ copyToBuffer (maybe_image.value ()->float_channels .at (channel_name), maybe_buffer.value ());
391+ }
381392 return true ;
382393}
383394
384- // Implementation of DepthImageInput methods
385- DepthImageInput::DepthImageInput (const std::string& key,
386- const metadata::DepthImageMetadata& metadata)
387- : key_(key), metadata_(metadata) {}
395+ // Implementation of PinholeImageInput methods
396+ PinholeImageInput::PinholeImageInput (const std::string& key, const std::string& sensor_name,
397+ const std::unordered_set<std::string>& channel_names,
398+ const metadata::PinholeImageMetadata& metadata)
399+ : key_(key), sensor_name_(sensor_name), channel_names_(channel_names), metadata_(metadata) {}
388400
389- bool DepthImageInput ::init (RobotStateInterface& state, CommandInterface&) {
401+ bool PinholeImageInput ::init (RobotStateInterface& state, CommandInterface&) {
390402 PinholeImageConfig config;
391403 config.width = metadata_.width ;
392404 config.height = metadata_.height ;
393405 config.fx = metadata_.fx ;
394406 config.fy = metadata_.fy ;
395407 config.cx = metadata_.cx ;
396408 config.cy = metadata_.cy ;
397- return state.initDepthImage (config);
409+ config.channel_names = channel_names_;
410+ return state.initPinholeImage (sensor_name_, config);
398411}
399412
400- bool DepthImageInput::read (OnnxRuntime& runtime, RobotStateInterface& state, CommandInterface&) {
401- auto maybe_buffer = runtime.inputBuffer <float >(key_);
402- if (!maybe_buffer.has_value ()) return false ;
403- auto maybe_image = state.depthImage ();
404- if (!maybe_image.has_value ()) return false ;
405- copyToBuffer (maybe_image.value (), maybe_buffer.value ());
413+ bool PinholeImageInput::read (OnnxRuntime& runtime, RobotStateInterface& state, CommandInterface&) {
414+ auto maybe_image = state.pinholeImage (sensor_name_, channel_names_);
415+ if (!maybe_image.has_value ()) {
416+ LOG_STREAM (ERROR, " Failed to get pinhole image data for PinholeImageInput" );
417+ return false ;
418+ }
419+ for (const auto & channel_name : channel_names_) {
420+ auto maybe_buffer = runtime.inputBuffer <float >(fmt::format (" {}.{}" , key_, channel_name));
421+ if (!maybe_buffer.has_value ()) {
422+ LOG_STREAM (ERROR, fmt::format (" Failed to get input buffer {}.{}" , key_, channel_name));
423+ return false ;
424+ }
425+ copyToBuffer (maybe_image.value ()->float_channels .at (channel_name), maybe_buffer.value ());
426+ }
406427 return true ;
407428}
408429
0 commit comments