├── .gitignore ├── CMakeLists.txt ├── HAL ├── CMakeLists.txt ├── Camera │ ├── AutoExposureInterface.h │ ├── CMakeLists.txt │ ├── CameraDevice.h │ ├── CameraDriverInterface.h │ └── Drivers │ │ ├── AlliedVision │ │ ├── AlliedVisionDriver.cpp │ │ ├── AlliedVisionDriver.h │ │ ├── CMakeLists.txt │ │ └── FindPVAPI.cmake │ │ ├── Android │ │ ├── AndroidDriver.cpp │ │ ├── AndroidDriver.h │ │ ├── AndroidFactory.cpp │ │ ├── CMakeLists.txt │ │ ├── CameraListener.cpp │ │ ├── CameraListener.h │ │ └── FindAndroidKernel.cmake │ │ ├── AutoExposure │ │ ├── AutoExposureDriver.cpp │ │ ├── AutoExposureDriver.h │ │ ├── AutoExposureFactory.cpp │ │ └── CMakeLists.txt │ │ ├── CMakeLists.txt │ │ ├── Cleave │ │ ├── CMakeLists.txt │ │ ├── CleaveDriver.cpp │ │ ├── CleaveDriver.h │ │ ├── CleaveFactory.cpp │ │ └── README │ │ ├── Convert │ │ ├── CMakeLists.txt │ │ ├── ConvertDriver.cpp │ │ ├── ConvertDriver.h │ │ └── ConvertFactory.cpp │ │ ├── DC1394 │ │ ├── CMakeLists.txt │ │ ├── DC1394Driver.cpp │ │ ├── DC1394Driver.h │ │ ├── DC1394Factory.cpp │ │ └── FindDC1394_2.cmake │ │ ├── Debayer │ │ ├── CMakeLists.txt │ │ ├── DebayerDriver.cpp │ │ ├── DebayerDriver.h │ │ ├── DebayerFactory.cpp │ │ └── FindDC1394_2.cmake │ │ ├── Deinterlace │ │ ├── CMakeLists.txt │ │ ├── DeinterlaceDriver.cpp │ │ ├── DeinterlaceDriver.h │ │ ├── DeinterlaceFactory.cpp │ │ └── FindDC1394_2.cmake │ │ ├── Epiphan │ │ ├── CMakeLists.txt │ │ ├── EpiphanDriver.cpp │ │ ├── EpiphanDriver.h │ │ ├── EpiphanFactory.cpp │ │ └── SDK │ │ │ ├── includes │ │ │ ├── frmgrab.h │ │ │ ├── s_base32.h │ │ │ ├── s_base64.h │ │ │ ├── s_bitset.h │ │ │ ├── s_buf.h │ │ │ ├── s_cs.h │ │ │ ├── s_def.h │ │ │ ├── s_dom.h │ │ │ ├── s_event.h │ │ │ ├── s_file.h │ │ │ ├── s_fio.h │ │ │ ├── s_futil.h │ │ │ ├── s_hash.h │ │ │ ├── s_hist.h │ │ │ ├── s_iop.h │ │ │ ├── s_itr.h │ │ │ ├── s_itrp.h │ │ │ ├── s_lib.h │ │ │ ├── s_libp.h │ │ │ ├── s_lock.h │ │ │ ├── s_lockp.h │ │ │ ├── s_math.h │ │ │ ├── s_md.h │ │ │ ├── s_mdp.h │ │ │ ├── s_mem.h │ │ │ ├── s_mutex.h │ │ │ ├── s_ntk.h │ │ │ ├── s_opt.h │ │ │ ├── s_os.h │ │ │ ├── s_prop.h │ │ │ ├── s_queue.h │ │ │ ├── s_random.h │ │ │ ├── s_ring.h │ │ │ ├── s_rwlock.h │ │ │ ├── s_stack.h │ │ │ ├── s_strbuf.h │ │ │ ├── s_thread.h │ │ │ ├── s_thrp.h │ │ │ ├── s_unix.h │ │ │ ├── s_util.h │ │ │ ├── s_vector.h │ │ │ ├── s_ver.h │ │ │ ├── s_win32.h │ │ │ ├── s_wkq.h │ │ │ ├── s_xml.h │ │ │ ├── s_xmlp.h │ │ │ ├── v2u_compression.h │ │ │ ├── v2u_defs.h │ │ │ ├── v2u_dshow.h │ │ │ ├── v2u_id.h │ │ │ ├── v2u_ioctl.h │ │ │ ├── v2u_lib.h │ │ │ ├── v2u_save.h │ │ │ ├── v2u_sys.h │ │ │ ├── v2u_util.h │ │ │ └── v2u_version.h │ │ │ ├── libfrmgrab │ │ │ ├── linux │ │ │ │ ├── i386 │ │ │ │ │ └── libfrmgrab.a │ │ │ │ └── x86_64 │ │ │ │ │ └── libfrmgrab.a │ │ │ ├── macosx │ │ │ │ └── libfrmgrab.a │ │ │ └── win │ │ │ │ ├── Win32 │ │ │ │ └── frmgrab.lib │ │ │ │ └── x64 │ │ │ │ └── frmgrab.lib │ │ │ ├── slib │ │ │ ├── COPYRIGHT │ │ │ ├── include │ │ │ │ ├── s_base32.h │ │ │ │ ├── s_base64.h │ │ │ │ ├── s_bitset.h │ │ │ │ ├── s_buf.h │ │ │ │ ├── s_cs.h │ │ │ │ ├── s_def.h │ │ │ │ ├── s_dom.h │ │ │ │ ├── s_event.h │ │ │ │ ├── s_file.h │ │ │ │ ├── s_fio.h │ │ │ │ ├── s_futil.h │ │ │ │ ├── s_hash.h │ │ │ │ ├── s_hist.h │ │ │ │ ├── s_iop.h │ │ │ │ ├── s_itr.h │ │ │ │ ├── s_itrp.h │ │ │ │ ├── s_lib.h │ │ │ │ ├── s_libp.h │ │ │ │ ├── s_lock.h │ │ │ │ ├── s_lockp.h │ │ │ │ ├── s_math.h │ │ │ │ ├── s_md.h │ │ │ │ ├── s_mdp.h │ │ │ │ ├── s_mem.h │ │ │ │ ├── s_mutex.h │ │ │ │ ├── s_ntk.h │ │ │ │ ├── s_opt.h │ │ │ │ ├── s_os.h │ │ │ │ ├── s_prop.h │ │ │ │ ├── s_queue.h │ │ │ │ ├── s_random.h │ │ │ │ ├── s_ring.h │ │ │ │ ├── s_rwlock.h │ │ │ │ ├── s_stack.h │ │ │ │ ├── s_strbuf.h │ │ │ │ ├── s_thread.h │ │ │ │ ├── s_thrp.h │ │ │ │ ├── s_unix.h │ │ │ │ ├── s_util.h │ │ │ │ ├── s_vector.h │ │ │ │ ├── s_ver.h │ │ │ │ ├── s_win32.h │ │ │ │ ├── s_wkq.h │ │ │ │ ├── s_xml.h │ │ │ │ └── s_xmlp.h │ │ │ └── src │ │ │ │ ├── ntk │ │ │ │ ├── k_event.c │ │ │ │ ├── k_fio.c │ │ │ │ ├── k_mutex.c │ │ │ │ ├── k_thread.c │ │ │ │ ├── k_trace.c │ │ │ │ └── k_util.c │ │ │ │ ├── s_base32.c │ │ │ │ ├── s_base64.c │ │ │ │ ├── s_bitset.c │ │ │ │ ├── s_buf.c │ │ │ │ ├── s_cs.c │ │ │ │ ├── s_dom.c │ │ │ │ ├── s_event.c │ │ │ │ ├── s_file.c │ │ │ │ ├── s_fio.c │ │ │ │ ├── s_fmem.c │ │ │ │ ├── s_fnull.c │ │ │ │ ├── s_fsock.c │ │ │ │ ├── s_fsplit.c │ │ │ │ ├── s_fsub.c │ │ │ │ ├── s_futil.c │ │ │ │ ├── s_fwrap.c │ │ │ │ ├── s_fzio.c │ │ │ │ ├── s_fzip.c │ │ │ │ ├── s_hash.c │ │ │ │ ├── s_hist.c │ │ │ │ ├── s_init.c │ │ │ │ ├── s_itr.c │ │ │ │ ├── s_itra.c │ │ │ │ ├── s_itrc.c │ │ │ │ ├── s_itrf.c │ │ │ │ ├── s_itrs.c │ │ │ │ ├── s_lib.c │ │ │ │ ├── s_lock.c │ │ │ │ ├── s_math.c │ │ │ │ ├── s_md.c │ │ │ │ ├── s_md5.c │ │ │ │ ├── s_mem.c │ │ │ │ ├── s_mpm.c │ │ │ │ ├── s_mutex.c │ │ │ │ ├── s_net.c │ │ │ │ ├── s_opt.c │ │ │ │ ├── s_parse.c │ │ │ │ ├── s_prop.c │ │ │ │ ├── s_propx.c │ │ │ │ ├── s_queue.c │ │ │ │ ├── s_random.c │ │ │ │ ├── s_ring.c │ │ │ │ ├── s_rwlock.c │ │ │ │ ├── s_sha1.c │ │ │ │ ├── s_stack.c │ │ │ │ ├── s_str.c │ │ │ │ ├── s_strbuf.c │ │ │ │ ├── s_thread.c │ │ │ │ ├── s_time.c │ │ │ │ ├── s_trace.c │ │ │ │ ├── s_utf8.c │ │ │ │ ├── s_util.c │ │ │ │ ├── s_vector.c │ │ │ │ ├── s_wkq.c │ │ │ │ ├── s_xml.c │ │ │ │ ├── s_xmlp.c │ │ │ │ ├── unix │ │ │ │ ├── u_event.c │ │ │ │ ├── u_furl.c │ │ │ │ ├── u_futil.c │ │ │ │ ├── u_mutex.c │ │ │ │ ├── u_thread.c │ │ │ │ └── u_trace.c │ │ │ │ └── win32 │ │ │ │ ├── w_event.c │ │ │ │ ├── w_furl.c │ │ │ │ ├── w_futil.c │ │ │ │ ├── w_mutex.c │ │ │ │ ├── w_thread.c │ │ │ │ └── w_trace.c │ │ │ └── v2u_lib │ │ │ ├── includes │ │ │ ├── v2u_lib.h │ │ │ ├── v2u_save.h │ │ │ ├── v2u_sys.h │ │ │ └── v2u_util.h │ │ │ └── src │ │ │ ├── v2u_bmp.c │ │ │ ├── v2u_jpeg.c │ │ │ ├── v2u_pal.c │ │ │ ├── v2u_png.c │ │ │ ├── v2u_sys.c │ │ │ └── v2u_util.c │ │ ├── FileReader │ │ ├── CMakeLists.txt │ │ ├── FileReaderDriver.cpp │ │ ├── FileReaderDriver.h │ │ ├── FileReaderFactory.cpp │ │ ├── ReadImage.cpp │ │ └── ReadImage.h │ │ ├── FireFly │ │ ├── CMakeLists.txt │ │ ├── FindDC1394_2.cmake │ │ ├── FireFlyDriver.cpp │ │ └── FireFlyDriver.h │ │ ├── Flycap │ │ ├── CMakeLists.txt │ │ ├── FindFLYCAP.cmake │ │ ├── FlycapDriver.cpp │ │ ├── FlycapDriver.h │ │ └── FlycapFactory.cpp │ │ ├── Freenect2 │ │ ├── CMakeLists.txt │ │ ├── Freenect2Driver.cpp │ │ ├── Freenect2Driver.h │ │ ├── Freenect2Factory.cpp │ │ ├── README │ │ ├── depth_registration.cpp │ │ ├── depth_registration.h │ │ ├── depth_registration_cpu.cpp │ │ ├── depth_registration_cpu.h │ │ ├── depth_registration_opencl.cpp │ │ └── depth_registration_opencl.h │ │ ├── HDMI │ │ ├── Blackmagic │ │ │ ├── DeckLinkAPI.h │ │ │ ├── DeckLinkAPIConfiguration.h │ │ │ ├── DeckLinkAPIDeckControl.h │ │ │ ├── DeckLinkAPIDiscovery.h │ │ │ ├── DeckLinkAPIDispatch.cpp │ │ │ ├── DeckLinkAPIDispatch_v7_6.cpp │ │ │ ├── DeckLinkAPIDispatch_v8_0.cpp │ │ │ ├── DeckLinkAPIModes.h │ │ │ ├── DeckLinkAPITypes.h │ │ │ ├── DeckLinkAPIVersion.h │ │ │ ├── DeckLinkAPI_v7_1.h │ │ │ ├── DeckLinkAPI_v7_3.h │ │ │ ├── DeckLinkAPI_v7_6.h │ │ │ ├── DeckLinkAPI_v7_9.h │ │ │ ├── DeckLinkAPI_v8_0.h │ │ │ ├── DeckLinkAPI_v8_1.h │ │ │ └── LinuxCOM.h │ │ ├── CMakeLists.txt │ │ ├── CaptureDelegate.cpp │ │ ├── CaptureDelegate.h │ │ ├── HDMIDriver.cpp │ │ └── HDMIDriver.h │ │ ├── Join │ │ ├── CMakeLists.txt │ │ ├── JoinCameraDriver.cpp │ │ ├── JoinCameraDriver.h │ │ ├── JoinCameraFactory.cpp │ │ └── README │ │ ├── KitKat │ │ ├── CMakeLists.txt │ │ ├── Camera.cpp │ │ ├── Camera.h │ │ ├── FindAndroidKernel.cmake │ │ ├── Image.h │ │ ├── KitKatDriver.cpp │ │ ├── KitKatDriver.h │ │ └── KitKatFactory.cpp │ │ ├── NodeCam │ │ ├── CMakeLists.txt │ │ ├── NodeCamDriver.cpp │ │ ├── NodeCamDriver.h │ │ ├── NodeCamFactory.cpp │ │ └── README.md │ │ ├── NodeSimCam │ │ ├── CMakeLists.txt │ │ ├── FindZeroMQ.cmake │ │ ├── LibFindMacros.cmake │ │ ├── NodeSimCamDriver.cpp │ │ ├── NodeSimCamDriver.h │ │ ├── NodeSimCamFactory.cpp │ │ └── readme.txt │ │ ├── Occam │ │ ├── CMakeLists.txt │ │ ├── FindOccamIndigo.cmake │ │ ├── OccamDriver.cpp │ │ ├── OccamDriver.h │ │ ├── OccamFactory.cpp │ │ └── README │ │ ├── OpenCV │ │ ├── CMakeLists.txt │ │ ├── OpenCVDriver.cpp │ │ ├── OpenCVDriver.h │ │ ├── OpenCVFactory.cpp │ │ └── README │ │ ├── OpenNI │ │ ├── CMakeLists.txt │ │ ├── FindOpenNI.cmake │ │ ├── OpenNIDriver.cpp │ │ ├── OpenNIDriver.h │ │ ├── OpenNIFactory.cpp │ │ ├── README │ │ ├── SE3.h │ │ └── imageintrincs.h │ │ ├── OpenNI2 │ │ ├── CMakeLists.txt │ │ ├── FindOpenNI2.cmake │ │ ├── OniSampleUtilities.h │ │ ├── OpenNI2Driver.cpp │ │ ├── OpenNI2Driver.h │ │ ├── OpenNI2Factory.cpp │ │ ├── README │ │ ├── SE3.h │ │ └── imageintrincs.h │ │ ├── PhotoCalib │ │ ├── CMakeLists.txt │ │ ├── PhotoCalibDriver.cpp │ │ ├── PhotoCalibDriver.h │ │ └── PhotoCalibFactory.cpp │ │ ├── ProtoReader │ │ ├── CMakeLists.txt │ │ ├── ProtoReaderDriver.cpp │ │ ├── ProtoReaderDriver.h │ │ └── ProtoReaderFactory.cpp │ │ ├── ROS │ │ ├── CMakeLists.txt │ │ ├── ROSDriver.cpp │ │ ├── ROSDriver.h │ │ └── ROSFactory.cpp │ │ ├── RealSense │ │ ├── CMakeLists.txt │ │ ├── RealSense.cpp │ │ ├── RealSense.h │ │ ├── RealSenseFactory.cpp │ │ └── libuvc_ex │ │ │ ├── .travis.yml │ │ │ ├── CMakeLists.txt │ │ │ ├── README.md │ │ │ ├── cameras │ │ │ ├── isight_imac.txt │ │ │ ├── isight_macbook.txt │ │ │ ├── logitech_hd_pro_920.txt │ │ │ ├── ms_lifecam_show.txt │ │ │ ├── quickcampro9000.txt │ │ │ ├── quickcampro9000_builtin_ctrls.txt │ │ │ └── quickcampro9000_extra_ctrls.txt │ │ │ ├── changelog.txt │ │ │ ├── doxygen.conf │ │ │ ├── include │ │ │ ├── libuvc_ex │ │ │ │ ├── libuvc.h │ │ │ │ ├── libuvc_config.h.in │ │ │ │ └── libuvc_internal.h │ │ │ └── utlist.h │ │ │ ├── libuvcConfig.cmake.in │ │ │ ├── libuvcConfigVersion.cmake.in │ │ │ ├── src │ │ │ ├── ctrl-gen.c │ │ │ ├── ctrl-gen.py │ │ │ ├── ctrl.c │ │ │ ├── device.c │ │ │ ├── diag.c │ │ │ ├── example.c │ │ │ ├── frame-mjpeg.c │ │ │ ├── frame.c │ │ │ ├── init.c │ │ │ ├── misc.c │ │ │ ├── stream.c │ │ │ └── test.c │ │ │ └── standard-units.yaml │ │ ├── RealSense2 │ │ ├── CMakeLists.txt │ │ ├── RealSense2Device.cpp │ │ ├── RealSense2Device.h │ │ ├── RealSense2Driver.cpp │ │ ├── RealSense2Driver.h │ │ └── RealSense2Factory.cpp │ │ ├── Rectify │ │ ├── CMakeLists.txt │ │ ├── RectifyDriver.cpp │ │ ├── RectifyDriver.h │ │ └── RectifyFactory.cpp │ │ ├── SimCam │ │ ├── CMakeLists.txt │ │ ├── FindZeroMQ.cmake │ │ ├── LibFindMacros.cmake │ │ ├── Message.proto │ │ ├── NodeCamDriver.cpp │ │ └── NodeCamDriver.h │ │ ├── Split │ │ ├── CMakeLists.txt │ │ ├── SplitDriver.cpp │ │ ├── SplitDriver.h │ │ └── SplitFactory.cpp │ │ ├── ToyotaReader │ │ ├── CMakeLists.txt │ │ ├── ToyotaReaderDriver.cpp │ │ └── ToyotaReaderDriver.h │ │ ├── UVC │ │ ├── CMakeLists.txt │ │ ├── UvcDriver.cpp │ │ ├── UvcDriver.h │ │ ├── UvcFactory.cpp │ │ └── libuvc │ │ │ ├── include │ │ │ ├── libuvc │ │ │ │ ├── libuvc.h │ │ │ │ └── libuvc_internal.h │ │ │ └── utlist.h │ │ │ └── src │ │ │ ├── ctrl.c │ │ │ ├── device.c │ │ │ ├── diag.c │ │ │ ├── frame.c │ │ │ ├── init.c │ │ │ ├── misc.c │ │ │ ├── stream.c │ │ │ └── test.c │ │ ├── Undistort │ │ ├── CMakeLists.txt │ │ ├── UndistortDriver.cpp │ │ ├── UndistortDriver.h │ │ └── UndistortFactory.cpp │ │ ├── V4L │ │ ├── CMakeLists.txt │ │ ├── V4LDriver.cpp │ │ ├── V4LDriver.h │ │ └── V4LFactory.cpp │ │ └── Ximea │ │ ├── CMakeLists.txt │ │ ├── FindXIMEA.cmake │ │ ├── XimeaDriver.cpp │ │ ├── XimeaDriver.h │ │ └── XimeaFactory.cpp ├── Car │ ├── CMakeLists.txt │ ├── CarDevice.h │ ├── CarDriverInterface.h │ └── Drivers │ │ ├── CMakeLists.txt │ │ └── NinjaV3 │ │ ├── CMakeLists.txt │ │ ├── ComDriver.h │ │ ├── NinjaV3CarDriver.cpp │ │ ├── NinjaV3CarDriver.h │ │ └── NinjaV3CarFactory.cpp ├── Devices │ ├── CMakeLists.txt │ ├── DeviceException.h │ ├── DeviceFactory.h │ ├── DeviceRegistry.cpp │ ├── DeviceRegistry.h │ ├── DeviceTime.cpp │ ├── DeviceTime.h │ ├── DriverInterface.h │ └── SharedLoad.h ├── Gamepad │ ├── CMakeLists.txt │ ├── Drivers │ │ ├── CMakeLists.txt │ │ └── GamepadMultiDevice │ │ │ ├── CMakeLists.txt │ │ │ ├── GSDK │ │ │ ├── CMakeLists.txt │ │ │ ├── Gamepad.h │ │ │ ├── Gamepad_linux.c │ │ │ ├── Gamepad_macosx.c │ │ │ ├── Gamepad_private.c │ │ │ ├── Gamepad_private.h │ │ │ ├── Gamepad_windows_dinput.c │ │ │ └── Gamepad_windows_mm.c │ │ │ ├── GamepadMultiDeviceDriver.cpp │ │ │ ├── GamepadMultiDeviceDriver.h │ │ │ ├── GamepadMultiDeviceFactory.cpp │ │ │ ├── JoystickHandler.cpp │ │ │ ├── JoystickHandler.h │ │ │ └── _CMakelist.txt │ ├── GamepadDevice.h │ └── GamepadDriverInterface.h ├── IMU │ ├── CMakeLists.txt │ ├── Drivers │ │ ├── Android │ │ │ ├── AndroidIMUDriver.cpp │ │ │ ├── AndroidIMUDriver.h │ │ │ ├── AndroidIMUFactory.cpp │ │ │ ├── CMakeLists.txt │ │ │ └── FindAndroidKernel.cmake │ │ ├── CMakeLists.txt │ │ ├── Csv │ │ │ ├── CMakeLists.txt │ │ │ ├── CsvDriver.cpp │ │ │ ├── CsvDriver.h │ │ │ └── CsvFactory.cpp │ │ ├── Gladiator │ │ │ ├── CMakeLists.txt │ │ │ ├── GladiatorDriver.cpp │ │ │ ├── GladiatorDriver.h │ │ │ ├── GladiatorFactory.cpp │ │ │ ├── ThreadedCommand.cc │ │ │ ├── ThreadedCommand.h │ │ │ ├── ThreadedObject.cc │ │ │ ├── ThreadedObject.h │ │ │ ├── commport.cpp │ │ │ ├── commport.h │ │ │ ├── gladiator.cpp │ │ │ ├── gladiator.h │ │ │ └── icd_imu.h │ │ ├── Join │ │ │ ├── CMakeLists.txt │ │ │ ├── JoinDriver.cpp │ │ │ ├── JoinDriver.h │ │ │ └── JoinFactory.cpp │ │ ├── MicroStrain │ │ │ ├── CMakeLists.txt │ │ │ ├── MIPSDK │ │ │ │ ├── byteswap_utilities.cpp │ │ │ │ ├── byteswap_utilities.h │ │ │ │ ├── mainpage.h │ │ │ │ ├── mip.cpp │ │ │ │ ├── mip.h │ │ │ │ ├── mip_gx3_35.h │ │ │ │ ├── mip_gx3_45.h │ │ │ │ ├── mip_gx4_15.h │ │ │ │ ├── mip_gx4_25.h │ │ │ │ ├── mip_gx4_45.h │ │ │ │ ├── mip_gx4_imu.h │ │ │ │ ├── mip_sdk.h │ │ │ │ ├── mip_sdk_3dm.cpp │ │ │ │ ├── mip_sdk_3dm.h │ │ │ │ ├── mip_sdk_ahrs.cpp │ │ │ │ ├── mip_sdk_ahrs.h │ │ │ │ ├── mip_sdk_base.cpp │ │ │ │ ├── mip_sdk_base.h │ │ │ │ ├── mip_sdk_config.h │ │ │ │ ├── mip_sdk_filter.cpp │ │ │ │ ├── mip_sdk_filter.h │ │ │ │ ├── mip_sdk_gps.cpp │ │ │ │ ├── mip_sdk_gps.h │ │ │ │ ├── mip_sdk_inteface.cpp │ │ │ │ ├── mip_sdk_interface.cpp │ │ │ │ ├── mip_sdk_interface.h │ │ │ │ ├── mip_sdk_nav.cpp │ │ │ │ ├── mip_sdk_nav.h │ │ │ │ ├── mip_sdk_system.cpp │ │ │ │ ├── mip_sdk_system.h │ │ │ │ ├── mip_sdk_user_functions.cpp │ │ │ │ ├── mip_sdk_user_functions.h │ │ │ │ ├── mip_types.h │ │ │ │ ├── ring_buffer.cpp │ │ │ │ └── ring_buffer.h │ │ │ ├── MicroStrainDriver.cpp │ │ │ ├── MicroStrainDriver.h │ │ │ └── MicroStrainFactory.cpp │ │ ├── NodeIMU │ │ │ ├── CMakeLists.txt │ │ │ ├── FindZeroMQ.cmake │ │ │ ├── NodeIMUDriver.cpp │ │ │ ├── NodeIMUDriver.h │ │ │ └── NodeIMUFactory.cpp │ │ ├── PCAN │ │ │ ├── CMakeLists.txt │ │ │ ├── PCANIMUDriver.cpp │ │ │ ├── PCANIMUDriver.h │ │ │ └── PCANIMUFactory.cpp │ │ ├── Phidgets │ │ │ ├── CMakeLists.txt │ │ │ ├── FindPHIDGETS.cmake │ │ │ ├── PhidgetsDriver.cpp │ │ │ ├── PhidgetsDriver.h │ │ │ └── PhidgetsFactory.cpp │ │ ├── ProtoReader │ │ │ ├── CMakeLists.txt │ │ │ ├── ProtoReaderIMUDriver.cpp │ │ │ ├── ProtoReaderIMUDriver.h │ │ │ └── ProtoReaderIMUFactory.cpp │ │ └── ROSImu │ │ │ ├── CMakeLists.txt │ │ │ ├── ROSImuDriver.cpp │ │ │ ├── ROSImuDriver.h │ │ │ └── ROSImuFactory.cpp │ ├── IMUDevice.h │ └── IMUDriverInterface.h ├── LIDAR │ ├── CMakeLists.txt │ ├── Drivers │ │ ├── CMakeLists.txt │ │ ├── ProtoReader │ │ │ ├── CMakeLists.txt │ │ │ ├── ProtoReaderLIDARDriver.cpp │ │ │ ├── ProtoReaderLIDARDriver.h │ │ │ └── ProtoReaderLIDARFactory.cpp │ │ └── Velodyne │ │ │ ├── CMakeLists.txt │ │ │ ├── FindCBLAS.cmake │ │ │ ├── FindCLAPACK.cmake │ │ │ ├── FindMVL.cmake │ │ │ ├── VelodyneDriver.cpp │ │ │ ├── VelodyneDriver.h │ │ │ ├── VelodyneDriver_local.cpp │ │ │ └── VelodyneFactory.cpp │ ├── LIDARDevice.h │ └── LIDARDriverInterface.h ├── Messages │ ├── Camera.proto │ ├── CameraModel.proto │ ├── Car.proto │ ├── Command.h │ ├── Command.proto │ ├── Gamepad.proto │ ├── Header.proto │ ├── Image.cpp │ ├── Image.h │ ├── Image.proto │ ├── ImageArray.h │ ├── ImagePyramid.h │ ├── Imu.proto │ ├── Lidar.proto │ ├── Logger.cpp │ ├── Logger.h │ ├── Matrix.h │ ├── Matrix.proto │ ├── Messages.proto │ ├── NodeCamMessage.proto │ ├── Pose.h │ ├── Pose.proto │ ├── PoseSensor.proto │ ├── Reader.cpp │ ├── Reader.h │ ├── Velodyne.cpp │ └── Velodyne.h ├── Posys │ ├── CMakeLists.txt │ ├── Drivers │ │ ├── CMakeLists.txt │ │ ├── Csv │ │ │ ├── CMakeLists.txt │ │ │ ├── CsvPosysDriver.cpp │ │ │ ├── CsvPosysDriver.h │ │ │ └── CsvPosysFactory.cpp │ │ ├── MicroStrain │ │ │ ├── CMakeLists.txt │ │ │ ├── MicroStrainPosysDriver.cpp │ │ │ ├── MicroStrainPosysDriver.h │ │ │ └── MicroStrainPosysFactory.cpp │ │ ├── ProtoReader │ │ │ ├── CMakeLists.txt │ │ │ ├── ProtoReaderPosysDriver.cpp │ │ │ ├── ProtoReaderPosysDriver.h │ │ │ └── ProtoReaderPosysFactory.cpp │ │ └── Vicon │ │ │ ├── CMakeLists.txt │ │ │ ├── FindQUATLIB.cmake │ │ │ ├── FindVRPN.cmake │ │ │ ├── ViconDriver.cpp │ │ │ ├── ViconDriver.h │ │ │ └── ViconFactory.cpp │ ├── PosysDevice.h │ └── PosysDriverInterface.h ├── ThirdParty │ ├── .gitignore │ ├── CMakeLists.txt │ └── ThirdPartyConfig.h.in ├── Utils │ ├── CMakeLists.txt │ ├── GetPot │ ├── PropertyMap.h │ ├── StringUtils.h │ ├── TicToc.h │ └── Uri.h └── config.h.in ├── LICENSE ├── README └── cmake_modules ├── .gitignore ├── FindASSIMP.cmake ├── FindAndroidKernel.cmake ├── FindAvahi.cmake ├── FindCeresSolver.cmake ├── FindCoreFoundation.cmake ├── FindDNSSD.cmake ├── FindEigen3.cmake ├── FindFREEGLUT.cmake ├── FindGFlags.cmake ├── FindGLEW.cmake ├── FindGLUES.cmake ├── FindGLog.cmake ├── FindIOKit.cmake ├── FindOpenCL.cmake ├── FindPCAN.cmake ├── FindPackage.cmake.in ├── FindPkgMacros.cmake ├── FindRealSense2.cmake ├── FindTBB.cmake ├── FindTinyXML2.cmake ├── FindUSB1.cmake ├── FindZeroMQ.cmake ├── FindZeroMQPP.cmake ├── LICENSE.md ├── LibFindMacros.cmake ├── PackageConfig.cmake.in ├── PackageConfigVersion.cmake.in ├── PkgConfig.pc.in ├── README.md ├── SetPlatformVars.cmake ├── SetSourceFlags.cmake ├── cmake_uninstall.cmake.in ├── def_apk.cmake ├── def_executable.cmake ├── def_library.cmake ├── def_test.cmake ├── install_package.cmake └── set_git_version.cmake /.gitignore: -------------------------------------------------------------------------------- 1 | CMakeLists.txt.user 2 | build 3 | .DS_Store 4 | *~ 5 | 6 | ##Built binaries 7 | libhal.so 8 | 9 | ##CMake-generated files 10 | CMakeFiles/ 11 | Makefile 12 | doc-pak/ 13 | description-pak 14 | install_manifest.txt 15 | .cproject 16 | .project 17 | CMakeCache.txt 18 | *.deb 19 | 20 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Version 2.8.10 onwards is required for dependency build to work correctly. 2 | cmake_minimum_required(VERSION 2.8.10) 3 | project( HAL ) 4 | 5 | # Add to module path, so we can find our cmake modules 6 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules) 7 | 8 | if(ANDROID) 9 | set(ANDROID_PACKAGE_NAME "edu.colorado.arpg") 10 | endif() 11 | 12 | ################################################################################ 13 | 14 | option( BUILD_SHARED_LIBS "Build shared libraries." ON ) 15 | 16 | include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) 17 | add_subdirectory( HAL ) 18 | 19 | set( HAL_DIR ${CMAKE_CURRENT_BINARY_DIR} ) 20 | set( HAL_LIBRARIES ${HAL_LIBS} hal ) 21 | set( HAL_INCLUDE_DIRS ${HAL_INCLUDES} ) 22 | link_libraries( ${HAL_LIBS} hal ) 23 | 24 | include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ) 25 | 26 | # make an uninstall target 27 | include(${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in) 28 | add_custom_target(uninstall 29 | COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") 30 | -------------------------------------------------------------------------------- /HAL/Camera/AutoExposureInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace hal 6 | { 7 | 8 | class AutoExposureInterface : public CameraDriverInterface 9 | { 10 | public: 11 | 12 | virtual double MaxExposure(int channel = 0) const = 0; 13 | 14 | virtual double MinExposure(int channel = 0) const = 0; 15 | 16 | virtual double MaxGain(int channel = 0) const = 0; 17 | 18 | virtual double MinGain(int channel = 0) const = 0; 19 | 20 | virtual double Exposure(int channel = 0) = 0; 21 | 22 | virtual void SetExposure(double exposure, int channel = 0) = 0; 23 | 24 | virtual double Gain(int channel = 0) = 0; 25 | 26 | virtual void SetGain(double gain, int channel = 0) = 0; 27 | 28 | virtual double ProportionalGain(int channel = 0) const = 0; 29 | 30 | virtual double IntegralGain(int channel = 0) const = 0; 31 | 32 | virtual double DerivativeGain(int channel = 0) const = 0; 33 | }; 34 | 35 | } // namespace hal -------------------------------------------------------------------------------- /HAL/Camera/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(HDRS 2 | CameraDevice.h 3 | CameraDriverInterface.h 4 | ) 5 | 6 | add_to_hal_headers( ${HDRS} ) 7 | 8 | add_subdirectory( Drivers ) 9 | -------------------------------------------------------------------------------- /HAL/Camera/CameraDriverInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | namespace hal { 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | // Generic camera driver interface 13 | class CameraDriverInterface : public DriverInterface 14 | { 15 | public: 16 | // Pure virtual functions driver writers must implement: 17 | virtual ~CameraDriverInterface() {} 18 | virtual bool Capture( hal::CameraMsg& vImages ) = 0; 19 | virtual std::shared_ptr GetInputDevice() = 0; 20 | 21 | virtual size_t NumChannels() const = 0; 22 | virtual size_t Width( size_t /*idx*/ = 0 ) const = 0; 23 | virtual size_t Height( size_t /*idx*/ = 0 ) const = 0; 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/AlliedVision/AlliedVisionDriver.h: -------------------------------------------------------------------------------- 1 | /* 2 | \file Bumblebee2Driver.h 3 | 4 | */ 5 | 6 | #ifndef _ALLIEDVISIONDRIVER_H_ 7 | #define _ALLIEDVISIONDRIVER_H_ 8 | 9 | #include 10 | #include "RPG/Devices/Camera/CameraDriverInterface.h" 11 | 12 | // Forward declaration of Camera type 13 | struct AlliedVisionCamera; 14 | 15 | class AlliedVisionDriver : public CameraDriver 16 | { 17 | public: 18 | AlliedVisionDriver(); 19 | virtual ~AlliedVisionDriver(); 20 | bool Capture( std::vector& vImages ); 21 | bool Capture(AlliedVisionCamera* cam, rpg::ImageWrapper& img ); 22 | void PrintInfo(); 23 | bool Init(); 24 | 25 | private: 26 | void Deinit(); 27 | 28 | bool InitCamera(AlliedVisionCamera* cam, unsigned int width, unsigned int height, unsigned int binningX, unsigned int binningY); 29 | void DeinitCamera(AlliedVisionCamera* cam); 30 | 31 | bool StartCamera(AlliedVisionCamera* cam); 32 | 33 | AlliedVisionCamera* GetFirstCamera(); 34 | 35 | size_t m_numCams; 36 | std::vector m_cam; 37 | }; 38 | 39 | #endif // _ALLIEDVISIONDRIVER_H_ 40 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/AlliedVision/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build AlliedVision driver (you also need to make sure to edit DriverList.h) 2 | set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) 3 | find_package( PVAPI QUIET ) 4 | if( PVAPI_FOUND ) 5 | add_definitions( -DUSE_ALLIEDVISION ) 6 | 7 | message( STATUS "HAL: building 'AlliedVision' camera driver.") 8 | 9 | # 1) Build the library: 10 | set( AV_DRIVER_SOURCES AlliedVisionDriver.cpp ) 11 | set( AV_DRIVER_HEADERS AlliedVisionDriver.h ) 12 | add_library( AlliedVisionDriver ${AV_DRIVER_SOURCES} ${AV_DRIVER_HEADERS} ) 13 | 14 | include_directories( AlliedVisionDriver ${PVAPI_INCLUDE_DIR} ) 15 | target_link_libraries(AlliedVisionDriver ${PVAPI_LIBRARIES} ) 16 | 17 | # 2) Tell HAL about this library: 18 | add_to_hal_libraries( AlliedVisionDriver ) 19 | 20 | list( APPEND HAL_LIBRARIES "${PVAPI_LIBRARIES}" ) 21 | set( HAL_LIBRARIES ${HAL_LIBRARIES} CACHE INTERNAL "" FORCE ) 22 | 23 | # 3) And make sure we are able to install it correctly: 24 | install( TARGETS AlliedVisionDriver 25 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 26 | LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 27 | ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 28 | ) 29 | endif() 30 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/AlliedVision/FindPVAPI.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find libPvAPI 2 | # 3 | # PVAPI_FOUND - system has libPvAPI 4 | # PVAPI_INCLUDE_DIR - the libPvAPI include directories 5 | # PVAPI_LIBRARY - link these to use libPvAPI 6 | 7 | FIND_PATH( 8 | PVAPI_INCLUDE_DIR 9 | NAMES PvApi.h 10 | PATHS 11 | "${CMAKE_SOURCE_DIR}/../AVT GigE SDK/inc-pc" 12 | "${CMAKE_SOURCE_DIR}/../../../AVT GigE SDK/inc-pc" 13 | /usr/include/PvAPI 14 | /usr/local/include/PvAPI 15 | ) 16 | 17 | FIND_LIBRARY( 18 | PVAPI_LIBRARIES 19 | NAMES PvAPI 20 | PATHS 21 | "${CMAKE_SOURCE_DIR}/../AVT GigE SDK/lib-pc/x64/4.2" 22 | "${CMAKE_SOURCE_DIR}/../../../AVT GigE SDK/lib-pc/x64/4.2" 23 | /usr/lib 24 | /usr/local/lib 25 | ) 26 | 27 | IF (PVAPI_INCLUDE_DIR AND PVAPI_LIBRARIES) 28 | SET(PVAPI_FOUND TRUE) 29 | ENDIF (PVAPI_INCLUDE_DIR AND PVAPI_LIBRARIES) 30 | 31 | IF (PVAPI_FOUND) 32 | IF (NOT PVAPI_FIND_QUIETLY) 33 | MESSAGE(STATUS "Found PvAPI: ${PVAPI_LIBRARIES}") 34 | ENDIF (NOT PVAPI_FIND_QUIETLY) 35 | ELSE (PVAPI_FOUND) 36 | IF (PVAPI_FIND_REQUIRED) 37 | MESSAGE(FATAL_ERROR "Could not find PvAPI") 38 | ENDIF (PVAPI_FIND_REQUIRED) 39 | ENDIF (PVAPI_FOUND) 40 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Android/AndroidDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #include 5 | #include 6 | 7 | #pragma GCC diagnostic ignored "-Wunused-parameter" 8 | #include 9 | #include 10 | #pragma GCC diagnostic pop 11 | 12 | #include "CameraListener.h" 13 | 14 | namespace hal 15 | { 16 | 17 | class AndroidDriver : public CameraDriverInterface 18 | { 19 | public: 20 | AndroidDriver(); 21 | ~AndroidDriver(); 22 | 23 | bool Capture( hal::CameraMsg& vImages ); 24 | 25 | size_t NumChannels() const; 26 | size_t Width( size_t /*idx*/ = 0 ) const; 27 | size_t Height( size_t /*idx*/ = 0 ) const; 28 | 29 | inline std::shared_ptr GetInputDevice() { 30 | return std::shared_ptr(); 31 | } 32 | 33 | protected: 34 | android::sp m_Cam; 35 | android::sp m_CamListener; 36 | android::sp m_SurfaceTexture ; 37 | android::sp m_SurfaceTextureClient ; 38 | GLuint m_Texture; 39 | size_t m_nWidth; 40 | size_t m_nHeight; 41 | }; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Android/AndroidFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "AndroidDriver.h" 3 | 4 | namespace hal 5 | { 6 | 7 | class AndroidFactory : public DeviceFactory 8 | { 9 | public: 10 | AndroidFactory(const std::string& name) 11 | : DeviceFactory(name) 12 | { 13 | Params() = { 14 | }; 15 | } 16 | 17 | std::shared_ptr GetDevice(const Uri& /*uri*/) 18 | { 19 | AndroidDriver* driver = new AndroidDriver(); 20 | return std::shared_ptr( driver ); 21 | } 22 | }; 23 | 24 | // Register this factory by creating static instance of factory 25 | static AndroidFactory g_AndroidFactory("android"); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Android/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(ANDROID) 2 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH}) 3 | 4 | find_package(AndroidKernel QUIET) 5 | find_package(GLUES QUIET) 6 | 7 | set(BUILD_Android OFF CACHE BOOL "Build the generic Android camera driver") 8 | 9 | if(BUILD_Android) 10 | 11 | message( STATUS "HAL: building 'Android' camera driver.") 12 | 13 | add_to_hal_include_dirs( ${AndroidKernel_INCLUDE_DIRS} ) 14 | add_to_hal_libraries( ${AndroidKernel_LIBRARIES} ) 15 | 16 | add_to_hal_libraries( ${GLUES_LIBRARY} EGL GLESv2 GLESv1_CM ) 17 | 18 | add_to_hal_sources( 19 | AndroidDriver.h AndroidDriver.cpp 20 | CameraListener.h CameraListener.cpp 21 | AndroidFactory.cpp 22 | ) 23 | hal_set_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/CameraListener.cpp "-fno-rtti -fpermissive") 24 | hal_set_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/AndroidDriver.cpp "-fpermissive") 25 | hal_set_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/AndroidFactory.cpp "-fpermissive") 26 | endif() 27 | 28 | endif() 29 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Android/CameraListener.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #pragma GCC diagnostic ignored "-Wunused-parameter" 7 | #include 8 | #pragma GCC diagnostic pop 9 | 10 | #include 11 | 12 | 13 | namespace hal { 14 | 15 | class HALCameraListener : public android::CameraListener { 16 | public: 17 | HALCameraListener(); 18 | ~HALCameraListener(); 19 | 20 | bool GetImages( hal::ImageMsg* pbImg ); 21 | double GetTimestamp() { return m_dTimestamp; } 22 | 23 | void notify(int32_t msgType, int32_t ext1, int32_t ext2); 24 | void postData(int32_t msgType, const android::sp& dataPtr, 25 | camera_frame_metadata_t *metadata); 26 | void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const android::sp& dataPtr); 27 | 28 | private: 29 | unsigned int m_nCurrentImgId; 30 | unsigned int m_nReadImgId; 31 | std::mutex m_Mutex; 32 | std::condition_variable m_NewImg; 33 | double m_dTimestamp; 34 | unsigned char* m_pBuffer; 35 | size_t m_nBuffSize; 36 | }; 37 | 38 | } /* namespace */ 39 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/AutoExposure/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | message(STATUS "HAL: building 'AutoExposure' camera driver") 2 | 3 | add_to_hal_sources( 4 | AutoExposureDriver.h 5 | AutoExposureDriver.cpp 6 | AutoExposureFactory.cpp 7 | ) -------------------------------------------------------------------------------- /HAL/Camera/Drivers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | subdirlist(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR}) 2 | 3 | foreach(subdir ${SUBDIRS}) 4 | add_subdirectory(${subdir}) 5 | endforeach() 6 | 7 | if(HAL_HAVE_THIRDPARTY) 8 | subdirlist(SUBDIRS "${HAL_THIRDPARTY_DIR}/Camera") 9 | foreach(subdir ${SUBDIRS}) 10 | add_subdirectory("${HAL_THIRDPARTY_DIR}/Camera/${subdir}" "${CMAKE_CURRENT_BINARY_DIR}/${subdir}") 11 | endforeach() 12 | endif() 13 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Cleave/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | set( BUILD_Cleave true CACHE BOOL force ) 4 | 5 | if( BUILD_Cleave) 6 | 7 | message( STATUS "HAL: building 'Cleave' abstract camera driver.") 8 | 9 | add_to_hal_sources( 10 | CleaveDriver.cpp 11 | CleaveFactory.cpp 12 | ) 13 | 14 | endif() 15 | 16 | 17 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Cleave/CleaveDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | //Protobuf includes 14 | #include 15 | #include 16 | 17 | 18 | 19 | namespace hal 20 | { 21 | 22 | class CleaveDriver : public CameraDriverInterface 23 | { 24 | public: 25 | CleaveDriver(std::shared_ptr Input, int m_maxChannel, int m_minChannel); 26 | ~CleaveDriver(); 27 | 28 | bool Capture( hal::CameraMsg& vImages ); 29 | std::shared_ptr GetInputDevice() { return inputCamera; } 30 | 31 | void Start(); 32 | void Stop(); 33 | 34 | size_t NumChannels() const; 35 | size_t Width( size_t /*idx*/ = 0 ) const; 36 | size_t Height( size_t /*idx*/ = 0 ) const; 37 | 38 | 39 | //Width/Height of each component image 40 | std::vector widths; 41 | std::vector heights; 42 | unsigned int maxChannel; 43 | unsigned int minChannel; 44 | 45 | std::shared_ptr inputCamera; 46 | hal::CameraMsg m_InMsg; 47 | 48 | }; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Cleave/CleaveFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "CleaveDriver.h" 3 | 4 | 5 | 6 | namespace hal 7 | { 8 | 9 | class CleaveFactory : public DeviceFactory 10 | { 11 | public: 12 | CleaveFactory(const std::string& name) 13 | : DeviceFactory(name) 14 | { 15 | Params() = { 16 | {"max", "0", "Maximum channel number to pass through"}, 17 | {"min", "0", "Minimum channel number to pass through"}, 18 | }; 19 | }; 20 | 21 | 22 | std::shared_ptr GetDevice(const Uri& uri) 23 | { 24 | hal::Uri subUri(uri.url); 25 | int maxChannel = uri.properties.Get("max", 0); 26 | int minChannel = uri.properties.Get("min", 0); 27 | 28 | if (maxChannel < minChannel) 29 | { 30 | printf("Cleave: Max channel number [%u] is not >= min channel [%u]\n", maxChannel, minChannel); 31 | return NULL; 32 | } 33 | // Create input camera 34 | std::shared_ptr InCam = 35 | DeviceRegistry::Instance().Create(subUri); 36 | CleaveDriver* rs = new CleaveDriver(InCam, maxChannel, minChannel); 37 | return std::shared_ptr( rs ); 38 | } 39 | }; 40 | 41 | // Register this factory by creating static instance of factory 42 | static CleaveFactory g_CleaveFactory("cleave"); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Cleave/README: -------------------------------------------------------------------------------- 1 | The Cleave driver takes a slave video source with 1 or more channels and returns a contiguous subset of the available channels. For instance, with the Occam camera that produces 5 channels, cleave can produce a 'stereo' pair out of say, channels 2 and 3. 2 | 3 | Arguments: 4 | 5 | -cam cleave:[min=1,max=3]// 6 | 7 | will return channels 1,2, and 3 out of the available channels from the slave 8 | 9 | Min and max are zero-based - to pass through a single channel, use '0' for both parameters 10 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Convert/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | message( STATUS "HAL: building 'Convert' abstract camera driver (using libopencv).") 2 | 3 | add_to_hal_libraries( ${OpenCV_LIBS} ) 4 | add_to_hal_include_dirs( ${OpenCV_INCLUDE_DIRS} ) 5 | add_to_hal_sources( 6 | ConvertDriver.h ConvertDriver.cpp ConvertFactory.cpp 7 | ) 8 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/DC1394/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) 2 | 3 | find_package( DC1394_2 QUIET ) 4 | 5 | if( DC1394_2_FOUND ) 6 | 7 | set( BUILD_DC1394 true CACHE BOOL force ) 8 | 9 | if( BUILD_DC1394 ) 10 | 11 | message( STATUS "HAL: building 'DC1394' (firewire) camera driver.") 12 | add_to_hal_libraries( ${DC1394_2_LIBRARIES} ) 13 | add_to_hal_include_dirs( ${DC1394_2_INCLUDE_DIR} ) 14 | add_to_hal_sources( 15 | DC1394Driver.h DC1394Driver.cpp DC1394Factory.cpp 16 | ) 17 | endif() 18 | endif() 19 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Debayer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) 2 | 3 | find_package( DC1394_2 QUIET) 4 | if( DC1394_2_FOUND ) 5 | 6 | message( STATUS "HAL: building 'Debayer' camera driver (using libdc1394).") 7 | add_to_hal_libraries( ${DC1394_2_LIBRARIES} ) 8 | add_to_hal_include_dirs( ${DC1394_2_INCLUDE_DIR} ) 9 | add_to_hal_sources( 10 | DebayerDriver.h DebayerDriver.cpp DebayerFactory.cpp 11 | ) 12 | endif() 13 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Debayer/DebayerDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | 10 | namespace hal 11 | { 12 | 13 | class DebayerDriver : public CameraDriverInterface 14 | { 15 | public: 16 | DebayerDriver( std::shared_ptr Input, 17 | dc1394bayer_method_t Method, 18 | dc1394color_filter_t Filter, 19 | unsigned int nDepth 20 | ); 21 | 22 | bool Capture( hal::CameraMsg& vImages ); 23 | std::shared_ptr GetInputDevice() { return m_Input; } 24 | 25 | std::string GetDeviceProperty(const std::string& sProperty); 26 | 27 | size_t NumChannels() const; 28 | size_t Width( size_t /*idx*/ = 0 ) const; 29 | size_t Height( size_t /*idx*/ = 0 ) const; 30 | 31 | protected: 32 | std::shared_ptr m_Input; 33 | hal::CameraMsg m_Message; 34 | unsigned int m_nImgWidth; 35 | unsigned int m_nImgHeight; 36 | unsigned int m_nNumChannels; 37 | dc1394bayer_method_t m_Method; 38 | dc1394color_filter_t m_Filter; 39 | unsigned int m_nDepth; 40 | 41 | }; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Deinterlace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) 2 | 3 | find_package( DC1394_2 QUIET) 4 | if( DC1394_2_FOUND ) 5 | message( STATUS "HAL: building 'Deinterlace' camera driver (using libdc1394).") 6 | add_to_hal_libraries( ${DC1394_2_LIBRARIES} ) 7 | add_to_hal_include_dirs( ${DC1394_2_INCLUDE_DIR} ) 8 | add_to_hal_sources( 9 | DeinterlaceDriver.h DeinterlaceDriver.cpp DeinterlaceFactory.cpp 10 | ) 11 | endif() 12 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Deinterlace/DeinterlaceDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | 10 | namespace hal 11 | { 12 | 13 | class DeinterlaceDriver : public CameraDriverInterface 14 | { 15 | public: 16 | DeinterlaceDriver( std::shared_ptr Input 17 | ); 18 | 19 | bool Capture( hal::CameraMsg& vImages ); 20 | std::shared_ptr GetInputDevice() { return m_Input; } 21 | 22 | std::string GetDeviceProperty(const std::string& sProperty); 23 | 24 | size_t NumChannels() const; 25 | size_t Width( size_t /*idx*/ = 0 ) const; 26 | size_t Height( size_t /*idx*/ = 0 ) const; 27 | 28 | protected: 29 | std::shared_ptr m_Input; 30 | hal::CameraMsg m_Message; 31 | unsigned char* m_Buffer; 32 | unsigned int m_nImgWidth; 33 | unsigned int m_nImgHeight; 34 | }; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Deinterlace/DeinterlaceFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "DeinterlaceDriver.h" 3 | 4 | #include 5 | 6 | namespace hal 7 | { 8 | 9 | class DeinterlaceFactory : public DeviceFactory 10 | { 11 | public: 12 | DeinterlaceFactory(const std::string& name) 13 | : DeviceFactory(name) 14 | { 15 | Params() = { 16 | }; 17 | } 18 | 19 | std::shared_ptr GetDevice(const Uri& uri) 20 | { 21 | const Uri input_uri = Uri(uri.url); 22 | 23 | // Create input camera 24 | std::shared_ptr Input = 25 | DeviceRegistry::Instance().Create(input_uri); 26 | 27 | DeinterlaceDriver* pDriver = new DeinterlaceDriver( Input ); 28 | return std::shared_ptr( pDriver ); 29 | } 30 | }; 31 | 32 | // Register this factory by creating static instance of factory 33 | static DeinterlaceFactory g_DeinterlaceFactory("deinterlace"); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Epiphan/EpiphanDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "SDK/includes/v2u_lib.h" 6 | #include "SDK/includes/frmgrab.h" 7 | 8 | namespace hal { 9 | 10 | class EpiphanDriver : public CameraDriverInterface 11 | { 12 | public: 13 | EpiphanDriver(); 14 | ~EpiphanDriver(); 15 | 16 | bool Capture( hal::CameraMsg& vImages ); 17 | std::shared_ptr GetInputDevice() { return std::shared_ptr(); } 18 | 19 | std::string GetDeviceProperty(const std::string& sProperty); 20 | 21 | size_t NumChannels() const; 22 | size_t Width( size_t /*idx*/ = 0 ) const; 23 | size_t Height( size_t /*idx*/ = 0 ) const; 24 | 25 | private: 26 | FrmGrabber* OpenGrabber(const char* sn, const char* addr); 27 | int DetectVideoMode(FrmGrabber* fg, V2U_VideoMode* vm, V2U_BOOL details); 28 | void DumpVgaModeFlags(V2U_UINT32 flags, V2U_UINT32 mask); 29 | 30 | private: 31 | unsigned int m_nImageWidth; 32 | unsigned int m_nImageHeight; 33 | double m_dFps; 34 | 35 | FrmGrabber* m_pFrameGrabber; 36 | }; 37 | 38 | } /* namespace */ 39 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Epiphan/EpiphanFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "EpiphanDriver.h" 4 | 5 | namespace hal 6 | { 7 | 8 | class EpiphanFactory : public DeviceFactory 9 | { 10 | public: 11 | EpiphanFactory(const std::string& name) 12 | : DeviceFactory(name) 13 | { 14 | Params() = { 15 | }; 16 | } 17 | 18 | std::shared_ptr GetDevice(const Uri& uri) 19 | { 20 | EpiphanDriver* pDriver = new EpiphanDriver(); 21 | return std::shared_ptr( pDriver ); 22 | } 23 | }; 24 | 25 | // Register this factory by creating static instance of factory 26 | static EpiphanFactory g_EpiphanFactory("epiphan"); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Epiphan/SDK/includes/v2u_lib.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * $Id: v2u_lib.h 7764 2009-10-04 07:41:00Z monich $ 4 | * 5 | * Copyright (C) 2003-2007 Epiphan Systems, Inc. All rights reserved. 6 | * 7 | * v2u_lib master include file. 8 | * 9 | ****************************************************************************/ 10 | 11 | #ifndef _V2U_LIB_H_ 12 | #define _V2U_LIB_H_ 1 13 | 14 | #include "v2u_sys.h" 15 | #include "v2u_util.h" 16 | #include "v2u_save.h" 17 | 18 | #endif /* _V2U_LIB_H_ */ 19 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Epiphan/SDK/includes/v2u_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * $Id: v2u_version.h 15312 2012-01-07 13:16:03Z monich $ 4 | * 5 | * Copyright (C) 2004-2012 Epiphan Systems Inc. All rights reserved. 6 | * 7 | * Version information 8 | * 9 | ****************************************************************************/ 10 | 11 | #ifndef _VGA2USB_VERSION_H_ 12 | #define _VGA2USB_VERSION_H_ 1 13 | 14 | #ifndef V2U_COMPANY_NAME 15 | #define V2U_COMPANY_NAME "Epiphan Systems Inc." 16 | #endif /* V2U_COMPANY_NAME */ 17 | 18 | #ifndef V2U_PRODUCT_COPYRIGHT 19 | #define V2U_PRODUCT_COPYRIGHT "2004-2012 " V2U_COMPANY_NAME 20 | #endif /* V2U_PRODUCT_COPYRIGHT */ 21 | 22 | #ifndef V2U_PRODUCT_NAME 23 | #define V2U_PRODUCT_NAME "Epiphan VGA/DVI Capture" 24 | #endif /* V2U_PRODUCT_NAME */ 25 | 26 | #define V2U_VERSION_MAJOR 3 27 | #define V2U_VERSION_MINOR 27 28 | #define V2U_VERSION_MICRO 1 29 | #define V2U_VERSION_NANO 0 30 | 31 | #endif /* _VGA2USB_VERSION_H_*/ 32 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Epiphan/SDK/libfrmgrab/linux/i386/libfrmgrab.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arpg/HAL/80b3e7a0e43aa471046cea612652bbbe768f46c5/HAL/Camera/Drivers/Epiphan/SDK/libfrmgrab/linux/i386/libfrmgrab.a -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Epiphan/SDK/libfrmgrab/linux/x86_64/libfrmgrab.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arpg/HAL/80b3e7a0e43aa471046cea612652bbbe768f46c5/HAL/Camera/Drivers/Epiphan/SDK/libfrmgrab/linux/x86_64/libfrmgrab.a -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Epiphan/SDK/libfrmgrab/macosx/libfrmgrab.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arpg/HAL/80b3e7a0e43aa471046cea612652bbbe768f46c5/HAL/Camera/Drivers/Epiphan/SDK/libfrmgrab/macosx/libfrmgrab.a -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Epiphan/SDK/libfrmgrab/win/Win32/frmgrab.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arpg/HAL/80b3e7a0e43aa471046cea612652bbbe768f46c5/HAL/Camera/Drivers/Epiphan/SDK/libfrmgrab/win/Win32/frmgrab.lib -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Epiphan/SDK/libfrmgrab/win/x64/frmgrab.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arpg/HAL/80b3e7a0e43aa471046cea612652bbbe768f46c5/HAL/Camera/Drivers/Epiphan/SDK/libfrmgrab/win/x64/frmgrab.lib -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Epiphan/SDK/slib/COPYRIGHT: -------------------------------------------------------------------------------- 1 | 2 | Copyright (C) 2000-2011 by Slava Monich 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | 1.Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2.Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 16 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING 22 | IN ANY WAY OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN 23 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | The views and conclusions contained in the software and documentation 26 | are those of the authors and should not be interpreted as representing 27 | any official policies, either expressed or implied. 28 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Epiphan/SDK/v2u_lib/includes/v2u_lib.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * $Id: v2u_lib.h 7764 2009-10-04 07:41:00Z monich $ 4 | * 5 | * Copyright (C) 2003-2007 Epiphan Systems, Inc. All rights reserved. 6 | * 7 | * v2u_lib master include file. 8 | * 9 | ****************************************************************************/ 10 | 11 | #ifndef _V2U_LIB_H_ 12 | #define _V2U_LIB_H_ 1 13 | 14 | #include "v2u_sys.h" 15 | #include "v2u_util.h" 16 | #include "v2u_save.h" 17 | 18 | #endif /* _V2U_LIB_H_ */ 19 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/FileReader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set( BUILD_FileReader true CACHE BOOL force ) 3 | 4 | if( BUILD_FileReader ) 5 | 6 | message( STATUS "HAL: building 'FileReader' camera driver.") 7 | add_to_hal_sources( 8 | FileReaderDriver.cpp FileReaderFactory.cpp ReadImage.cpp 9 | FileReaderDriver.h ReadImage.h 10 | ) 11 | endif() 12 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/FileReader/ReadImage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace hal 7 | { 8 | 9 | cv::Mat _ReadFile( 10 | const std::string& sImageFileName, 11 | int nFlags 12 | ); 13 | 14 | cv::Mat _ReadPDM( 15 | const std::string& FileName 16 | ); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/FireFly/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(0) 2 | set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) 3 | 4 | find_package( DC1394_2 QUIET ) 5 | if( DC1394_2_FOUND ) 6 | add_definitions( -DUSE_FIREFLY ) 7 | 8 | message( STATUS "HAL: building 'FireFly' camera driver.") 9 | 10 | # 1) Build the library: 11 | set( FF_DRIVER_SOURCES FireFlyDriver.cpp ) 12 | set( FF_DRIVER_HEADERS FireFlyDriver.h ) 13 | add_library( FireFlyDriver ${FF_DRIVER_SOURCES} ${FF_DRIVER_HEADERS} ) 14 | 15 | # 2) Tell HAL about this library: 16 | add_to_hal_include_dirs( ${DC1394_2_INCLUDE_DIR} ) 17 | add_to_hal_libraries( FireFlyDriver ) 18 | 19 | list( APPEND HAL_LIBRARIES ${DC1394_2_LIBRARIES} ) 20 | set( HAL_LIBRARIES ${HAL_LIBRARIES} CACHE INTERNAL "" FORCE ) 21 | 22 | # 3) And make sure we are able to install it correctly: 23 | install( TARGETS FireFlyDriver 24 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 25 | LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 26 | ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 27 | ) 28 | 29 | install( FILES ${FF_DRIVER_HEADERS} 30 | DESTINATION 31 | ${CMAKE_INSTALL_PREFIX}/include/RPG/Devices/Camera/Drivers/FireFly ) 32 | endif() 33 | endif() 34 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/FireFly/FireFlyDriver.h: -------------------------------------------------------------------------------- 1 | /* 2 | \file FireFlyDriver.h 3 | 4 | */ 5 | 6 | #ifndef _FIREFLY_H_ 7 | #define _FIREFLY_H_ 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include "HAL/Camera/CameraDriverInterface.h" 14 | 15 | namespace hal { 16 | 17 | class FireFlyDriver : public CameraDriver 18 | { 19 | public: 20 | FireFlyDriver(); 21 | virtual ~FireFlyDriver(); 22 | bool Capture( hal::CameraMsg& vImages ); 23 | void PrintInfo(); 24 | bool Init(); 25 | private: 26 | void _cleanup_and_exit( dc1394camera_t *pCam ); 27 | private: 28 | dc1394camera_t* m_pCam[5]; 29 | dc1394_t* m_pBus; 30 | dc1394video_mode_t m_nVideoMode; 31 | dc1394framerate_t m_nFramerate; 32 | unsigned int m_nImageWidth; 33 | unsigned int m_nImageHeight; 34 | unsigned int m_nNumCams; 35 | mvl_camera_t* m_pCMod[5]; 36 | bool m_bOutputRectified; 37 | 38 | }; 39 | 40 | } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Flycap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) 2 | 3 | 4 | find_package( FLYCAP QUIET ) 5 | 6 | if( FLYCAP_FOUND ) 7 | 8 | set( BUILD_Flycap true CACHE BOOL force ) 9 | 10 | if( BUILD_Flycap ) 11 | 12 | message( STATUS "HAL: building 'FlyCap' camera driver.") 13 | add_to_hal_include_dirs( ${FLYCAP_INCLUDE_DIR} ) 14 | add_to_hal_libraries( ${FLYCAP_LIBRARIES} ) 15 | add_to_hal_sources( 16 | FlycapDriver.h FlycapDriver.cpp FlycapFactory.cpp 17 | ) 18 | endif() 19 | endif() 20 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Flycap/FlycapDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace hal { 11 | 12 | 13 | class FlycapDriver : public CameraDriverInterface 14 | { 15 | public: 16 | FlycapDriver(std::vector& vID, 17 | FlyCapture2::Mode Mode, 18 | ImageRoi ROI); 19 | ~FlycapDriver(); 20 | 21 | bool Capture( hal::CameraMsg& vImages ); 22 | std::shared_ptr GetInputDevice() { return std::shared_ptr(); } 23 | 24 | std::string GetDeviceProperty(const std::string& sProperty); 25 | 26 | size_t NumChannels() const; 27 | size_t Width( size_t /*idx*/ = 0 ) const; 28 | size_t Height( size_t /*idx*/ = 0 ) const; 29 | 30 | private: 31 | void _CheckError( FlyCapture2::Error error ); 32 | 33 | private: 34 | std::vector m_vCams; 35 | unsigned int m_nImgWidth; 36 | unsigned int m_nImgHeight; 37 | 38 | }; 39 | 40 | } /* namespace */ 41 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Freenect2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package( freenect2 QUIET ) 2 | 3 | set( BUILD_Freenect2 "${freenect2_FOUND}" CACHE BOOL 4 | "Build Freenect2 driver for Kinect2" ) 5 | 6 | set(freenect2_DEFINITIONS "-DLIBFREENECT2_THREADING_TINYTHREAD") 7 | ##temp fix for OpenKinect/libfreenect2 issue #217 8 | #set(freenect2_INCLUDE_DIRS ${freenect2_INCLUDE_DIR} ${freenect2_INCLUDE_DIR}/libfreenect2/tinythread) 9 | # Whoa, this should not be here -- at least move it inside the condtional bellow 10 | 11 | if( BUILD_Freenect2 ) 12 | 13 | set(freenect2_DEFINITIONS "-DLIBFREENECT2_THREADING_TINYTHREAD") 14 | #temp fix for OpenKinect/libfreenect2 issue #217 15 | set(freenect2_INCLUDE_DIRS ${freenect2_INCLUDE_DIR} ${freenect2_INCLUDE_DIR}/libfreenect2/tinythread) 16 | 17 | if( freenect2_FOUND ) 18 | 19 | message( STATUS "HAL: building 'Freenect2' camera driver.") 20 | 21 | add_to_hal_include_dirs( ${freenect2_INCLUDE_DIRS} ) 22 | add_to_hal_libraries( ${freenect2_LIBRARY} ) 23 | add_to_hal_sources( Freenect2Driver.h Freenect2Driver.cpp 24 | Freenect2Factory.cpp depth_registration.h depth_registration.cpp depth_registration_cpu.h depth_registration_cpu.cpp) 25 | hal_set_compile_flags( ${CMAKE_CURRENT_SOURCE_DIR}/Freenect2Driver.cpp ${freenect2_DEFINITIONS} ) 26 | hal_set_compile_flags( ${CMAKE_CURRENT_SOURCE_DIR}/Freenect2Factory.cpp ${freenect2_DEFINITIONS} ) 27 | else() 28 | message("libfreenect2 not found. Freenect2 driver cannot be built") 29 | endif() 30 | endif() 31 | 32 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Freenect2/README: -------------------------------------------------------------------------------- 1 | To use this driver: 2 | - Install libfreenect2 by doing: 3 | git clone https://github.com/dorian3d/libfreenect2.git 4 | 5 | Remember to do make install. 6 | 7 | If runtime fails, make sure the Kinect2 is connected to a USB 3.0 port and that it is recognized by the system in the USB 3.0 SuperSpeed Bus. Note that if it appears in the USB 3.0 Hi-Speed Bus (which actually is USB 2.0), the camera will not work. 8 | 9 | In MacOs, it has been shown effective to plug the camera to the USB port first and then to the power. 10 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/HDMI/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(0) 2 | 3 | 4 | message( STATUS "HAL: building 'HDMI' camera driver.") 5 | 6 | # 1) Build the library 7 | include_directories( Blackmagic ) 8 | set( HDMI_DRIVER_SOURCES HDMIDriver.cpp Blackmagic/DeckLinkAPIDispatch.cpp CaptureDelegate.cpp) 9 | set( HDMI_DRIVER_HEADERS HDMIDriver.h CaptureDelegate.h) 10 | add_library( HDMIDriver ${HDMI_DRIVER_SOURCES} ${HDMI_DRIVER_HEADERS} ) 11 | 12 | # 2) Tell RPG about this library: 13 | add_to_hal_libraries( HDMIDriver ) 14 | 15 | # 3) And make sure we are able to install it correctly: 16 | install( TARGETS HDMIDriver 17 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 18 | LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 19 | ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 20 | ) 21 | 22 | install( FILES ${HDMI_DRIVER_HEADERS} 23 | DESTINATION 24 | ${CMAKE_INSTALL_PREFIX}/include/RPG/Devices/Camera/Drivers/HDMI ) 25 | endif() 26 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/HDMI/HDMIDriver.h: -------------------------------------------------------------------------------- 1 | #ifndef _HDMI_H_ 2 | #define _HDMI_H_ 3 | 4 | #include "RPG/Devices/Camera/CameraDriverInterface.h" 5 | 6 | #include "Blackmagic/DeckLinkAPI.h" 7 | #include "CaptureDelegate.h" 8 | 9 | 10 | class HDMIDriver : public CameraDriver 11 | { 12 | public: 13 | HDMIDriver(); 14 | virtual ~HDMIDriver(); 15 | bool Capture( std::vector& vImages ); 16 | bool Init(); 17 | private: 18 | unsigned int m_nNumImages; 19 | unsigned int m_nImageWidth; 20 | unsigned int m_nImageHeight; 21 | 22 | IDeckLink* m_pDeckLink; 23 | IDeckLinkInput* m_pDeckLinkInput; 24 | IDeckLinkDisplayModeIterator* m_pDisplayModeIterator; 25 | IDeckLinkIterator* m_pIterator; 26 | 27 | CaptureDelegate* m_pDelegate; 28 | 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Join/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUILD_JoinCamera ON CACHE BOOL "Toggle building the Join Camera driver") 2 | if(BUILD_JoinCamera) 3 | message( STATUS "HAL: building 'Join' abstract camera driver.") 4 | add_to_hal_sources( JoinCameraDriver.h JoinCameraDriver.cpp JoinCameraFactory.cpp ) 5 | endif() 6 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Join/README: -------------------------------------------------------------------------------- 1 | The Join driver allows to join image streams from an arbitrary number of other HAL drivers. 2 | 3 | Usage: 4 | join://&&...& 5 | 6 | Example: 7 | join://node://client1/images&node://client2/images 8 | 9 | Note that if used in the command line you need to escape the character '&' or to write all 10 | the driver line between quotes. Examples: 11 | ./SensorViewer -cam join://node://client1/images\&node://client2/images 12 | ./SensorViewer -cam "join://node://client1/images&node://client2/images" 13 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/KitKat/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(ANDROID) 2 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH}) 3 | 4 | find_package(AndroidKernel QUIET) 5 | find_package(GLUES QUIET) 6 | 7 | set(BUILD_KitKat OFF CACHE BOOL "Build the KitKat camera driver") 8 | if(BUILD_KitKat) 9 | 10 | message( STATUS "HAL: building 'KitKat' camera driver.") 11 | 12 | add_to_hal_include_dirs(${AndroidKernel_INCLUDE_DIRS}) 13 | add_to_hal_libraries(${AndroidKernel_LIBRARIES}) 14 | 15 | add_to_hal_libraries(${GLUES_LIBRARY} EGL GLESv2 GLESv1_CM 16 | c m dl utils camera_client binder log ui camera_metadata) 17 | 18 | add_to_hal_sources(KitKatFactory.cpp Camera.cpp KitKatDriver.cpp) 19 | hal_set_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/KitKatDriver.cpp "-fpermissive") 20 | hal_set_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/Camera.cpp "-fpermissive -fno-rtti") 21 | hal_set_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/KitKatFactory.cpp "-fpermissive") 22 | endif() 23 | 24 | endif() 25 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/KitKat/Camera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "./Image.h" 4 | struct camera_t; 5 | 6 | struct camera_t *camera_alloc(int id); 7 | 8 | void camera_play(camera_t *camera); 9 | 10 | void camera_lock_buffer(camera_t *camera, 11 | image_t *buffer); 12 | 13 | void camera_unlock_buffer(camera_t *camera, 14 | image_t *buffer); 15 | 16 | void camera_stop(camera_t *camera); 17 | 18 | void camera_free(camera_t *camera); 19 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/KitKat/Image.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct image_t { 4 | unsigned int texture_id; 5 | 6 | int framecount; 7 | double timestamp; 8 | int width, height; 9 | unsigned char *buffer; 10 | } image_t; 11 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/KitKat/KitKatDriver.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) George Washington University, all rights reserved. See the 2 | // accompanying LICENSE file for more information. 3 | 4 | #include "KitKatDriver.h" 5 | #include 6 | #include "./Camera.h" 7 | #include "./Image.h" 8 | 9 | namespace hal { 10 | 11 | KitKatDriver::KitKatDriver() { 12 | camera_ = camera_alloc(0); 13 | if (camera_) { 14 | camera_play(camera_); 15 | } else { 16 | abort(); 17 | } 18 | } 19 | 20 | KitKatDriver::~KitKatDriver() { 21 | camera_stop(camera_); 22 | camera_free(camera_); 23 | } 24 | 25 | bool KitKatDriver::Capture( hal::CameraMsg& vImages ) { 26 | hal::ImageMsg* pb_img = vImages.add_image(); 27 | 28 | image_t image; 29 | camera_lock_buffer(camera_, &image); 30 | 31 | if (!image.buffer) return false; 32 | 33 | pb_img->set_width(image.width); 34 | pb_img->set_height(image.height); 35 | pb_img->set_type(hal::PB_UNSIGNED_BYTE); 36 | pb_img->set_format(hal::PB_LUMINANCE); 37 | pb_img->set_timestamp(image.timestamp); 38 | pb_img->set_data(image.buffer, image.width * image.height); 39 | 40 | camera_unlock_buffer(camera_, &image); 41 | return true; 42 | } 43 | 44 | size_t KitKatDriver::NumChannels() const { 45 | return 1; 46 | } 47 | 48 | size_t KitKatDriver::Width( size_t ) const { 49 | return 1280; 50 | } 51 | 52 | size_t KitKatDriver::Height( size_t ) const { 53 | return 720; 54 | } 55 | 56 | } // namespace hal 57 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/KitKat/KitKatDriver.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) George Washington University, all rights reserved. See the 2 | // accompanying LICENSE file for more information. 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | struct camera_t; 9 | 10 | namespace hal { 11 | 12 | class KitKatDriver : public CameraDriverInterface { 13 | public: 14 | KitKatDriver(); 15 | virtual ~KitKatDriver(); 16 | 17 | bool Capture( hal::CameraMsg& vImages ); 18 | 19 | size_t NumChannels() const; 20 | size_t Width( size_t /*idx*/ = 0 ) const; 21 | size_t Height( size_t /*idx*/ = 0 ) const; 22 | 23 | inline std::shared_ptr GetInputDevice() { 24 | return std::shared_ptr(); 25 | } 26 | 27 | private: 28 | camera_t* camera_; 29 | }; 30 | } // namespace hal 31 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/KitKat/KitKatFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "KitKatDriver.h" 3 | 4 | namespace hal { 5 | 6 | class KitKatFactory : public DeviceFactory { 7 | public: 8 | KitKatFactory(const std::string& name) 9 | : DeviceFactory(name) { 10 | Params() = {}; 11 | } 12 | 13 | std::shared_ptr GetDevice(const Uri& /*uri*/) { 14 | return std::shared_ptr(new KitKatDriver); 15 | } 16 | }; 17 | 18 | // Register this factory by creating static instance of factory 19 | static KitKatFactory g_KitKatFactory("kitkat"); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/NodeCam/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Node QUIET) 2 | find_package(GLog QUIET) 3 | find_package(ZeroMQPP QUIET) 4 | 5 | if(Node_FOUND AND GLOG_FOUND AND ZeroMQPP_FOUND) 6 | 7 | option(BUILD_NodeCam false "Build NodeCam Driver" ) 8 | 9 | if(BUILD_NodeCam) 10 | message( STATUS "HAL: building 'NodeCam' camera driver.") 11 | add_to_hal_include_dirs(${Node_INCLUDE_DIRS} ${GLOG_INCLUDE_DIRS} ${ZeroMQPP_INCLUDE_DIRS}) 12 | add_to_hal_libraries(${Node_LIBRARIES} ${GLOG_LIBRARIES} ${ZeroMQPP_LIBRARIES}) 13 | add_to_hal_sources(NodeCamDriver.h NodeCamDriver.cpp NodeCamFactory.cpp) 14 | endif() 15 | endif() 16 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/NodeCam/NodeCamDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | namespace hal { 12 | 13 | class NodeCamDriver : public CameraDriverInterface 14 | { 15 | public: 16 | NodeCamDriver(const std::string& sLocalNode, const std::string& sRemoteNode, 17 | const std::string& sTopicName, double timeout); 18 | ~NodeCamDriver(); 19 | 20 | bool Capture( hal::CameraMsg& vImages ); 21 | std::shared_ptr GetInputDevice() { 22 | return std::shared_ptr(); 23 | } 24 | 25 | std::string GetDeviceProperty(const std::string& sProperty); 26 | 27 | size_t NumChannels() const; 28 | size_t Width( size_t idx = 0 ) const; 29 | size_t Height( size_t idx = 0 ) const; 30 | 31 | private: 32 | 33 | bool InitNode(); 34 | 35 | // Returns ms from epoch 36 | std::chrono::milliseconds Now() const; 37 | 38 | // Returns difference in seconds 39 | double EllapsedSeconds(const std::chrono::milliseconds& begin, 40 | const std::chrono::milliseconds& end) const; 41 | 42 | private: 43 | node::node m_Node; 44 | std::string m_sLocalNode; 45 | std::string m_sRemoteNode; 46 | std::string m_sTopicName; 47 | double m_dTimeout; // seconds 48 | std::string m_sAddress; // RemoteNode/Topic 49 | size_t m_nChannels; 50 | std::vector m_nImgWidth; 51 | std::vector m_nImgHeight; 52 | }; 53 | 54 | } /* namespace */ 55 | 56 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/NodeCam/NodeCamFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "NodeCamDriver.h" 4 | 5 | namespace hal 6 | { 7 | 8 | class NodeCamFactory : public DeviceFactory 9 | { 10 | public: 11 | NodeCamFactory(const std::string& name) 12 | : DeviceFactory(name) 13 | { 14 | Params() = {}; 15 | } 16 | 17 | std::shared_ptr GetDevice(const Uri& uri) 18 | { 19 | std::string local_node = uri.properties.Get("name", "nodecam"); 20 | double timeout = uri.properties.Get("timeout", 3.); 21 | 22 | // parse url: remote/topic 23 | std::string::size_type p = uri.url.find('/'); 24 | if(p != std::string::npos && p > 0 && p < uri.url.length() - 1) 25 | { 26 | std::string remote_node = uri.url.substr(0, p); 27 | std::string topic = uri.url.substr(p + 1); 28 | return std::shared_ptr 29 | (new NodeCamDriver(local_node, remote_node, topic, timeout)); 30 | } 31 | else 32 | throw DeviceException("NodeCamDriver: ill-formed URI"); 33 | } 34 | }; 35 | 36 | // Register this factory by creating static instance of factory 37 | static NodeCamFactory g_NodeCamFactory("node"); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/NodeCam/README.md: -------------------------------------------------------------------------------- 1 | NodeCam Driver 2 | ============== 3 | 4 | Usage: 5 | 6 | node[options]:/// 7 | 8 | Parameters: 9 | 10 | * ``: name of the node to connect to. 11 | * ``: name of the topic to subscribe. 12 | 13 | Options: 14 | 15 | * `name`: Name of the current node. Default: `name=nodecam`. 16 | * `timeout`: Timeout in seconds. Default: `timeout=3`. 17 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/NodeSimCam/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUILD_NodeSimCam false CACHE BOOL force) 2 | 3 | find_package(Node QUIET) 4 | if(BUILD_NodeSimCam AND Node_FOUND) 5 | 6 | message( STATUS "HAL: building 'NodeSimCam' camera driver.") 7 | add_to_hal_include_dirs(${Node_INCLUDE_DIRS}) 8 | add_to_hal_libraries(${Node_LIBRARIES}) 9 | add_to_hal_sources(NodeSimCamDriver.h NodeSimCamDriver.cpp NodeSimCamFactory.cpp) 10 | endif() 11 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/NodeSimCam/FindZeroMQ.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find libzmq 2 | # Once done, this will define 3 | # 4 | # ZeroMQ_FOUND - system has libzmq 5 | # ZeroMQ_INCLUDE_DIRS - the libzmq include directories 6 | # ZeroMQ_LIBRARIES - link these to use libzmq 7 | 8 | include(LibFindMacros) 9 | 10 | IF (UNIX) 11 | # Use pkg-config to get hints about paths 12 | libfind_pkg_check_modules(ZeroMQ_PKGCONF libzmq) 13 | 14 | # Include dir 15 | find_path(ZeroMQ_INCLUDE_DIR 16 | NAMES zmq.h 17 | PATHS ${ZEROMQ_ROOT}/include ${ZeroMQ_PKGCONF_INCLUDE_DIRS} 18 | ) 19 | 20 | # Finally the library itself 21 | find_library(ZeroMQ_LIBRARY 22 | NAMES zmq 23 | PATHS ${ZEROMQ_ROOT}/lib ${ZeroMQ_PKGCONF_LIBRARY_DIRS} 24 | ) 25 | ELSEIF (WIN32) 26 | find_path(ZeroMQ_INCLUDE_DIR 27 | NAMES zmq.h 28 | PATHS ${ZEROMQ_ROOT}/include ${CMAKE_INCLUDE_PATH} 29 | ) 30 | # Finally the library itself 31 | find_library(ZeroMQ_LIBRARY 32 | NAMES libzmq 33 | PATHS ${ZEROMQ_ROOT}/lib ${CMAKE_LIB_PATH} 34 | ) 35 | ENDIF() 36 | 37 | # Set the include dir variables and the libraries and let libfind_process do the rest. 38 | # NOTE: Singular variables for this library, plural for libraries this this lib depends on. 39 | set(ZeroMQ_PROCESS_INCLUDES ZeroMQ_INCLUDE_DIR ZeroMQ_INCLUDE_DIRS) 40 | set(ZeroMQ_PROCESS_LIBS ZeroMQ_LIBRARY ZeroMQ_LIBRARIES) 41 | libfind_process(ZeroMQ) 42 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/NodeSimCam/NodeSimCamDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "NodeCamMessage.pb.h" 6 | #include 7 | 8 | #pragma GCC system_header 9 | #include 10 | 11 | namespace hal { 12 | 13 | class NodeSimCamDriver : public CameraDriverInterface 14 | { 15 | public: 16 | NodeSimCamDriver(const hal::Uri &uri); 17 | 18 | virtual ~NodeSimCamDriver(); 19 | 20 | bool Capture( hal::CameraMsg& vImages ); 21 | std::shared_ptr GetInputDevice() { 22 | return std::shared_ptr(); 23 | } 24 | 25 | std::string GetDeviceProperty(const std::string& sProperty); 26 | 27 | bool InitNode(); 28 | bool RegisterInHost(const Uri& uri); 29 | 30 | size_t NumChannels() const; 31 | size_t Width( size_t /*idx*/ = 0 ) const; 32 | size_t Height( size_t /*idx*/ = 0 ) const; 33 | 34 | private: 35 | unsigned int m_nImgHeight; 36 | unsigned int m_nImgWidth; 37 | unsigned int m_nChannels; 38 | 39 | node::node m_Node; 40 | std::string m_sSimNodeName; 41 | std::string m_sDeviceName; 42 | std::string m_sDeviceId; 43 | std::string m_sTopic; 44 | int m_nTimeStep; 45 | }; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/NodeSimCam/NodeSimCamFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "NodeSimCamDriver.h" 3 | 4 | namespace hal 5 | { 6 | 7 | class NodeSimCamFactory : public DeviceFactory 8 | { 9 | public: 10 | NodeSimCamFactory(const std::string& name) 11 | : DeviceFactory(name) 12 | { 13 | Params() = { 14 | {"id", "", "Device ID (Serve the purpose of UUID)."}, 15 | {"sim", "", "name of the simulator, which is also node name."}, 16 | {"name", "", "name of the camera. Id will be used if not set"}, 17 | }; 18 | } 19 | 20 | std::shared_ptr GetDevice(const Uri& uri) 21 | { 22 | NodeSimCamDriver* pDriver = new NodeSimCamDriver(uri); 23 | return std::shared_ptr( pDriver ); 24 | } 25 | }; 26 | 27 | // Register this factory by creating static instance of factory 28 | static NodeSimCamFactory g_NodeCamFactory("nodesim"); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/NodeSimCam/readme.txt: -------------------------------------------------------------------------------- 1 | How to build Node2Cam (please build it with GCC 4.7 or higher version, or you may have strange error!) 2 | 3 | 1, Turn Node and Node2Cam option on when build hal. 4 | 2, make -j, you will see an error about Node2Cam. 5 | 3, type make -j again and that error will gone. Done. (If you know how to solve this error, please inform luma@gwu.edu) 6 | 7 | 8 | How to use Node2Cam 9 | you can test it with TestCam in simba/apps/Examples/TestCam 10 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Occam/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package( OccamIndigo QUIET ) 2 | option( BUILD_Occam "Build Occam Driver." OFF ) 3 | 4 | if( OccamIndigo_FOUND ) 5 | if( BUILD_Occam ) 6 | 7 | message( STATUS "HAL: building 'Occam' camera driver.") 8 | add_to_hal_include_dirs( 9 | ${OccamIndigo_INCLUDE_DIRS} 10 | ) 11 | add_to_hal_libraries( 12 | ${OccamIndigo_LIBRARIES} 13 | ) 14 | add_to_hal_sources( 15 | OccamDriver.cpp 16 | OccamFactory.cpp 17 | ) 18 | endif() 19 | else() 20 | set( BUILD_Occam false) 21 | endif() 22 | 23 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Occam/FindOccamIndigo.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find Occam Indigo SDK 2 | # Once done, this will define 3 | # 4 | # OccamIndigo_FOUND - system has libindigo 5 | # OccamIndigo_INCLUDE_DIRS - the Occam libindigo include directories 6 | # OccamIndigo_LIBRARIES - link these to use libindigo 7 | 8 | include(LibFindMacros) 9 | 10 | IF (UNIX) 11 | 12 | # Include dir 13 | find_path(OccamIndigo_INCLUDE_DIR 14 | NAMES occam/indigo.h 15 | PATHS ${OccamIndigo_ROOT}/include /usr/local/include 16 | ) 17 | 18 | # Finally the library itself 19 | find_library(OccamIndigo_LIBRARY 20 | NAMES indigo 21 | PATHS ${OccamIndigo_ROOT}/lib /usr/local/lib 22 | ) 23 | ENDIF() 24 | 25 | # Set the include dir variables and the libraries and let libfind_process do the rest. 26 | # NOTE: Singular variables for this library, plural for libraries this this lib depends on. 27 | set(OccamIndigo_PROCESS_INCLUDES OccamIndigo_INCLUDE_DIR OccamIndigo_INCLUDE_DIRS) 28 | set(OccamIndigo_PROCESS_LIBS OccamIndigo_LIBRARY OccamIndigo_LIBRARIES) 29 | libfind_process(OccamIndigo) -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Occam/OccamDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | //Protobuf includes 14 | #include 15 | #include 16 | 17 | //Occam includes from the indigosdk package 18 | #include 19 | 20 | using std::cout; 21 | using std::string; 22 | using std::endl; 23 | using std::vector; 24 | 25 | 26 | namespace hal 27 | { 28 | 29 | class OccamDriver : public CameraDriverInterface 30 | { 31 | public: 32 | OccamDriver(string m_serial); 33 | ~OccamDriver(); 34 | 35 | bool Capture( hal::CameraMsg& vImages ); 36 | std::shared_ptr GetInputDevice() { return std::shared_ptr(); } 37 | 38 | void Start(); 39 | void Stop(); 40 | 41 | size_t NumChannels() const; 42 | size_t Width( size_t /*idx*/ = 0 ) const; 43 | size_t Height( size_t /*idx*/ = 0 ) const; 44 | template vector split(const T & str, const T & delimiters); 45 | void reportError(int error_code); 46 | 47 | string serialNumber; 48 | int sensorCount; 49 | int deviceIndex; 50 | int isColor; 51 | 52 | //Width/Height of each component image 53 | int width; 54 | int height; 55 | 56 | //Occam variables 57 | OccamDeviceList* device_list; 58 | OccamDevice* device; 59 | OccamImage* image; 60 | 61 | }; 62 | 63 | } 64 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Occam/OccamFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "OccamDriver.h" 3 | 4 | 5 | 6 | namespace hal 7 | { 8 | 9 | class OccamFactory : public DeviceFactory 10 | { 11 | public: 12 | OccamFactory(const std::string& name) 13 | : DeviceFactory(name) 14 | { 15 | Params() = { 16 | {"serial", "0", "Serial number of the camera to open (default: first discovered)"}, 17 | }; 18 | }; 19 | 20 | 21 | std::shared_ptr GetDevice(const Uri& uri) 22 | { 23 | 24 | std::string serial = uri.properties.Get("serial", ""); 25 | 26 | OccamDriver* rs = new OccamDriver(serial); 27 | return std::shared_ptr( rs ); 28 | } 29 | }; 30 | 31 | // Register this factory by creating static instance of factory 32 | static OccamFactory g_OccamFactory("occam"); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Occam/README: -------------------------------------------------------------------------------- 1 | This driver is for Occam Vision Group's omni60 camera, both mono (tested) and color (untested) 2 | 3 | To download the SDK from Occam, one must first register to get access to the link. 4 | This driver expects to find indigo.h in /usr/include/occam, and tries to find libindigo.so in /usr/lib 5 | This driver is written against Occam SDK version 2.0.13 6 | 7 | 8 | Currently, this driver supports opening a camera by serial number as well as the default of opening the first enumerated camera. 9 | 10 | The camera exports a PbBuf of size 5, with the raw, unprocessed images 11 | 12 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/OpenCV/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( BUILD_OpenCV true CACHE BOOL force ) 2 | 3 | if(BUILD_OpenCV) 4 | 5 | message( STATUS "HAL: building 'OpenCV' camera driver.") 6 | add_to_hal_libraries( ${OpenCV_LIBS} ) 7 | add_to_hal_include_dirs( ${OpenCV_INCLUDE_DIRS} ) 8 | add_to_hal_sources( 9 | OpenCVDriver.h OpenCVDriver.cpp OpenCVFactory.cpp 10 | ) 11 | endif() 12 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/OpenCV/OpenCVDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #if CV_VERSION_EPOCH == 2 || (!defined CV_VERSION_EPOCH && CV_VERSION_MAJOR == 2) 8 | #include 9 | #include //constants are defined here 10 | #elif CV_VERSION_MAJOR == 3 11 | #include 12 | #endif 13 | 14 | #include 15 | 16 | namespace hal { 17 | 18 | class OpenCVDriver : public CameraDriverInterface 19 | { 20 | public: 21 | OpenCVDriver(unsigned int nCamId, bool bForceGrey); 22 | OpenCVDriver(const std::string& sFilePath, bool bForceGrey); 23 | ~OpenCVDriver(); 24 | 25 | bool Capture( hal::CameraMsg& vImages ); 26 | std::shared_ptr GetInputDevice() { return std::shared_ptr(); } 27 | 28 | size_t NumChannels() const; 29 | size_t Width( size_t /*idx*/ = 0 ) const; 30 | size_t Height( size_t /*idx*/ = 0 ) const; 31 | private: 32 | void Initialize(); 33 | size_t img_height_; 34 | size_t img_width_; 35 | int num_channels_; 36 | bool force_greyscale_; 37 | cv::VideoCapture cam_; 38 | }; 39 | } // namespace hal 40 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/OpenCV/OpenCVFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "OpenCVDriver.h" 3 | 4 | namespace hal { 5 | 6 | class OpenCVFactory : public DeviceFactory { 7 | public: 8 | OpenCVFactory(const std::string& name) 9 | : DeviceFactory(name) { 10 | Params() = {}; 11 | } 12 | 13 | std::shared_ptr GetDevice(const Uri& uri) { 14 | bool bGrey = uri.properties.Get("grey", false); 15 | 16 | unsigned int nCamId = uri.properties.Get("id", 0); 17 | 18 | const std::string path = ExpandTildePath(uri.url); 19 | if(path.empty()){ 20 | std::string sName = uri.properties.Get("name", "OpenCVCam"); 21 | return std::shared_ptr( 22 | new OpenCVDriver(nCamId, bGrey)); 23 | }else{ 24 | std::string sName = uri.properties.Get("name", "OpenCVVideoFile"); 25 | return std::shared_ptr( 26 | new OpenCVDriver(path, bGrey)); 27 | } 28 | } 29 | }; 30 | 31 | // Register this factory by creating static instance of factory 32 | static OpenCVFactory g_OpenCVFactory("opencv"); 33 | } // namespace hal 34 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/OpenCV/README: -------------------------------------------------------------------------------- 1 | The OpenCV driver allows to stream video from OpenCV VideoCapture, which can be either a camera or 2 | a file. 3 | 4 | Usage: 5 | opencv:[id=] 6 | - OR - 7 | opencv:// 8 | 9 | Examples: 10 | opencv:[id=2] 11 | opencv:///media/lameusername/data/cap/video1_h264.mp4 12 | 13 | Note that if the is used together with the id property, the id will be ignored. 14 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/OpenNI/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) 2 | 3 | find_package( OpenNI QUIET ) 4 | 5 | if( OPENNI_FOUND ) 6 | 7 | set( BUILD_OpenNI true CACHE BOOL force ) 8 | 9 | if( BUILD_OpenNI ) 10 | 11 | message( STATUS "HAL: building 'OpenNI' camera driver.") 12 | add_to_hal_include_dirs( ${OPENNI_INCLUDE_DIRS} ) 13 | add_to_hal_libraries( ${OPENNI_LIBRARY} ) 14 | add_to_hal_sources( OpenNIDriver.h OpenNIDriver.cpp OpenNIFactory.cpp ) 15 | endif() 16 | endif() 17 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/OpenNI/README: -------------------------------------------------------------------------------- 1 | To use this driver: 2 | - Install OpenNI. 3 | - Install avi2-SensorKinect module. 4 | 5 | If runtime fails, verify if the default Kinect module for Kernel 3.0+ in Ubuntu -- "gspca_kinect" -- is loaded. If so, remove it otherwise it would create conflict with OpenNI. 6 | 7 | rmmod gspca_kinect 8 | 9 | Then blacklist it by adding "blacklist gscpa_kinect" in /etc/modprobe.d/blacklist.conf 10 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/OpenNI2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) 2 | 3 | find_package( OpenNI2 QUIET ) 4 | 5 | if( OPENNI2_FOUND ) 6 | set( BUILD_OpenNI2 true CACHE BOOL force ) 7 | if( BUILD_OpenNI2 ) 8 | message( STATUS "HAL: building 'OpenNI2' camera driver.") 9 | add_to_hal_include_dirs( ${OPENNI2_INCLUDE_DIRS} ) 10 | add_to_hal_libraries( ${OPENNI2_LIBRARIES} ) 11 | add_to_hal_sources( OpenNI2Driver.h OpenNI2Driver.cpp OpenNI2Factory.cpp ) 12 | endif() 13 | endif() 14 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/OpenNI2/README: -------------------------------------------------------------------------------- 1 | To use this driver first install the openni2 API: 2 | 3 | $ brew tap homebrew/science 4 | $ brew install openni2 5 | 6 | In my experience, in OSX, this driver works better than the openni driver. 7 | 8 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/PhotoCalib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUILD_PhotoCalib OFF CACHE BOOL "Build the PhotoCalib Camera driver") 2 | 3 | if(BUILD_PhotoCalib) 4 | 5 | message(STATUS "HAL: building 'PhotoCalib' camera driver.") 6 | 7 | add_to_hal_sources( 8 | PhotoCalibDriver.h 9 | PhotoCalibDriver.cpp 10 | PhotoCalibFactory.cpp 11 | ) 12 | 13 | endif() -------------------------------------------------------------------------------- /HAL/Camera/Drivers/ProtoReader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | message( STATUS "HAL: building 'ProtoReader' camera driver.") 3 | 4 | add_to_hal_sources( 5 | ProtoReaderDriver.h ProtoReaderDriver.cpp ProtoReaderFactory.cpp 6 | ) 7 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/ProtoReader/ProtoReaderDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace hal { 7 | 8 | class ProtoReaderDriver : public CameraDriverInterface { 9 | public: 10 | ProtoReaderDriver(std::string filename, int camID, size_t imageID, 11 | bool realtime); 12 | ~ProtoReaderDriver(); 13 | 14 | bool Capture( hal::CameraMsg& vImages ); 15 | 16 | std::shared_ptr GetInputDevice() { 17 | return std::shared_ptr(); 18 | } 19 | 20 | std::string GetDeviceProperty(const std::string& sProperty); 21 | 22 | size_t NumChannels() const; 23 | size_t Width( size_t /*idx*/ = 0 ) const; 24 | size_t Height( size_t /*idx*/ = 0 ) const; 25 | 26 | protected: 27 | bool ReadNextCameraMessage(hal::CameraMsg& msg); 28 | 29 | bool m_first; 30 | bool m_realtime; 31 | int m_camId; 32 | hal::Reader& m_reader; 33 | hal::CameraMsg m_nextMsg; 34 | 35 | std::vector m_width; 36 | std::vector m_height; 37 | size_t m_numChannels; 38 | std::chrono::steady_clock::time_point m_start_time; 39 | double m_first_frame_time; 40 | }; 41 | 42 | } // end namespace hal 43 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/ProtoReader/ProtoReaderFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ProtoReaderDriver.h" 3 | 4 | namespace hal 5 | { 6 | 7 | class ProtoReaderFactory : public DeviceFactory 8 | { 9 | public: 10 | ProtoReaderFactory(const std::string& name) 11 | : DeviceFactory(name) 12 | { 13 | Params() = { 14 | {"startframe", "0", "First frame to capture."}, 15 | {"id", "0", "Id of the camera in log."}, 16 | {"realtime", "0", "If the data should be played back at framerate"} 17 | }; 18 | } 19 | 20 | std::shared_ptr GetDevice(const Uri& uri) 21 | { 22 | const std::string file = ExpandTildePath(uri.url); 23 | size_t startframe = uri.properties.Get("startframe", 0); 24 | int camId = uri.properties.Get("id", -1); 25 | bool realtime = uri.properties.Get("realtime", 0); 26 | 27 | ProtoReaderDriver* driver = 28 | new ProtoReaderDriver(file, camId, startframe, realtime); 29 | return std::shared_ptr( driver ); 30 | } 31 | }; 32 | 33 | // Register this factory by creating static instance of factory 34 | static ProtoReaderFactory g_ProtoReaderFactory1("proto"); 35 | static ProtoReaderFactory g_ProtoReaderFactory2("log"); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/ROS/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package( roscpp QUIET ) 3 | find_package( image_transport QUIET ) 4 | find_package( std_msgs QUIET ) 5 | if(roscpp_FOUND) 6 | 7 | set( BUILD_ROS_Camera true CACHE BOOL force ) 8 | 9 | if( BUILD_ROS_Camera) 10 | message( STATUS "HAL: building 'ROS' camera driver.") 11 | add_to_hal_include_dirs( 12 | ${roscpp_INCLUDE_DIRS} 13 | ${image_transport_INCLUDE_DIRS} 14 | ${std_msgs_INCLUDE_DIRS} 15 | ) 16 | 17 | add_to_hal_libraries( 18 | ${image_transport_LIBRARIES} 19 | ${std_msgs_LIBRARIES} 20 | ${roscpp_LIBRARIES} 21 | ${PbMsgs_LIBRARIES} 22 | ) 23 | 24 | add_to_hal_sources( 25 | ROSDriver.cpp 26 | ROSFactory.cpp 27 | ) 28 | 29 | endif() 30 | endif() 31 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/ROS/ROSFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ROSDriver.h" 3 | 4 | #define DEFAULT_SIZE "640x480" 5 | 6 | namespace hal 7 | { 8 | 9 | class ROSFactory : public DeviceFactory 10 | { 11 | public: 12 | ROSFactory(const std::string& name) 13 | : DeviceFactory(name) 14 | { 15 | Params() = { 16 | {"topics","/image_left","Topics to subscribe to, separated by +"}, 17 | {"sizes", "DEFAULT_SIZE","Size of each image (wxh), separated by +"}, 18 | {"gray_scale","0","Should the gray images be scaled dynamically to the output range?"}, 19 | }; 20 | }; 21 | 22 | 23 | std::shared_ptr GetDevice(const Uri& uri) 24 | { 25 | 26 | std::string topics = uri.properties.Get("topics", "/image_left"); 27 | std::string sizes = uri.properties.Get("sizes", "DEFAULT_SIZE"); 28 | int grayScale = uri.properties.Get("gray_scale", 0); 29 | 30 | 31 | ROSDriver* rs = new ROSDriver(topics, sizes, grayScale); 32 | return std::shared_ptr( rs ); 33 | } 34 | }; 35 | 36 | // Register this factory by creating static instance of factory 37 | static ROSFactory g_ROSFactory("ros"); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/RealSense/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(USB1 QUIET) 2 | 3 | option( BUILD_RealSense "Build RealSense Driver." OFF ) 4 | 5 | if(USB1_FOUND AND BUILD_RealSense) # to be added: AND BUILD_UVC 6 | 7 | message( STATUS "HAL: building 'RealSense' camera driver.") 8 | 9 | add_to_hal_include_dirs( 10 | ${CMAKE_CURRENT_SOURCE_DIR}/libuvc/include 11 | ${USB1_INCLUDE_DIRS} 12 | ) 13 | 14 | add_to_hal_libraries( 15 | ${USB1_LIBRARIES} 16 | ) 17 | 18 | add_to_hal_sources( 19 | RealSense.h RealSense.cpp RealSenseFactory.cpp 20 | libuvc_ex/src/ctrl.c libuvc_ex/src/ctrl-gen.c libuvc_ex/src/device.c libuvc_ex/src/diag.c 21 | libuvc_ex/src/frame.c libuvc_ex/src/init.c libuvc_ex/src/stream.c 22 | libuvc_ex/src/misc.c 23 | ) 24 | 25 | endif() 26 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/RealSense/RealSenseFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "RealSense.h" 3 | 4 | namespace hal 5 | { 6 | 7 | class RealSenseFactory : public DeviceFactory 8 | { 9 | public: 10 | RealSenseFactory(const std::string& name) 11 | : DeviceFactory(name) 12 | { 13 | Params() = { 14 | {"ir","0","Select ir or depth image for the second channel, 0=depth"}, 15 | {"sync","0","Attempt to use the SCR value from UVC Video spec to sync depth/rgb streams, 0=unsynced images"} 16 | }; 17 | }; 18 | 19 | 20 | std::shared_ptr GetDevice(const Uri& uri) 21 | { 22 | bool useIR = false; 23 | bool useSync = false; 24 | std::string sUseIR = uri.properties.Get("ir", "0"); 25 | std::string sSync = uri.properties.Get("sync", "0"); 26 | if (sUseIR == "1") 27 | useIR = true; 28 | 29 | if (sSync == "1") 30 | useSync = true; 31 | 32 | RealSenseDriver* rs = new RealSenseDriver(useIR, useSync); 33 | return std::shared_ptr( rs ); 34 | } 35 | }; 36 | 37 | // Register this factory by creating static instance of factory 38 | static RealSenseFactory g_RealSenseFactory("realsense"); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/RealSense/libuvc_ex/.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | compiler: 3 | - gcc 4 | before_script: 5 | - mkdir build 6 | - cd build 7 | - cmake .. 8 | script: 9 | - make 10 | before_install: 11 | - sudo apt-get install libusb-1.0-0-dev 12 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/RealSense/libuvc_ex/README.md: -------------------------------------------------------------------------------- 1 | `libuvc` is a cross-platform library for USB video devices, built atop `libusb`. 2 | It enables fine-grained control over USB video devices exporting the standard USB Video Class 3 | (UVC) interface, enabling developers to write drivers for previously unsupported devices, 4 | or just access UVC devices in a generic fashion. 5 | 6 | ## Getting and Building libuvc 7 | 8 | Prerequisites: You will need `libusb` and [CMake](http://www.cmake.org/) installed. 9 | 10 | To build, you can just run these shell commands: 11 | 12 | git clone https://github.com/ktossell/libuvc 13 | cd libuvc 14 | mkdir build 15 | cd build 16 | cmake .. 17 | make && sudo make install 18 | 19 | and you're set! If you want to change the build configuration, you can edit `CMakeCache.txt` 20 | in the build directory, or use a CMake GUI to make the desired changes. 21 | 22 | ## Developing with libuvc 23 | 24 | The documentation for `libuvc` can currently be found at https://int80k.com/libuvc/doc/. 25 | 26 | Happy hacking! 27 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/RealSense/libuvc_ex/cameras/ms_lifecam_show.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arpg/HAL/80b3e7a0e43aa471046cea612652bbbe768f46c5/HAL/Camera/Drivers/RealSense/libuvc_ex/cameras/ms_lifecam_show.txt -------------------------------------------------------------------------------- /HAL/Camera/Drivers/RealSense/libuvc_ex/cameras/quickcampro9000_builtin_ctrls.txt: -------------------------------------------------------------------------------- 1 | Listing available controls for device video0: 2 | Exposure, Auto Priority 3 | Exposure (Absolute) 4 | Exposure, Auto 5 | Backlight Compensation 6 | Sharpness 7 | White Balance Temperature 8 | Power Line Frequency 9 | Gain 10 | White Balance Temperature, Auto 11 | Saturation 12 | Contrast 13 | Brightness 14 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/RealSense/libuvc_ex/cameras/quickcampro9000_extra_ctrls.txt: -------------------------------------------------------------------------------- 1 | Listing available controls for device video0: 2 | Raw bits per pixel 3 | Disable video processing 4 | LED1 Frequency 5 | LED1 Mode 6 | Focus 7 | Exposure, Auto Priority 8 | Exposure (Absolute) 9 | Exposure, Auto 10 | Backlight Compensation 11 | Sharpness 12 | White Balance Temperature 13 | Power Line Frequency 14 | Gain 15 | White Balance Temperature, Auto 16 | Saturation 17 | Contrast 18 | Brightness 19 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/RealSense/libuvc_ex/include/libuvc_ex/libuvc_config.h.in: -------------------------------------------------------------------------------- 1 | #ifndef LIBUVC_CONFIG_H 2 | #define LIBUVC_CONFIG_H 3 | 4 | #define LIBUVC_VERSION_MAJOR @libuvc_VERSION_MAJOR@ 5 | #define LIBUVC_VERSION_MINOR @libuvc_VERSION_MINOR@ 6 | #define LIBUVC_VERSION_PATCH @libuvc_VERSION_PATCH@ 7 | #define LIBUVC_VERSION_STR "@libuvc_VERSION@" 8 | #define LIBUVC_VERSION_INT \ 9 | ((@libuvc_VERSION_MAJOR@ << 16) | \ 10 | (@libuvc_VERSION_MINOR@ << 8) | \ 11 | (@libuvc_VERSION_PATCH@)) 12 | 13 | /** @brief Test whether libuvc is new enough 14 | * This macro evaluates true iff the current version is 15 | * at least as new as the version specified. 16 | */ 17 | #define LIBUVC_VERSION_GTE(major, minor, patch) \ 18 | (LIBUVC_VERSION_INT >= (((major) << 16) | ((minor) << 8) | (patch))) 19 | 20 | #cmakedefine LIBUVC_HAS_JPEG 1 21 | 22 | #endif // !def(LIBUVC_CONFIG_H) 23 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/RealSense/libuvc_ex/libuvcConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # - Config file for the libuvc package 2 | set(libuvc_INCLUDE_DIRS "@CONF_INCLUDE_DIR@") 3 | set(libuvc_LIBRARIES "@CONF_LIBRARY@") 4 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/RealSense/libuvc_ex/libuvcConfigVersion.cmake.in: -------------------------------------------------------------------------------- 1 | set(PACKAGE_VERSION "@libuvc_VERSION@") 2 | 3 | # Check whether the requested PACKAGE_FIND_VERSION is compatible 4 | if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() 12 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/RealSense2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(RealSense2 QUIET) 2 | option(BUILD_RealSense2 "Build RealSense2 Driver." ON) 3 | 4 | if(RealSense2_FOUND AND BUILD_RealSense2) 5 | 6 | message(STATUS "HAL: building 'RealSense2' camera driver.") 7 | 8 | set(SOURCES 9 | RealSense2Device.h 10 | RealSense2Device.cpp 11 | RealSense2Driver.h 12 | RealSense2Driver.cpp 13 | RealSense2Factory.cpp 14 | ) 15 | 16 | add_to_hal_include_dirs(${RealSense2_INCLUDE_DIRS}) 17 | add_to_hal_libraries(${RealSense2_LIBRARIES}) 18 | add_to_hal_sources(${SOURCES}) 19 | 20 | endif() -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Rectify/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set( BUILD_Rectify true CACHE BOOL force ) 3 | 4 | if( BUILD_Rectify ) 5 | 6 | message( STATUS "HAL: building 'Rectify' abstract camera driver.") 7 | 8 | find_package( Calibu 0.1 QUIET ) 9 | if(Calibu_FOUND) 10 | add_to_hal_libraries( ${Calibu_LIBRARIES} ) 11 | add_to_hal_include_dirs( ${Calibu_INCLUDE_DIRS} ) 12 | add_to_hal_sources( 13 | RectifyDriver.h RectifyDriver.cpp RectifyFactory.cpp ) 14 | endif() 15 | endif() 16 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Rectify/RectifyDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #pragma GCC system_header 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace hal 14 | { 15 | 16 | class RectifyDriver : public CameraDriverInterface 17 | { 18 | public: 19 | RectifyDriver(std::shared_ptr input, 20 | const std::shared_ptr> rig); 21 | 22 | bool Capture( hal::CameraMsg& vImages ); 23 | std::shared_ptr GetInputDevice() { return m_input; } 24 | 25 | size_t NumChannels() const; 26 | size_t Width( size_t /*idx*/ = 0 ) const; 27 | size_t Height( size_t /*idx*/ = 0 ) const; 28 | 29 | std::string GetDeviceProperty(const std::string& sProperty); 30 | 31 | /// Return rectified right-from-left camera transform. 32 | inline const Sophus::SE3d& T_rl() const { 33 | return m_T_nr_nl; 34 | } 35 | 36 | /// Return rectified rig. 37 | const std::shared_ptr> Rig() const { 38 | return m_rig; 39 | } 40 | 41 | protected: 42 | Sophus::SE3d m_T_nr_nl; 43 | std::shared_ptr> m_rig; 44 | std::shared_ptr m_input; 45 | std::vector m_vLuts; 46 | 47 | }; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/SimCam/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(0) 2 | PROTOBUF_GENERATE_CPP( PROTO_HDRS PROTO_SRCS Message.proto ) 3 | 4 | # include dirs 5 | include_directories( ${ZeroMQ_INCLUDE_DIRS} ) 6 | include_directories( ${PROTOBUF_INCLUDE_DIRS} ) 7 | include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) 8 | 9 | # Build the library: 10 | set( DRIVER_SOURCES NodeCamDriver.cpp ) 11 | set( DRIVER_HEADERS NodeCamDriver.h ) 12 | add_library( NodeCamDriver ${PROTO_HDRS} ${DRIVER_HEADERS} ${PROTO_SRCS} ${DRIVER_SOURCES} ) 13 | 14 | # Tell RPG about this library: 15 | add_to_hal_libraries( NodeCamDriver ${ZeroMQ_LIBRARIES} ${PROTOBUF_LIBRARIES} ) 16 | 17 | # 3) And make sure we are able to install it correctly: 18 | install( TARGETS NodeCamDriver 19 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 20 | LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 21 | ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 22 | ) 23 | 24 | install( FILES ${DRIVER_HEADERS} 25 | DESTINATION 26 | ${CMAKE_INSTALL_PREFIX}/include/RPG/Devices/Camera/Drivers/NodeCam ) 27 | endif() 28 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/SimCam/FindZeroMQ.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find libzmq 2 | # Once done, this will define 3 | # 4 | # ZeroMQ_FOUND - system has libzmq 5 | # ZeroMQ_INCLUDE_DIRS - the libzmq include directories 6 | # ZeroMQ_LIBRARIES - link these to use libzmq 7 | 8 | include(LibFindMacros) 9 | 10 | IF (UNIX) 11 | # Use pkg-config to get hints about paths 12 | libfind_pkg_check_modules(ZeroMQ_PKGCONF libzmq) 13 | 14 | # Include dir 15 | find_path(ZeroMQ_INCLUDE_DIR 16 | NAMES zmq.h 17 | PATHS ${ZEROMQ_ROOT}/include ${ZeroMQ_PKGCONF_INCLUDE_DIRS} 18 | ) 19 | 20 | # Finally the library itself 21 | find_library(ZeroMQ_LIBRARY 22 | NAMES zmq 23 | PATHS ${ZEROMQ_ROOT}/lib ${ZeroMQ_PKGCONF_LIBRARY_DIRS} 24 | ) 25 | ELSEIF (WIN32) 26 | find_path(ZeroMQ_INCLUDE_DIR 27 | NAMES zmq.h 28 | PATHS ${ZEROMQ_ROOT}/include ${CMAKE_INCLUDE_PATH} 29 | ) 30 | # Finally the library itself 31 | find_library(ZeroMQ_LIBRARY 32 | NAMES libzmq 33 | PATHS ${ZEROMQ_ROOT}/lib ${CMAKE_LIB_PATH} 34 | ) 35 | ENDIF() 36 | 37 | # Set the include dir variables and the libraries and let libfind_process do the rest. 38 | # NOTE: Singular variables for this library, plural for libraries this this lib depends on. 39 | set(ZeroMQ_PROCESS_INCLUDES ZeroMQ_INCLUDE_DIR ZeroMQ_INCLUDE_DIRS) 40 | set(ZeroMQ_PROCESS_LIBS ZeroMQ_LIBRARY ZeroMQ_LIBRARIES) 41 | libfind_process(ZeroMQ) 42 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/SimCam/Message.proto: -------------------------------------------------------------------------------- 1 | package msg; 2 | 3 | message Image 4 | { 5 | required bytes image = 1; 6 | required int32 image_type = 2; 7 | required int32 image_height = 3; 8 | required int32 image_width = 4; 9 | required int32 image_size = 5; 10 | repeated string property_name = 6; 11 | repeated string property_val = 7; 12 | } 13 | 14 | message NodeCam 15 | { 16 | repeated Image image = 1; 17 | } 18 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/SimCam/NodeCamDriver.h: -------------------------------------------------------------------------------- 1 | /* 2 | \file NodeCamDriver.h 3 | 4 | */ 5 | 6 | #ifndef _NODECAM_H_ 7 | #define _NODECAM_H_ 8 | 9 | #include "RPG/Devices/Camera/CameraDriverInterface.h" 10 | 11 | #include "Node.h" 12 | 13 | class NodeCamDriver : public CameraDriver 14 | { 15 | public: 16 | NodeCamDriver(); 17 | virtual ~NodeCamDriver(); 18 | bool Capture( std::vector& vImages ); 19 | bool Init(); 20 | private: 21 | unsigned int m_nNumNodes; 22 | rpg::Node m_Node; 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Split/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | message( STATUS "HAL: building 'Split' abstract camera driver.") 3 | 4 | add_to_hal_sources( 5 | SplitDriver.h SplitDriver.cpp SplitFactory.cpp 6 | ) 7 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Split/SplitDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "HAL/Camera/CameraDriverInterface.h" 7 | 8 | 9 | namespace hal 10 | { 11 | 12 | class SplitDriver : public CameraDriverInterface 13 | { 14 | public: 15 | SplitDriver(std::shared_ptr Input, std::vector& vROIs); 16 | 17 | bool Capture( hal::CameraMsg& vImages ); 18 | std::shared_ptr GetInputDevice() { return m_Input; } 19 | 20 | std::string GetDeviceProperty(const std::string& sProperty); 21 | 22 | size_t NumChannels() const; 23 | size_t Width( size_t /*idx*/ = 0 ) const; 24 | size_t Height( size_t /*idx*/ = 0 ) const; 25 | 26 | 27 | protected: 28 | std::shared_ptr m_Input; 29 | hal::CameraMsg m_InMsg; 30 | std::vector m_vROIs; 31 | }; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/ToyotaReader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(0) 2 | 3 | message( STATUS "HAL: building 'ToyotaReader' camera driver.") 4 | 5 | # 1) Build the library 6 | set( TOYOTAREADER_DRIVER_SOURCES ToyotaReaderDriver.cpp ) 7 | set( TOYOTAREADER_DRIVER_HEADERS ToyotaReaderDriver.h ) 8 | add_library( ToyotaReaderDriver ${TOYOTAREADER_DRIVER_SOURCES} ${TOYOTAREADER_DRIVER_HEADERS} ) 9 | 10 | # 2) Tell HAL about this library: 11 | add_to_hal_libraries( ToyotaReaderDriver ) 12 | 13 | # 3) And make sure we are able to install it correctly: 14 | install( TARGETS ToyotaReaderDriver 15 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 16 | LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 17 | ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 18 | ) 19 | 20 | install( FILES ${TOYOTAREADER_DRIVER_HEADERS} 21 | DESTINATION 22 | ${CMAKE_INSTALL_PREFIX}/include/RPG/Devices/Camera/Drivers/ToyotaReader ) 23 | endif() 24 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/UVC/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(USB1 QUIET) 2 | 3 | if(USB1_FOUND) 4 | 5 | set( BUILD_UVC true CACHE BOOL force ) 6 | 7 | if( BUILD_UVC ) 8 | 9 | message( STATUS "HAL: building 'UVC' camera driver.") 10 | 11 | add_to_hal_include_dirs( 12 | ${CMAKE_CURRENT_SOURCE_DIR}/libuvc/include 13 | ${USB1_INCLUDE_DIRS} 14 | ) 15 | 16 | add_to_hal_libraries( 17 | ${USB1_LIBRARIES} 18 | ) 19 | 20 | add_to_hal_sources( 21 | UvcDriver.h UvcDriver.cpp UvcFactory.cpp 22 | libuvc/src/ctrl.c libuvc/src/device.c libuvc/src/diag.c 23 | libuvc/src/frame.c libuvc/src/init.c libuvc/src/stream.c 24 | libuvc/src/misc.c 25 | ) 26 | 27 | endif() 28 | endif() 29 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/UVC/UvcDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | namespace hal 9 | { 10 | 11 | class UvcDriver : public CameraDriverInterface 12 | { 13 | public: 14 | UvcDriver(); 15 | ~UvcDriver(); 16 | 17 | bool Capture( hal::CameraMsg& vImages ); 18 | std::shared_ptr GetInputDevice() { return std::shared_ptr(); } 19 | bool SetExposure(int nExposure); 20 | 21 | void Start(int vid, int pid, char* sn); 22 | void Stop(); 23 | 24 | size_t NumChannels() const; 25 | size_t Width( size_t /*idx*/ = 0 ) const; 26 | size_t Height( size_t /*idx*/ = 0 ) const; 27 | 28 | static void ImageCallbackAdapter(uvc_frame_t *frame, void *ptr); 29 | void ImageCallback(uvc_frame_t *frame); 30 | 31 | uvc_context* ctx_; 32 | uvc_device* dev_; 33 | uvc_device_handle* devh_; 34 | uvc_frame_t* frame_; 35 | 36 | int pbtype; 37 | int pbformat; 38 | int width_; 39 | int height_; 40 | int fps_; 41 | 42 | 43 | }; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/UVC/UvcFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "UvcDriver.h" 3 | 4 | namespace hal 5 | { 6 | 7 | class UvcFactory : public DeviceFactory 8 | { 9 | public: 10 | UvcFactory(const std::string& name) 11 | : DeviceFactory(name) 12 | { 13 | Params() = { 14 | }; 15 | } 16 | 17 | std::shared_ptr GetDevice(const Uri& /*uri*/) 18 | { 19 | UvcDriver* Uvc = new UvcDriver(); 20 | return std::shared_ptr( Uvc ); 21 | } 22 | }; 23 | 24 | // Register this factory by creating static instance of factory 25 | static UvcFactory g_UvcFactory("uvc"); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Undistort/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set( BUILD_Undistort true CACHE BOOL force ) 3 | 4 | if( BUILD_Undistort ) 5 | find_package( Calibu 0.1 QUIET ) 6 | if(Calibu_FOUND) 7 | message( STATUS "HAL: building 'Undistort' camera driver.") 8 | add_to_hal_libraries( ${Calibu_LIBRARIES} ) 9 | add_to_hal_include_dirs( ${Calibu_INCLUDE_DIRS} ) 10 | add_to_hal_sources( 11 | UndistortDriver.h UndistortDriver.cpp UndistortFactory.cpp 12 | ) 13 | endif() 14 | endif() 15 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Undistort/UndistortDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #pragma GCC system_header 7 | #include 8 | #include 9 | #include 10 | 11 | namespace hal 12 | { 13 | 14 | class UndistortDriver : public CameraDriverInterface 15 | { 16 | public: 17 | UndistortDriver(std::shared_ptr input, 18 | const std::shared_ptr > rig); 19 | 20 | bool Capture( hal::CameraMsg& vImages ); 21 | std::shared_ptr GetInputDevice() { return m_Input; } 22 | 23 | size_t NumChannels() const; 24 | size_t Width( size_t idx = 0 ) const; 25 | size_t Height( size_t idx = 0 ) const; 26 | 27 | std::string GetDeviceProperty(const std::string& sProperty); 28 | 29 | /// Return rectified camera model. 30 | const std::shared_ptr> CameraModel(size_t idx = 0) const { 31 | if(idx < m_CamModel.size()) { 32 | return m_CamModel[idx]; 33 | } 34 | return m_CamModel[0]; 35 | } 36 | 37 | protected: 38 | hal::CameraMsg m_InMsg; 39 | std::shared_ptr m_Input; 40 | std::vector>> m_CamModel; 41 | std::vector m_vLuts; 42 | 43 | }; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/V4L/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") 2 | message( STATUS "HAL: building 'V4L' camera driver.") 3 | add_to_hal_sources( 4 | V4LDriver.h V4LDriver.cpp V4LFactory.cpp 5 | ) 6 | endif() 7 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/V4L/V4LFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "V4LDriver.h" 3 | 4 | namespace hal 5 | { 6 | 7 | class V4LFactory : public DeviceFactory 8 | { 9 | public: 10 | V4LFactory(const std::string& name) 11 | : DeviceFactory(name) 12 | { 13 | Params() = { 14 | }; 15 | } 16 | 17 | std::shared_ptr GetDevice(const Uri& uri) 18 | { 19 | const std::string devname = uri.url; 20 | V4LDriver* pDriver = new V4LDriver(devname, IO_METHOD_MMAP); 21 | return std::shared_ptr( pDriver ); 22 | } 23 | }; 24 | 25 | // Register this factory by creating static instance of factory 26 | static V4LFactory g_V4LFactory("v4l"); 27 | } 28 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Ximea/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) 2 | 3 | find_package( XIMEA ) 4 | 5 | if( XIMEA_FOUND ) 6 | 7 | message( STATUS "HAL: building 'Ximea' camera driver.") 8 | 9 | set( BUILD_Ximea true CACHE BOOL force ) 10 | 11 | if( BUILD_Ximea ) 12 | add_to_hal_include_dirs( ${XIMEA_INCLUDE_DIR} ) 13 | add_to_hal_libraries( ${XIMEA_LIBRARIES} ) 14 | add_to_hal_sources( 15 | XimeaDriver.h XimeaDriver.cpp XimeaFactory.cpp 16 | ) 17 | endif() 18 | else() 19 | message( STATUS "HAL: NOT building 'Ximea' camera driver.") 20 | endif() 21 | -------------------------------------------------------------------------------- /HAL/Camera/Drivers/Ximea/FindXIMEA.cmake: -------------------------------------------------------------------------------- 1 | # 2 | ## Try to find ximea library 3 | ## 4 | ## This module defines the following variables: 5 | ## XIMEA_FOUND - 6 | ## XIMEA_INCLUDE_DIR - include directory 7 | ## XIMEA_LIBRARIES - full path libraries 8 | ## 9 | 10 | SET( XIMEA_SEARCH_PATHS 11 | /usr/local/include/ximea 12 | /usr/include/ximea 13 | /usr/lib 14 | /usr/local/lib 15 | /opt/XIMEA/lib 16 | /opt/XIMEA/include 17 | /Library/Frameworks/m3api.framework/Libraries 18 | /Library/Frameworks/m3api.framework/Headers 19 | ) 20 | 21 | find_path(XIMEA_INCLUDE_DIR 22 | NAMES xiApi.h 23 | PATHS ${XIMEA_SEARCH_PATHS} 24 | ) 25 | 26 | find_library( XIMEA_LIBRARY 27 | NAMES libXIMEA_GenTL.dylib libm3api.so libXIMEA_GenTL.so 28 | PATHS ${XIMEA_SEARCH_PATHS} 29 | ) 30 | 31 | if( XIMEA_INCLUDE_DIR AND XIMEA_LIBRARY ) 32 | set( XIMEA_LIBRARIES ${XIMEA_LIBRARY} ) 33 | set( XIMEA_INCLUDE_DIRS ${XIMEA_INCLUDE_DIR} ) 34 | set( XIMEA_FOUND TRUE ) 35 | endif() 36 | 37 | -------------------------------------------------------------------------------- /HAL/Car/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(HDRS 2 | CarDevice.h 3 | CarDriverInterface.h 4 | ) 5 | 6 | add_to_hal_headers( ${HDRS} ) 7 | 8 | add_subdirectory(Drivers) 9 | -------------------------------------------------------------------------------- /HAL/Car/CarDriverInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace hal { 7 | typedef std::function CarStateDataCallback; 8 | 9 | /////////////////////////////////////////////////////////////////////////////// 10 | // Generic Car Driver Interface 11 | /////////////////////////////////////////////////////////////////////////////// 12 | class CarDriverInterface : public DriverInterface 13 | { 14 | public: 15 | virtual ~CarDriverInterface() {} 16 | 17 | virtual void UpdateCarCommand( CarCommandMsg& command_msg) = 0; 18 | 19 | virtual void RegisterCarStateDataCallback(CarStateDataCallback callback) = 0; 20 | }; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /HAL/Car/Drivers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | subdirlist(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR}) 2 | 3 | foreach(subdir ${SUBDIRS}) 4 | add_subdirectory(${subdir}) 5 | endforeach() 6 | -------------------------------------------------------------------------------- /HAL/Car/Drivers/NinjaV3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUILD_NinjaV3 false CACHE BOOL force) 2 | 3 | if(BUILD_NinjaV3) 4 | 5 | add_to_hal_sources(NinjaV3CarDriver.h NinjaV3CarDriver.cpp NinjaV3CarFactory.cpp ComDriver.h) 6 | 7 | endif() 8 | -------------------------------------------------------------------------------- /HAL/Car/Drivers/NinjaV3/NinjaV3CarFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "NinjaV3CarDriver.h" 4 | 5 | namespace hal 6 | { 7 | 8 | class NinjaV3CarFactory : public DeviceFactory 9 | { 10 | public: 11 | NinjaV3CarFactory(const std::string& name) 12 | : DeviceFactory(name) 13 | { 14 | Params() = { 15 | {"baud", "115200", "Comport baudrate"}, 16 | {"dev", "/dev/ttyUSB0", "Comport device to open"} 17 | }; 18 | } 19 | 20 | std::shared_ptr GetDevice(const Uri& uri) 21 | { 22 | int baud = uri.properties.Get("baud", 115200); 23 | std::string dev = uri.properties.Get("dev","/dev/ttyUSB0"); 24 | NinjaV3CarDriver* pDriver = new NinjaV3CarDriver(dev,baud); 25 | return std::shared_ptr( pDriver ); 26 | } 27 | }; 28 | 29 | // Register this factory by creating static instance of factory 30 | static NinjaV3CarFactory g_NinjaV3CarFactory("ninja_v3"); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /HAL/Devices/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(HDRS 2 | DeviceException.h 3 | DeviceFactory.h 4 | DeviceRegistry.h 5 | DeviceTime.h 6 | DriverInterface.h 7 | SharedLoad.h 8 | ) 9 | 10 | add_to_hal_sources( DeviceTime.cpp DeviceRegistry.cpp ) 11 | 12 | add_to_hal_headers( ${HDRS} ) 13 | -------------------------------------------------------------------------------- /HAL/Devices/DeviceException.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace hal { 7 | 8 | struct DeviceException : std::exception 9 | { 10 | DeviceException(std::string str) : desc(str) {} 11 | DeviceException(std::string str, std::string detail) { 12 | desc = str + "\n\t" + detail; 13 | } 14 | ~DeviceException() throw() {} 15 | const char* what() const throw() { return desc.c_str(); } 16 | std::string desc; 17 | }; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /HAL/Devices/DeviceFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace hal 9 | { 10 | 11 | template 12 | class DeviceFactory 13 | { 14 | public: 15 | struct Param 16 | { 17 | std::string param; 18 | std::string defaultval; 19 | std::string help; 20 | }; 21 | 22 | DeviceFactory(std::string name) 23 | : m_name(name) 24 | { 25 | Registry().RegisterFactory(m_name, this); 26 | } 27 | 28 | virtual ~DeviceFactory() {} 29 | virtual std::shared_ptr GetDevice(const Uri& uri) = 0; 30 | 31 | virtual std::vector AvailableDevices() { 32 | return std::vector(); 33 | } 34 | 35 | inline std::vector& Params() { 36 | return m_params; 37 | } 38 | 39 | inline static hal::DeviceRegistry& Registry() { 40 | return hal::DeviceRegistry::Instance(); 41 | } 42 | 43 | protected: 44 | std::string m_name; 45 | std::vector m_params; 46 | }; 47 | 48 | } 49 | -------------------------------------------------------------------------------- /HAL/Devices/DeviceRegistry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace hal 10 | { 11 | 12 | // Forward declaration 13 | template class DeviceFactory; 14 | 15 | template 16 | class DeviceRegistry 17 | { 18 | public: 19 | /// global device registery singleton 20 | static DeviceRegistry& Instance(); 21 | 22 | DeviceRegistry(); 23 | ~DeviceRegistry(); 24 | 25 | /// Register factory pointer accessible by device_name 26 | void RegisterFactory( 27 | const std::string& device_name, 28 | DeviceFactory* factory 29 | ); 30 | 31 | // Register device 'name' as alias for 'alias' 32 | void RegisterAlias( 33 | const std::string& name, 34 | const std::string& alias 35 | ); 36 | 37 | // Get factory associated with uri 38 | std::shared_ptr Create(const Uri& uri); 39 | 40 | void Destroy(BaseDevice* dev); 41 | 42 | // print the map table 43 | void PrintRegisteredDevices(); 44 | 45 | protected: 46 | 47 | // Map of device names to aliases. 48 | std::map m_aliases; 49 | 50 | // Map of device name -> factory instance 51 | std::map*> m_factories; 52 | 53 | /* 54 | struct DevInstance 55 | { 56 | Uri uri; 57 | std::shared_ptr dev; 58 | }; 59 | */ 60 | // // Vector of running instances 61 | // std::vector m_instances; 62 | }; 63 | 64 | } 65 | -------------------------------------------------------------------------------- /HAL/Devices/DriverInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace hal { 6 | 7 | const std::string DeviceDirectory = "Directory"; 8 | const std::string DeviceDepthFocalLength = "DepthFocalLength"; 9 | const std::string DeviceDepthBaseline = "DepthBaseline"; 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | // Generic device driver interface 13 | class DriverInterface 14 | { 15 | public: 16 | // Get device specific properties, such as base directory for a file reader 17 | inline virtual std::string GetDeviceProperty(const std::string& /*sProperty*/) 18 | { 19 | return std::string(); 20 | } 21 | }; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /HAL/Devices/SharedLoad.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace hal 7 | { 8 | 9 | // Make sure all symbols for HAL are loaded and initialised. 10 | // This may be required for static initialisation based 11 | // plugin systems etc. 12 | struct StaticInitForceLoad{ 13 | StaticInitForceLoad(const char* libpath) { 14 | // TODO: check this path always works out. 15 | void* handle = dlopen(libpath, RTLD_NOW); 16 | if(!handle) { 17 | std::cerr << "Unable to dlopen '" << libpath << "'" << std::endl; 18 | } 19 | } 20 | }; 21 | 22 | #ifndef __APPLE__ 23 | // Trigger load of all symbols via this static variable 24 | static StaticInitForceLoad g_StaticInitForceLoadHAL("libhal.so"); 25 | #endif 26 | 27 | } 28 | -------------------------------------------------------------------------------- /HAL/Gamepad/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(HDRS 2 | GamepadDevice.h 3 | GamepadDriverInterface.h 4 | ) 5 | 6 | add_to_hal_headers( ${HDRS} ) 7 | 8 | add_subdirectory( Drivers ) 9 | -------------------------------------------------------------------------------- /HAL/Gamepad/Drivers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | subdirlist(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR}) 2 | 3 | foreach(subdir ${SUBDIRS}) 4 | add_subdirectory(${subdir}) 5 | endforeach() 6 | -------------------------------------------------------------------------------- /HAL/Gamepad/Drivers/GamepadMultiDevice/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) 2 | 3 | find_package( IOKit QUIET ) 4 | find_package( CoreFoundation QUIET) 5 | 6 | ## There is a problem in add_to_hal_libraries. if I link sys_libs inside if(build_gamepad) then 7 | ## I will have linking errors when compiling the code. this happens when BUILD_GAMEPAD is OFF by default. 8 | set( SYS_LIBS ${IOKit_LIBRARIES} ${COREFOUNDATION_LIBRARY}) 9 | add_to_hal_libraries( ${SYS_LIBS} ) 10 | add_to_hal_include_dirs( ${IOKit_INCLUDE_DIRS} ) 11 | 12 | set( BUILD_GAMEPAD OFF CACHE BOOL force) 13 | if (BUILD_GAMEPAD) 14 | if(UNIX) 15 | set( GSDK_CPP GSDK/Gamepad_private.c ) 16 | set( GSDK_H GSDK/Gamepad_private.h GSDK/Gamepad.h ) 17 | if(APPLE) 18 | if( COREFOUNDATION_FOUND AND IOKit_FOUND ) 19 | set( GSDK_CPP ${GSDK_CPP} GSDK/Gamepad_macosx.c ) 20 | endif( COREFOUNDATION_FOUND AND IOKit_FOUND ) 21 | else(APPLE) 22 | set( GSDK_CPP ${GSDK_CPP} GSDK/Gamepad_linux.c ) 23 | endif(APPLE) 24 | endif(UNIX) 25 | add_to_hal_sources( GamepadMultiDeviceDriver.h ${GSDK_H} GamepadMultiDeviceDriver.cpp GamepadMultiDeviceFactory.cpp ${GSDK_CPP} ) 26 | endif( BUILD_GAMEPAD ) 27 | 28 | -------------------------------------------------------------------------------- /HAL/Gamepad/Drivers/GamepadMultiDevice/GSDK/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(Gamepad) 2 | cmake_minimum_required(VERSION 2.8) 3 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) 4 | 5 | set( GAMEPAD_HDRS Gamepad.h 6 | Gamepad_private.h 7 | ) 8 | 9 | set( GAMEPAD_SRC Gamepad_private.c 10 | ) 11 | 12 | # test platform type 13 | if(UNIX) 14 | if(APPLE) 15 | find_package( IOKit REQUIRED ) 16 | include_directories( ${IOKit_INCLUDE_DIRS} ) 17 | find_library(COREFOUNDATION_FRAMEWORK CoreFoundation) 18 | message("Finding library CoreFoundation: ${COREFOUNDATION_FRAMEWORK}") 19 | set( GAMEPAD_SRC ${GAMEPAD_SRC} Gamepad_macosx.c ) 20 | set( GAMEPAD_LIBRARIES ${GLUT_LIBRARY} ${OPENGL_LIBRARY}) 21 | else() 22 | set( GAMEPAD_SRC ${GAMEPAD_SRC} Gamepad_linux.c ) 23 | endif() 24 | endif() 25 | 26 | add_library(Gamepad ${GAMEPAD_HDRS} ${GAMEPAD_SRC} ) 27 | target_link_libraries(Gamepad ${GAMEPAD_LIBRARIES} ${IOKit_LIBRARIES} ${COREFOUNDATION_FRAMEWORK}) 28 | -------------------------------------------------------------------------------- /HAL/Gamepad/Drivers/GamepadMultiDevice/GamepadMultiDeviceDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "GSDK/Gamepad.h" 10 | 11 | namespace hal { 12 | 13 | class GamepadMultiDeviceDriver : public GamepadDriverInterface { 14 | public: 15 | GamepadMultiDeviceDriver(); 16 | ~GamepadMultiDeviceDriver(); 17 | void RegisterGamepadDataCallback(GamepadDriverDataCallback callback); 18 | bool IsRunning() const override { return mShouldRun; } 19 | // void EnableVerbose(bool enable) const override { _verbose = enable; } 20 | 21 | private: 22 | static GamepadDriverDataCallback mGamepadCallback; 23 | static void _OnButtonDown(struct Gamepad_device* device, unsigned int buttonID, double timestamp, void* context); 24 | static void _OnButtonUp(struct Gamepad_device* device, unsigned int buttonID, double timestamp, void* context); 25 | static void _OnAxisMoved(struct Gamepad_device* device, unsigned int axisID, float value, float lastValue, double timestamp, void * context); 26 | static void _OnDeviceAttached(struct Gamepad_device* device, void* context); 27 | static void _OnDeviceRemoved(struct Gamepad_device* device, void* context); 28 | void _GamepadThread(); 29 | bool _Init(); 30 | std::mutex should_run_mutex; 31 | volatile bool mShouldRun; 32 | std::thread _GamepadThreadHandle; 33 | std::string m_sPortName; 34 | static hal::GamepadMsg pbGamepadMsg; 35 | static hal::VectorMsg *pbVecButtonsMsg; 36 | static hal::VectorMsg *pbVecAxesMsg; 37 | 38 | // for debug purposes 39 | static bool _verbose; 40 | }; 41 | 42 | } /* namespace */ 43 | -------------------------------------------------------------------------------- /HAL/Gamepad/Drivers/GamepadMultiDevice/GamepadMultiDeviceFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "GamepadMultiDeviceDriver.h" 4 | 5 | namespace hal 6 | { 7 | 8 | class GamepadMultiDeviceFactory : public DeviceFactory 9 | { 10 | public: 11 | GamepadMultiDeviceFactory(const std::string& name) 12 | : DeviceFactory(name) 13 | { 14 | Params() = { 15 | }; 16 | } 17 | 18 | std::shared_ptr GetDevice(const Uri& /*uri*/) 19 | { 20 | GamepadMultiDeviceDriver* pDriver = 21 | new GamepadMultiDeviceDriver(); 22 | return std::shared_ptr( pDriver ); 23 | } 24 | }; 25 | 26 | // Register this factory by creating static instance of factory 27 | static GamepadMultiDeviceFactory g_GamepadMultiDeviceFactory("gamepad"); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /HAL/Gamepad/Drivers/GamepadMultiDevice/JoystickHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include "Gamepad/Gamepad.h" 10 | #include "Gamepad/EventDispatcher.h" 11 | 12 | #define JOYSTICK_AXIS_MAX 1.0 13 | #define JOYSTICK_AXIS_MIN -1.0 14 | 15 | class JoystickHandler 16 | { 17 | public: 18 | JoystickHandler(); 19 | bool InitializeJoystick(); 20 | void UpdateJoystick(); 21 | 22 | double GetAxisValue(int id) { return id < (int)m_vAxes.size() ? m_vAxes[id] : 0; } 23 | bool IsButtonPressed(int id){ return id < (int)m_vButtonStates.size() ? m_vButtonStates[id] == 1 : false; } 24 | 25 | void JoinThread(); 26 | 27 | 28 | private: 29 | void _ThreadFunc(); 30 | static bool _OnButtonDown(void *sender, const char *eventID, void *eventData, void *context); 31 | static bool _OnButtonUp(void *sender, const char *eventID, void *eventData, void *context); 32 | static bool _OnAxisMoved(void *sender, const char *eventID, void *eventData, void *context); 33 | static bool _OnDeviceAttached(void *sender, const char *eventID, void *eventData, void *context); 34 | static bool _OnDeviceRemoved(void *sender, const char *eventID, void *eventData, void *context); 35 | 36 | std::vector m_vAxes; 37 | std::vector m_vButtonStates; 38 | std::thread* m_pJoystickThread; 39 | 40 | }; 41 | -------------------------------------------------------------------------------- /HAL/Gamepad/Drivers/GamepadMultiDevice/_CMakelist.txt: -------------------------------------------------------------------------------- 1 | project(commander_node) 2 | cmake_minimum_required(VERSION 2.8) 3 | 4 | set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules ${CMAKE_MODULE_PATH} ) 5 | 6 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 7 | 8 | option(JOYSTICK_CONTROL "Enable in order to control ninja with joystick" ON) 9 | 10 | find_package( HAL REQUIRED ) 11 | find_package( Node REQUIRED ) 12 | find_package( Protobuf REQUIRED ) 13 | include_directories( ${CMAKE_BINARY_DIR} ) 14 | PROTOBUF_GENERATE_CPP( PROTO_SRCS PROTO_HDRS NinjaMsgs.proto ) 15 | 16 | include_directories( ${HAL_INCLUDE_DIRS} ) 17 | include_directories( ${Node_INCLUDE_DIRS} ) 18 | 19 | add_subdirectory( Gamepad ) 20 | set( HDRS ${PROTO_HDRS} JoystickHandler.h) 21 | 22 | if(JOYSTICK_CONTROL) 23 | set( SRCS JoystickHandler.cpp commander_node.cpp ${PROTO_SRCS} ) 24 | else() 25 | set( SRCS main.cpp JoystickHandler.cpp ${PROTO_SRCS} ) 26 | endif() 27 | 28 | add_executable( ${PROJECT_NAME} ${HDRS} ${SRCS} ) 29 | 30 | target_link_libraries( ${PROJECT_NAME} 31 | ${HAL_LIBRARIES} 32 | ${PROTOBUF_LIBRARY} 33 | ${Node_LIBRARIES} 34 | ${PROTOBUF_LIBRARIES} 35 | Gamepad 36 | ) 37 | -------------------------------------------------------------------------------- /HAL/Gamepad/GamepadDevice.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace hal { 10 | 11 | // Generic Gamepad device 12 | class Gamepad : public GamepadDriverInterface { 13 | public: 14 | Gamepad() {} 15 | 16 | Gamepad(const std::string& uri) : m_URI(uri) { 17 | m_Gamepad = DeviceRegistry::Instance().Create(m_URI); 18 | } 19 | 20 | ~Gamepad() { 21 | Clear(); 22 | } 23 | 24 | inline void Reset() { 25 | Clear(); 26 | m_Gamepad = DeviceRegistry::Instance().Create(m_URI); 27 | RegisterGamepadDataCallback(m_callback); 28 | } 29 | 30 | void Clear() { 31 | m_Gamepad = nullptr; 32 | } 33 | 34 | void RegisterGamepadDataCallback(GamepadDriverDataCallback callback) override{ 35 | m_callback = callback; 36 | if( m_Gamepad ){ 37 | m_Gamepad->RegisterGamepadDataCallback( callback ); 38 | }else{ 39 | std::cerr << "ERROR: no driver initialized!\n"; 40 | } 41 | return; 42 | } 43 | 44 | std::string GetDeviceProperty(const std::string& sProperty) override{ 45 | return m_Gamepad->GetDeviceProperty(sProperty); 46 | } 47 | 48 | bool IsRunning() const override { 49 | return m_Gamepad->IsRunning(); 50 | } 51 | 52 | protected: 53 | hal::Uri m_URI; 54 | std::shared_ptr m_Gamepad; 55 | GamepadDriverDataCallback m_callback; 56 | }; 57 | } /* namespace hal */ 58 | -------------------------------------------------------------------------------- /HAL/Gamepad/GamepadDriverInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace hal { 8 | 9 | typedef std::function GamepadDriverDataCallback; 10 | 11 | /// Generic Gamepad driver interface 12 | /// 13 | class GamepadDriverInterface : public DriverInterface { 14 | public: 15 | virtual ~GamepadDriverInterface() {} 16 | virtual void RegisterGamepadDataCallback(GamepadDriverDataCallback callback) = 0; 17 | virtual bool IsRunning() const = 0; 18 | // virtual void EnableVerbose(bool enable) const = 0; 19 | }; 20 | 21 | } /* namespace */ 22 | -------------------------------------------------------------------------------- /HAL/IMU/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(HDRS 2 | IMUDevice.h 3 | IMUDriverInterface.h 4 | ) 5 | 6 | add_to_hal_headers( ${HDRS} ) 7 | 8 | add_subdirectory( Drivers ) 9 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Android/AndroidIMUDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | // Android sensor interface classes 9 | class ASensorEventQueue; 10 | class ASensorManager; 11 | class ASensor; 12 | 13 | namespace hal { 14 | 15 | class AndroidIMUDriver : public IMUDriverInterface { 16 | public: 17 | AndroidIMUDriver(); 18 | virtual ~AndroidIMUDriver(); 19 | void RegisterIMUDataCallback(IMUDriverDataCallback callback) override; 20 | 21 | bool IsRunning() const override { 22 | return should_run_; 23 | } 24 | 25 | private: 26 | void SensorLoop(); 27 | 28 | IMUDriverDataCallback imu_callback_; 29 | 30 | bool should_run_; 31 | std::thread device_thread_; 32 | ASensorManager* sensor_manager_; 33 | ASensorEventQueue* event_queue_; 34 | const ASensor* accelerometer_, *gyroscope_, *magnetometer_; 35 | }; 36 | 37 | } // end namespace hal 38 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Android/AndroidIMUFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "./AndroidIMUDriver.h" 3 | 4 | namespace hal { 5 | class AndroidIMUFactory : public DeviceFactory { 6 | public: 7 | AndroidIMUFactory(const std::string& name) 8 | : DeviceFactory(name) { 9 | Params() = {}; 10 | } 11 | 12 | std::shared_ptr GetDevice(const Uri& /*uri*/) { 13 | return std::shared_ptr(new AndroidIMUDriver()); 14 | } 15 | }; 16 | 17 | // Register this factory by creating static instance of factory 18 | static AndroidIMUFactory g_AndroidIMUFactory("android"); 19 | } // end namespace hal 20 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Android/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # build the library 2 | if(ANDROID) 3 | find_package(AndroidKernel QUIET) 4 | 5 | if(AndroidKernel_FOUND) 6 | set(should_build ON) 7 | else() 8 | set(should_build OFF) 9 | endif() 10 | set(BUILD_ANDROID_IMU ${should_build} CACHE BOOL "Build an IMU driver for recent Android devices") 11 | if(BUILD_ANDROID_IMU) 12 | add_to_hal_sources( 13 | AndroidIMUDriver.h 14 | AndroidIMUDriver.cpp 15 | AndroidIMUFactory.cpp) 16 | add_to_hal_include_dirs(${AndroidKernel_INCLUDE_DIRS}) 17 | add_to_hal_libraries(${AndroidKernel_LIBRARIES}) 18 | endif() 19 | endif() -------------------------------------------------------------------------------- /HAL/IMU/Drivers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | subdirlist(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR}) 2 | 3 | foreach(subdir ${SUBDIRS}) 4 | add_subdirectory(${subdir}) 5 | endforeach() 6 | 7 | if(HAL_HAVE_THIRDPARTY) 8 | subdirlist(SUBDIRS "${HAL_THIRDPARTY_DIR}/IMU") 9 | foreach(subdir ${SUBDIRS}) 10 | add_subdirectory("${HAL_THIRDPARTY_DIR}/IMU/${subdir}" "${CMAKE_CURRENT_BINARY_DIR}/${subdir}") 11 | endforeach() 12 | endif() 13 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Csv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # build the library 2 | set( BUILD_Csv_IMU true CACHE BOOL force ) 3 | 4 | if( BUILD_Csv_IMU ) 5 | add_to_hal_sources( CsvDriver.h CsvDriver.cpp CsvFactory.cpp ) 6 | endif() 7 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Csv/CsvDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | namespace hal { 9 | 10 | class CsvDriver : public IMUDriverInterface 11 | { 12 | public: 13 | CsvDriver(const std::string sFileAccel, const std::string sFileGyro, 14 | const std::string sFileMag, 15 | const std::string sFileTimestamp 16 | ); 17 | ~CsvDriver(); 18 | 19 | void RegisterIMUDataCallback(IMUDriverDataCallback callback); 20 | void RegisterIMUFinishedCallback(IMUDriverFinishedCallback callback); 21 | bool IsRunning() const override { 22 | return m_bShouldRun; 23 | } 24 | 25 | private: 26 | void _ThreadCaptureFunc(); 27 | bool _GetNextTime( double& dNextTime, double& dNextTimePPS ); 28 | 29 | bool m_bHaveAccel; 30 | bool m_bHaveGyro; 31 | bool m_bHaveMag; 32 | bool m_bHaveGPS; 33 | std::string m_sDataSourceDir; 34 | std::ifstream m_pFileTime; 35 | std::ifstream m_pFileAccel; 36 | std::ifstream m_pFileGyro; 37 | std::ifstream m_pFileMag; 38 | std::ifstream m_pFileGPS; 39 | volatile bool m_bShouldRun; 40 | double m_dNextTime; 41 | double m_dNextTimePPS; 42 | std::thread m_DeviceThread; 43 | IMUDriverDataCallback m_IMUCallback; 44 | IMUDriverFinishedCallback m_IMUFinishedCallback; 45 | }; 46 | 47 | } /* namespace */ 48 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Csv/CsvFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "CsvDriver.h" 5 | 6 | namespace hal 7 | { 8 | 9 | class CsvFactory : public DeviceFactory 10 | { 11 | public: 12 | CsvFactory(const std::string& name) 13 | : DeviceFactory(name) 14 | { 15 | Params() = { 16 | }; 17 | } 18 | 19 | std::shared_ptr GetDevice(const Uri& uri) 20 | { 21 | const std::string sDataSourceDir = hal::ExpandTildePath(uri.url); 22 | const std::string sFileAccel = uri.properties.Get( "Accel", sDataSourceDir+"/accel.txt"); 23 | const std::string sFileGyro = uri.properties.Get( "Gyro", sDataSourceDir+"/gyro.txt"); 24 | const std::string sFileMag = uri.properties.Get( "Mag", sDataSourceDir+"/mag.txt"); 25 | const std::string sFileTimestamp = uri.properties.Get( "Timestamp", sDataSourceDir+"/timestamp.txt"); 26 | 27 | CsvDriver* pDriver = new CsvDriver(sFileAccel, sFileGyro, sFileMag, sFileTimestamp); 28 | return std::shared_ptr( pDriver ); 29 | } 30 | }; 31 | 32 | // Register this factory by creating static instance of factory 33 | static CsvFactory g_CsvFactory("csv"); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Gladiator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set( BUILD_Gladiator_Imu false CACHE BOOL force ) 3 | 4 | if( BUILD_Gladiator_Imu) 5 | message( STATUS "HAL: building Gladiator IMU driver.") 6 | add_to_hal_include_dirs( 7 | . 8 | ) 9 | 10 | add_to_hal_libraries( 11 | ${PbMsgs_LIBRARIES} 12 | ) 13 | 14 | add_to_hal_sources( 15 | commport.cpp 16 | GladiatorDriver.cpp 17 | GladiatorFactory.cpp 18 | gladiator.cpp 19 | ThreadedCommand.cc 20 | ThreadedObject.cc 21 | 22 | ) 23 | 24 | endif() 25 | 26 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Gladiator/GladiatorDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "gladiator.h" 14 | 15 | namespace hal { 16 | 17 | class GladiatorDriver : public IMUDriverInterface 18 | { 19 | public: 20 | GladiatorDriver(const char* mPort); 21 | ~GladiatorDriver(); 22 | bool Init(const char* mPort); 23 | void RegisterIMUDataCallback(IMUDriverDataCallback callback); 24 | volatile bool m_bShouldRun; 25 | bool IsRunning() const override { 26 | return false; 27 | } 28 | std::thread m_DeviceThread; 29 | void service(); 30 | private: 31 | GladiatorIMU *m_dev; 32 | 33 | IMUDriverDataCallback m_IMUCallback; 34 | }; 35 | 36 | } /* namespace */ 37 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Gladiator/GladiatorFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GladiatorDriver.h" 4 | 5 | namespace hal 6 | { 7 | 8 | class GladiatorFactory : public DeviceFactory 9 | { 10 | public: 11 | GladiatorFactory(const std::string& name) 12 | : DeviceFactory(name) 13 | { 14 | Params() = { 15 | {"port","/dev/ttyUSB0","RS485-capable serial port"}, 16 | }; 17 | } 18 | 19 | std::shared_ptr GetDevice(const Uri& uri) 20 | { 21 | std::string port = uri.properties.Get("port", "/dev/ttyUSB0"); 22 | GladiatorDriver* pDriver = new GladiatorDriver(port.c_str()); 23 | return std::shared_ptr( pDriver ); 24 | } 25 | }; 26 | 27 | // Register this factory by creating static instance of factory 28 | static GladiatorFactory g_GladiatorFactory("gladiator"); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Gladiator/ThreadedCommand.h: -------------------------------------------------------------------------------- 1 | #ifndef __THREADEDCOMMAND_H_ 2 | #define __THREADEDCOMMAND_H_ 3 | 4 | #include "ThreadedObject.h" 5 | /* 6 | Originally developed at Astrobotic (https://www.astrobotic.com). Used with permission 7 | Generic command to be used with the ThreadedObjects. 8 | Override and populate with device-specific fields 9 | */ 10 | 11 | class ThreadedCommand 12 | { 13 | public: 14 | ThreadedCommand(ThreadedObject *m_parent); 15 | ~ThreadedCommand(); 16 | void signal(); 17 | void submit(); 18 | void wait(); 19 | private: 20 | pthread_mutex_t cmdMutex; 21 | pthread_cond_t responseValid; 22 | ThreadedObject *parent; 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Gladiator/ThreadedObject.h: -------------------------------------------------------------------------------- 1 | #ifndef __THREADEDOBJ_H_ 2 | #define __THREADEDOBJ_H_ 3 | /* 4 | Self-contained threaded object built around pthreads 5 | Originally developed at Astrobotic (https://www.astrobotic.com). Used with permission 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace std; 18 | 19 | class ThreadedObject 20 | { 21 | public: 22 | ThreadedObject(); 23 | virtual ~ThreadedObject(); 24 | pthread_t start(); 25 | void cancel(); 26 | void join(); 27 | void PutCommand(void* command); 28 | 29 | /* 30 | GetData() doesn't implement a means of making sure that a 31 | particular client got a piece of data 32 | If you expect to use multiple clients, don't use GetData() 33 | A correct implementation would use some client ID bitmap, e.g. 34 | similar to an FD_SET where in O(1) time one could check. 35 | However, that still wouldn't solve the problem of a slow client 36 | backing up the flow for others. 37 | */ 38 | 39 | void* GetData(); //polling, nonblocking 40 | 41 | void* WaitData(); //sleeps on a broadcast condvar if necessary 42 | 43 | 44 | protected: 45 | virtual void run()=0; 46 | void* GetCommand(); 47 | void PutData(void* data); 48 | int64_t GetTime(); 49 | private: 50 | deque cmdQueue; 51 | deque dataQueue; 52 | pthread_mutex_t cmdMutex; 53 | pthread_mutex_t dataMutex; 54 | pthread_cond_t dataPresent; 55 | pthread_t myThread; 56 | 57 | friend void *redirectRun(void *); 58 | 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Gladiator/icd_imu.h: -------------------------------------------------------------------------------- 1 | #ifndef __ICD_IMU_H_ 2 | #define __ICD_IMU_H_ 3 | #include 4 | 5 | /* The same imu_data_t is used for both ADIS and Gladiator output 6 | Originally developed at Astrobotic (https://www.astrobotic.com). Used with permission 7 | */ 8 | 9 | typedef struct 10 | { 11 | /*note: timespec is platform dependent, 8 bytes on ARM32, 16 on x86_64, ? on i686 12 | The idea is to use a x86_64 timespec, with the 32-bit platforms type promoted to fit 13 | */ 14 | uint64_t tv_sec; 15 | uint64_t tv_nsec; 16 | int32_t accel_x; /* Accel units are in 10000-g */ 17 | int32_t accel_y; 18 | int32_t accel_z; 19 | int32_t gyro_x; /* Gyro units are in 1000-deg/s */ 20 | int32_t gyro_y; 21 | int32_t gyro_z; 22 | int16_t temp; /* Temp is centi-deg C */ 23 | } __attribute__((packed)) imu_data_t; 24 | 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Join/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUILD_JoinIMU ON CACHE BOOL "Toggle building the Join IMU driver") 2 | if(BUILD_JoinIMU) 3 | add_to_hal_sources(JoinDriver.h JoinDriver.cpp JoinFactory.cpp) 4 | endif() 5 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Join/JoinDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace hal { 9 | 10 | class JoinDriver : public IMUDriverInterface { 11 | public: 12 | JoinDriver(const std::shared_ptr& input); 13 | virtual ~JoinDriver() {} 14 | 15 | void RegisterIMUDataCallback(IMUDriverDataCallback callback) override { 16 | callback_ = callback; 17 | } 18 | 19 | bool IsRunning() const override { 20 | return input_imu_ && input_imu_->IsRunning(); 21 | } 22 | 23 | private: 24 | void HandleIMU(hal::ImuMsg& imu); 25 | inline bool InterpolateAccel(int* gyro_index, Eigen::VectorXd* vec) const; 26 | 27 | std::shared_ptr input_imu_; 28 | IMUDriverDataCallback callback_; 29 | 30 | // The measurements themselves. Back is most recent. 31 | std::deque accels_, gyros_; 32 | 33 | // Timestamps of measurements. Back is most recent. 34 | std::deque accel_ts_, gyro_ts_; 35 | 36 | // The timestamp of the last sent message 37 | double last_sent_time_; 38 | }; 39 | 40 | } // end namespace hal 41 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Join/JoinFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "./JoinDriver.h" 3 | 4 | namespace hal { 5 | 6 | class JoinFactory : public DeviceFactory { 7 | public: 8 | JoinFactory(const std::string& name) 9 | : DeviceFactory(name) { 10 | Params() = {}; 11 | } 12 | 13 | std::shared_ptr GetDevice(const Uri& uri) { 14 | return std::shared_ptr(new JoinDriver( 15 | DeviceRegistry::Instance().Create(uri.url))); 16 | } 17 | }; 18 | 19 | // Register this factory by creating static instance of factory 20 | static JoinFactory g_JoinFactory("join"); 21 | 22 | } // end namespace hal 23 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/MicroStrain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # build the library 2 | set( MIPSDK_CPP MIPSDK/mip_sdk_user_functions.cpp MIPSDK/byteswap_utilities.cpp MIPSDK/mip_sdk_base.cpp MIPSDK/mip_sdk_gps.cpp MIPSDK/mip.cpp MIPSDK/mip_sdk_interface.cpp MIPSDK/ring_buffer.cpp MIPSDK/mip_sdk_3dm.cpp MIPSDK/mip_sdk_nav.cpp MIPSDK/mip_sdk_ahrs.cpp MIPSDK/mip_sdk_system.cpp ) 3 | set( MIPSDK_H MIPSDK/mip_sdk_user_functions.h MIPSDK/byteswap_utilities.h MIPSDK/mip.h MIPSDK/mip_sdk_config.h MIPSDK/mip_sdk_nav.h MIPSDK/mainpage.h MIPSDK/mip_sdk_3dm.h MIPSDK/mip_sdk_gps.h MIPSDK/mip_sdk_system.h MIPSDK/mip_gx3_35.h MIPSDK/mip_sdk_ahrs.h MIPSDK/mip_sdk.h MIPSDK/mip_types.h MIPSDK/mip_gx3_45.h MIPSDK/mip_gx4_45.h MIPSDK/mip_gx4_imu.h MIPSDK/mip_sdk_base.h MIPSDK/mip_sdk_interface.h MIPSDK/ring_buffer.h ) 4 | 5 | set( BUILD_MicroStrain true CACHE BOOL force ) 6 | 7 | if( BUILD_MicroStrain ) 8 | add_to_hal_sources( MicroStrainDriver.h ${MIPSDK_H} MicroStrainDriver.cpp MicroStrainFactory.cpp ${MIPSDK_CPP} ) 9 | endif() 10 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/MicroStrain/MicroStrainFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "MicroStrainDriver.h" 4 | 5 | namespace hal 6 | { 7 | 8 | class MicroStrainFactory : public DeviceFactory 9 | { 10 | public: 11 | MicroStrainFactory(const std::string& name) 12 | : DeviceFactory(name) 13 | { 14 | Params() = { 15 | {"accel", "1", "Capture accelerometer data."}, 16 | {"gyro", "1", "Capture gyro data."}, 17 | {"mag", "0", "Capture magnetometer data."}, 18 | {"gps", "0", "Capture GPS data."}, 19 | {"gpshz", "1", "GPS capture rate in Hz."}, 20 | {"imuhz", "200", "IMU capture rate in Hz."} 21 | }; 22 | } 23 | 24 | std::shared_ptr GetDevice(const Uri& uri) 25 | { 26 | bool capture_accel = uri.properties.Get("accel", true); 27 | bool capture_gyro = uri.properties.Get("gyro", true); 28 | bool capture_mag = uri.properties.Get("mag", false); 29 | bool capture_gps = uri.properties.Get("gps", false); 30 | int gps_hz = uri.properties.Get("gpshz", 1); 31 | int imu_hz = uri.properties.Get("imuhz", 200); 32 | 33 | MicroStrainDriver* pDriver = 34 | new MicroStrainDriver(uri.url, capture_accel, capture_gyro, 35 | capture_mag, capture_gps, gps_hz, imu_hz); 36 | return std::shared_ptr( pDriver ); 37 | } 38 | }; 39 | 40 | // Register this factory by creating static instance of factory 41 | static MicroStrainFactory g_MicroStrainFactory("microstrain"); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/NodeIMU/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) 2 | 3 | find_package( Node QUIET ) 4 | 5 | if( Node_FOUND ) 6 | set( BUILD_NodeIMU true CACHE BOOL force ) 7 | if( BUILD_NodeIMU ) 8 | add_to_hal_include_dirs( ${Node_INCLUDE_DIRS} ) 9 | add_to_hal_libraries( ${Node_LIBRARIES} ) 10 | add_to_hal_sources( NodeIMUDriver.h NodeIMUDriver.cpp NodeIMUFactory.cpp ) 11 | endif() 12 | endif() 13 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/NodeIMU/FindZeroMQ.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find libzmq 2 | # Once done, this will define 3 | # 4 | # ZeroMQ_FOUND - system has libzmq 5 | # ZeroMQ_INCLUDE_DIRS - the libzmq include directories 6 | # ZeroMQ_LIBRARIES - link these to use libzmq 7 | 8 | include(LibFindMacros) 9 | 10 | IF(UNIX) 11 | # Use pkg-config to get hints about paths 12 | libfind_pkg_check_modules(ZeroMQ_PKGCONF libzmq) 13 | 14 | # Include dir 15 | find_path(ZeroMQ_INCLUDE_DIR 16 | NAMES zmq.h 17 | PATHS ${ZEROMQ_ROOT}/include ${ZeroMQ_PKGCONF_INCLUDE_DIRS} 18 | ) 19 | 20 | # Finally the library itself 21 | find_library(ZeroMQ_LIBRARY 22 | NAMES zmq 23 | PATHS ${ZEROMQ_ROOT}/lib ${ZeroMQ_PKGCONF_LIBRARY_DIRS} 24 | ) 25 | ELSEIF (WIN32) 26 | find_path(ZeroMQ_INCLUDE_DIR 27 | NAMES zmq.h 28 | PATHS ${ZEROMQ_ROOT}/include ${CMAKE_INCLUDE_PATH} 29 | ) 30 | # Finally the library itself 31 | find_library(ZeroMQ_LIBRARY 32 | NAMES libzmq 33 | PATHS ${ZEROMQ_ROOT}/lib ${CMAKE_LIB_PATH} 34 | ) 35 | ENDIF() 36 | 37 | # Set the include dir variables and the libraries and let libfind_process do the rest. 38 | # NOTE: Singular variables for this library, plural for libraries this this lib depends on. 39 | set(ZeroMQ_PROCESS_INCLUDES ZeroMQ_INCLUDE_DIR ZeroMQ_INCLUDE_DIRS) 40 | set(ZeroMQ_PROCESS_LIBS ZeroMQ_LIBRARY ZeroMQ_LIBRARIES) 41 | libfind_process(ZeroMQ) 42 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/NodeIMU/NodeIMUDriver.cpp: -------------------------------------------------------------------------------- 1 | // hack to enable sleep_for (GCC < 4.8) 2 | #ifndef _GLIBCXX_USE_NANOSLEEP 3 | #define _GLIBCXX_USE_NANOSLEEP 4 | #endif // _GLIBCXX_USE_NANOSLEEP 5 | 6 | #include "NodeIMUDriver.h" 7 | 8 | using namespace hal; 9 | 10 | 11 | ///////////////////////////////////////////////////////////////////////////////////////// 12 | NodeIMUDriver::NodeIMUDriver(const std::string& sHost) 13 | : m_host(sHost), m_running(false), m_callback(nullptr) 14 | { 15 | if( m_node.subscribe(sHost+"/IMU") == false ) { 16 | std::cerr << "HAL: Error subscribing to remote node." << std::endl; 17 | } 18 | } 19 | 20 | 21 | ///////////////////////////////////////////////////////////////////////////////////////// 22 | void NodeIMUDriver::_ThreadFunc() 23 | { 24 | hal::ImuMsg pbMsg; 25 | while( m_running ) { 26 | pbMsg.Clear(); 27 | if( m_node.receive(m_host+"/IMU", pbMsg) == false ) { 28 | std::cerr << "HAL: Error reading node publisher." << std::endl; 29 | continue; 30 | } 31 | m_callback(pbMsg); 32 | } 33 | 34 | m_running = false; 35 | } 36 | 37 | ///////////////////////////////////////////////////////////////////////////////////////// 38 | NodeIMUDriver::~NodeIMUDriver() 39 | { 40 | m_running = false; 41 | if( m_callbackThread.joinable() ) { 42 | m_callbackThread.join(); 43 | } 44 | } 45 | 46 | ///////////////////////////////////////////////////////////////////////////////////////// 47 | void NodeIMUDriver::RegisterIMUDataCallback(IMUDriverDataCallback callback) 48 | { 49 | m_callback = callback; 50 | m_running = true; 51 | m_callbackThread = std::thread( &NodeIMUDriver::_ThreadFunc, this ); 52 | } 53 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/NodeIMU/NodeIMUDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | namespace hal { 10 | 11 | class NodeIMUDriver : public IMUDriverInterface 12 | { 13 | public: 14 | NodeIMUDriver(const std::string& sHost); 15 | ~NodeIMUDriver(); 16 | void RegisterIMUDataCallback(IMUDriverDataCallback callback); 17 | 18 | bool IsRunning() const override { 19 | return m_running; 20 | } 21 | 22 | private: 23 | void _ThreadFunc(); 24 | 25 | private: 26 | node::node m_node; 27 | std::string m_host; 28 | bool m_running; 29 | std::thread m_callbackThread; 30 | IMUDriverDataCallback m_callback; 31 | }; 32 | 33 | } /* namespace */ 34 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/NodeIMU/NodeIMUFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // hack to enable sleep_for (GCC < 4.8) 4 | #ifndef _GLIBCXX_USE_NANOSLEEP 5 | #define _GLIBCXX_USE_NANOSLEEP 6 | #endif // _GLIBCXX_USE_NANOSLEEP 7 | 8 | #include "NodeIMUDriver.h" 9 | 10 | namespace hal 11 | { 12 | 13 | class NodeIMUFactory : public DeviceFactory 14 | { 15 | public: 16 | NodeIMUFactory(const std::string& name) 17 | : DeviceFactory(name) 18 | { 19 | Params() = { 20 | }; 21 | } 22 | 23 | std::shared_ptr GetDevice(const Uri& uri) 24 | { 25 | NodeIMUDriver* pDriver = new NodeIMUDriver( uri.url ); 26 | return std::shared_ptr( pDriver ); 27 | } 28 | }; 29 | 30 | // Register this factory by creating static instance of factory 31 | static NodeIMUFactory g_NodeIMUFactory("node"); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/PCAN/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if( BUILD_PCAN ) 2 | add_to_hal_sources( PCANIMUDriver.h PCANIMUDriver.cpp PCANIMUFactory.cpp ) 3 | endif() 4 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/PCAN/PCANIMUDriver.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "PCANIMUDriver.h" 4 | 5 | using namespace hal; 6 | 7 | 8 | ///////////////////////////////////////////////////////////////////////////////////////// 9 | PCANIMUDriver::PCANIMUDriver(unsigned long int baudrate, const std::string& sCom) 10 | : m_PCANListener(PCANListener::GetInstance()) 11 | { 12 | m_PCANListener.Connect( baudrate, sCom ); 13 | } 14 | 15 | 16 | ///////////////////////////////////////////////////////////////////////////////////////// 17 | PCANIMUDriver::~PCANIMUDriver() 18 | { 19 | m_PCANListener.Disconnect(); 20 | } 21 | 22 | 23 | ///////////////////////////////////////////////////////////////////////////////////////// 24 | void PCANIMUDriver::RegisterIMUDataCallback(IMUDriverDataCallback Callback) 25 | { 26 | m_PCANListener.RegisterIMUCallback( Callback ); 27 | } 28 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/PCAN/PCANIMUDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | class PCANListener; 9 | namespace hal { 10 | 11 | class PCANIMUDriver : public IMUDriverInterface 12 | { 13 | public: 14 | PCANIMUDriver(unsigned long int baudrate, const std::string& sCom); 15 | ~PCANIMUDriver(); 16 | void RegisterIMUDataCallback(IMUDriverDataCallback Callback); 17 | 18 | bool IsRunning() const override { 19 | return m_PCANListener.IsRunning(); 20 | } 21 | 22 | private: 23 | PCANListener& m_PCANListener; 24 | }; 25 | 26 | } /* namespace */ 27 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/PCAN/PCANIMUFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "PCANIMUDriver.h" 4 | 5 | namespace hal 6 | { 7 | 8 | class PCANIMUFactory : public DeviceFactory 9 | { 10 | public: 11 | PCANIMUFactory(const std::string& name) 12 | : DeviceFactory(name) 13 | { 14 | Params() = { 15 | {"portname", "/dev/pcan32", "Port name such as /dev/pcan32"}, 16 | {"baudrate", "500000", "CAN Bus baudrate as 125000 or 500000 or1000000"} 17 | }; 18 | } 19 | 20 | std::shared_ptr GetDevice(const Uri& uri) 21 | { 22 | std::string portname = uri.properties.Get("portname", std::string("/dev/pcan32")); 23 | int baudrate = uri.properties.Get("baudrate", 500000); 24 | PCANIMUDriver* pDriver = new PCANIMUDriver( baudrate, portname ); 25 | return std::shared_ptr( pDriver ); 26 | } 27 | }; 28 | 29 | // Register this factory by creating static instance of factory 30 | static PCANIMUFactory g_PCANIMUFactory("pcan"); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Phidgets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) 2 | 3 | find_package( PHIDGETS QUIET ) 4 | 5 | if( PHIDGETS_FOUND ) 6 | 7 | set( BUILD_Phidgets true CACHE BOOL force ) 8 | if( BUILD_Phidgets ) 9 | 10 | add_to_hal_include_dirs( ${PHIDGETS_INCLUDE_DIR} ) 11 | add_to_hal_libraries( ${PHIDGETS_LIBRARIES} ) 12 | add_to_hal_sources( PhidgetsDriver.h PhidgetsDriver.cpp PhidgetsFactory.cpp ) 13 | endif() 14 | endif() 15 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Phidgets/FindPHIDGETS.cmake: -------------------------------------------------------------------------------- 1 | # Find the Phidgets includes and library 2 | # 3 | # This module defines 4 | # PHIDGETS_INCLUDE_DIR 5 | # PHIDGETS_LIBRARIES 6 | # PHIDGETS_FOUND 7 | 8 | find_path(PHIDGETS_INCLUDE_DIR 9 | NAMES phidget22.h 10 | PATHS 11 | /usr/local/include 12 | /usr/include 13 | /Library/Frameworks/Phidget22.framework/Headers 14 | ) 15 | 16 | find_library( PHIDGETS_LIBRARY 17 | NAMES Phidget22 18 | PATHS 19 | /usr/local/lib 20 | /usr/lib 21 | /opt/local/lib 22 | /Library/Frameworks/Phidget22.framework 23 | ) 24 | 25 | if( PHIDGETS_INCLUDE_DIR AND PHIDGETS_LIBRARY ) 26 | set( PHIDGETS_LIBRARIES ${PHIDGETS_LIBRARY} ) 27 | set( PHIDGETS_INCLUDE_DIRS ${PHIDGETS_INCLUDE_DIR} ) 28 | set( PHIDGETS_FOUND TRUE ) 29 | endif() 30 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Phidgets/PhidgetsDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace hal { 8 | 9 | void CCONV AttachHandler(PhidgetHandle spatial, void *userptr); 10 | void CCONV DetachHandler(PhidgetHandle spatial, void *userptr); 11 | void CCONV ErrorHandler(PhidgetHandle spatial, void *userptr, 12 | Phidget_ErrorEventCode ErrorCode, const char *unknown); 13 | void CCONV SpatialDataHandler(PhidgetSpatialHandle spatial, void *userptr, 14 | const double accel[3], const double angular[3], const double mag_field[3], 15 | double timestamp); 16 | 17 | class PhidgetsDriver : public IMUDriverInterface { 18 | public: 19 | PhidgetsDriver(); 20 | ~PhidgetsDriver(); 21 | bool Init(); 22 | void RegisterIMUDataCallback(IMUDriverDataCallback callback); 23 | 24 | void _AttachHandler(PhidgetHandle spatial); 25 | void _DetachHandler(PhidgetHandle spatial); 26 | void _ErrorHandler(PhidgetHandle /*spatial*/, 27 | Phidget_ErrorEventCode ErrorCode, const char *unknown); 28 | void _SpatialDataHandler(PhidgetSpatialHandle /*spatial*/, 29 | const double accel[3], const double angular[3], const double mag_field[3], 30 | double timestamp); 31 | 32 | bool IsRunning() const override { 33 | return false; 34 | } 35 | 36 | private: 37 | PhidgetSpatialHandle m_hSpatial; 38 | IMUDriverDataCallback m_ImuCallback; 39 | }; 40 | 41 | } // namespace hal 42 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/Phidgets/PhidgetsFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "PhidgetsDriver.h" 3 | 4 | namespace hal 5 | { 6 | 7 | class PhidgetsFactory : public DeviceFactory 8 | { 9 | public: 10 | PhidgetsFactory(const std::string& name) 11 | : DeviceFactory(name) 12 | { 13 | Params() = { 14 | }; 15 | } 16 | 17 | std::shared_ptr GetDevice(const Uri& /*uri*/) 18 | { 19 | PhidgetsDriver* pDriver = new PhidgetsDriver(); 20 | return std::shared_ptr( pDriver ); 21 | } 22 | }; 23 | 24 | // Register this factory by creating static instance of factory 25 | static PhidgetsFactory g_PhidgetsFactory("phidgets"); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/ProtoReader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_to_hal_sources( ProtoReaderIMUDriver.h ProtoReaderIMUDriver.cpp ProtoReaderIMUFactory.cpp ) 2 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/ProtoReader/ProtoReaderIMUDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace hal { 8 | 9 | class ProtoReaderIMUDriver : public IMUDriverInterface 10 | { 11 | public: 12 | ProtoReaderIMUDriver(std::string filename); 13 | ~ProtoReaderIMUDriver(); 14 | void RegisterIMUDataCallback(IMUDriverDataCallback callback); 15 | void RegisterIMUFinishedCallback(IMUDriverFinishedCallback callback); 16 | 17 | bool IsRunning() const override { 18 | return m_running; 19 | } 20 | 21 | private: 22 | void _ThreadFunc(); 23 | 24 | private: 25 | hal::Reader& m_reader; 26 | bool m_running; 27 | std::thread m_callbackThread; 28 | IMUDriverDataCallback m_callback; 29 | IMUDriverFinishedCallback m_IMUFinishedCallback; 30 | 31 | }; 32 | 33 | } /* namespace */ 34 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/ProtoReader/ProtoReaderIMUFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ProtoReaderIMUDriver.h" 3 | 4 | namespace hal 5 | { 6 | 7 | class ProtoReaderIMUFactory : public DeviceFactory 8 | { 9 | public: 10 | ProtoReaderIMUFactory(const std::string& name) 11 | : DeviceFactory(name) 12 | { 13 | Params() = { 14 | }; 15 | } 16 | 17 | std::shared_ptr GetDevice(const Uri& uri) 18 | { 19 | const std::string file = ExpandTildePath(uri.url); 20 | 21 | ProtoReaderIMUDriver* pDriver = new ProtoReaderIMUDriver(file); 22 | return std::shared_ptr( pDriver ); 23 | } 24 | }; 25 | 26 | // Register this factory by creating static instance of factory 27 | static ProtoReaderIMUFactory g_ProtoReaderIMUFactory1("proto"); 28 | static ProtoReaderIMUFactory g_ProtoReaderIMUFactory2("log"); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/ROSImu/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package( roscpp QUIET ) 3 | find_package( std_msgs QUIET ) 4 | if(roscpp_FOUND) 5 | 6 | set( BUILD_ROS_Imu false CACHE BOOL force ) 7 | 8 | if( BUILD_ROS_Imu) 9 | message( STATUS "HAL: building 'ROS' IMU driver.") 10 | add_to_hal_include_dirs( 11 | ${roscpp_INCLUDE_DIRS} 12 | ${std_msgs_INCLUDE_DIRS} 13 | ) 14 | 15 | add_to_hal_libraries( 16 | ${std_msgs_LIBRARIES} 17 | ${roscpp_LIBRARIES} 18 | ${PbMsgs_LIBRARIES} 19 | ) 20 | 21 | add_to_hal_sources( 22 | ROSImuDriver.cpp 23 | ROSImuFactory.cpp 24 | ) 25 | 26 | endif() 27 | endif() 28 | -------------------------------------------------------------------------------- /HAL/IMU/Drivers/ROSImu/ROSImuFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "ROSImuDriver.h" 5 | 6 | #define DEFAULT_SIZE "640x480" 7 | 8 | namespace hal 9 | { 10 | 11 | class ROSImuFactory : public DeviceFactory 12 | { 13 | public: 14 | ROSImuFactory(const std::string& name) 15 | : DeviceFactory(name) 16 | { 17 | Params() = { 18 | {"topic","/imu","Topic to subscribe to"}, 19 | }; 20 | }; 21 | 22 | 23 | std::shared_ptr GetDevice(const Uri& uri) 24 | { 25 | 26 | std::string topic = uri.properties.Get("topic", "/imu"); 27 | 28 | ROSImuDriver* rs = new ROSImuDriver(topic); 29 | return std::shared_ptr( rs ); 30 | } 31 | }; 32 | 33 | // Register this factory by creating static instance of factory 34 | static ROSImuFactory g_ROSImuFactory("ros_imu"); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /HAL/IMU/IMUDriverInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace hal { 8 | 9 | typedef std::function IMUDriverDataCallback; 10 | typedef std::function IMUDriverFinishedCallback; 11 | 12 | /// Generic IMU driver interface 13 | /// 14 | class IMUDriverInterface : public DriverInterface { 15 | public: 16 | virtual ~IMUDriverInterface() {} 17 | virtual void RegisterIMUDataCallback(IMUDriverDataCallback callback) = 0; 18 | virtual void RegisterIMUFinishedCallback(IMUDriverFinishedCallback ) {} 19 | virtual bool IsRunning() const = 0; 20 | }; 21 | 22 | } /* namespace */ 23 | -------------------------------------------------------------------------------- /HAL/LIDAR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(HDRS 2 | LIDARDevice.h 3 | LIDARDriverInterface.h 4 | ) 5 | 6 | add_to_hal_headers( ${HDRS} ) 7 | 8 | add_subdirectory( Drivers ) 9 | -------------------------------------------------------------------------------- /HAL/LIDAR/Drivers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | subdirlist(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR}) 2 | 3 | foreach(subdir ${SUBDIRS}) 4 | add_subdirectory(${subdir}) 5 | endforeach() 6 | -------------------------------------------------------------------------------- /HAL/LIDAR/Drivers/ProtoReader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_to_hal_sources( ProtoReaderLIDARDriver.h ProtoReaderLIDARDriver.cpp ProtoReaderLIDARFactory.cpp ) 2 | -------------------------------------------------------------------------------- /HAL/LIDAR/Drivers/ProtoReader/ProtoReaderLIDARDriver.cpp: -------------------------------------------------------------------------------- 1 | #include "ProtoReaderLIDARDriver.h" 2 | 3 | using namespace hal; 4 | 5 | 6 | ///////////////////////////////////////////////////////////////////////////////////////// 7 | ProtoReaderLIDARDriver::ProtoReaderLIDARDriver(std::string filename) 8 | : m_reader(hal::Reader::Instance(filename, hal::Msg_Type_LIDAR)), m_running(false), m_callback(nullptr) 9 | { 10 | } 11 | 12 | 13 | ///////////////////////////////////////////////////////////////////////////////////////// 14 | void ProtoReaderLIDARDriver::_ThreadFunc() 15 | { 16 | while( m_running ) { 17 | std::unique_ptr readmsg = m_reader.ReadLidarMsg(); 18 | if(readmsg) { 19 | m_callback( *readmsg ); 20 | } else { 21 | break; 22 | } 23 | } 24 | } 25 | 26 | ///////////////////////////////////////////////////////////////////////////////////////// 27 | ProtoReaderLIDARDriver::~ProtoReaderLIDARDriver() 28 | { 29 | m_running = false; 30 | m_reader.StopBuffering(); 31 | if( m_callbackThread.joinable() ) { 32 | m_callbackThread.join(); 33 | } 34 | } 35 | 36 | ///////////////////////////////////////////////////////////////////////////////////////// 37 | void ProtoReaderLIDARDriver::RegisterLIDARDataCallback(LIDARDriverDataCallback callback) 38 | { 39 | m_callback = callback; 40 | m_running = true; 41 | m_callbackThread = std::thread( &ProtoReaderLIDARDriver::_ThreadFunc, this ); 42 | } 43 | 44 | 45 | -------------------------------------------------------------------------------- /HAL/LIDAR/Drivers/ProtoReader/ProtoReaderLIDARDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace hal { 8 | 9 | class ProtoReaderLIDARDriver : public LIDARDriverInterface 10 | { 11 | public: 12 | ProtoReaderLIDARDriver(std::string filename); 13 | ~ProtoReaderLIDARDriver(); 14 | void RegisterLIDARDataCallback(LIDARDriverDataCallback callback); 15 | 16 | private: 17 | void _ThreadFunc(); 18 | 19 | private: 20 | hal::Reader& m_reader; 21 | bool m_running; 22 | std::thread m_callbackThread; 23 | LIDARDriverDataCallback m_callback; 24 | }; 25 | 26 | } /* namespace */ 27 | -------------------------------------------------------------------------------- /HAL/LIDAR/Drivers/ProtoReader/ProtoReaderLIDARFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ProtoReaderLIDARDriver.h" 3 | 4 | namespace hal 5 | { 6 | 7 | class ProtoReaderLIDARFactory : public DeviceFactory 8 | { 9 | public: 10 | ProtoReaderLIDARFactory(const std::string& name) 11 | : DeviceFactory(name) 12 | { 13 | Params() = { 14 | }; 15 | } 16 | 17 | std::shared_ptr GetDevice(const Uri& uri) 18 | { 19 | const std::string file = ExpandTildePath(uri.url); 20 | 21 | ProtoReaderLIDARDriver* pDriver = new ProtoReaderLIDARDriver(file); 22 | return std::shared_ptr( pDriver ); 23 | } 24 | }; 25 | 26 | // Register this factory by creating static instance of factory 27 | static ProtoReaderLIDARFactory g_ProtoReaderLIDARFactory1("proto"); 28 | static ProtoReaderLIDARFactory g_ProtoReaderLIDARFactory2("log"); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /HAL/LIDAR/Drivers/Velodyne/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) 2 | find_package( TinyXML2 QUIET ) 3 | 4 | if( TinyXML2_FOUND ) 5 | add_to_hal_sources(VelodyneDriver.h VelodyneDriver.cpp VelodyneFactory.cpp) 6 | add_to_hal_libraries(${TinyXML2_LIBRARIES}) 7 | add_to_hal_include_dirs(${TinyXML2_INCLUDE_DIRS}) 8 | endif() 9 | 10 | -------------------------------------------------------------------------------- /HAL/LIDAR/Drivers/Velodyne/FindCLAPACK.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2010 Ion Torrent Systems, Inc. All Rights Reserved 2 | 3 | include(LibFindMacros) 4 | 5 | # Dependencies 6 | #libfind_package(CLAPACK CBLAS) 7 | 8 | # Include dir 9 | find_path(CLAPACK_INCLUDE_DIR 10 | NAMES clapack.h 11 | PATHS /usr/include 12 | PATHS /usr/include/atlas 13 | ) 14 | 15 | # Finally the library itself 16 | find_library(CLAPACK_LIBRARY 17 | NAMES lapack 18 | PATHS /usr/lib /usr/lib64 /usr/lib/atlas /usr/lib64/atlas 19 | ) 20 | 21 | # Set the include dir variables and the libraries and let libfind_process do the rest. 22 | # NOTE: Singular variables for this library, plural for libraries this this lib depends on. 23 | set(CLAPACK_PROCESS_INCLUDES CLAPACK_INCLUDE_DIR CLAPACK_INCLUDE_DIRS) 24 | set(CLAPACK_PROCESS_LIBS CLAPACK_LIBRARY CLAPACK_LIBRARIES) 25 | set(CLAPACK_FIND_REQUIRED OFF) 26 | libfind_process(CLAPACK) 27 | 28 | -------------------------------------------------------------------------------- /HAL/LIDAR/Drivers/Velodyne/VelodyneDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* Header file to enable threading and ergo callback */ 4 | #include 5 | 6 | /* Header file to make it in image defined by HAL */ 7 | #include 8 | 9 | /* Header files for socket variable */ 10 | #include 11 | #include 12 | 13 | #define BUFLEN 1248 14 | 15 | namespace hal { 16 | 17 | class VelodyneDriver : public LIDARDriverInterface 18 | { 19 | public: 20 | VelodyneDriver(int port=2368); 21 | ~VelodyneDriver(); 22 | void RegisterLIDARDataCallback(LIDARDriverDataCallback callback); 23 | 24 | private: 25 | void _ThreadFunc(); 26 | 27 | private: 28 | /* Variable for HAL compatibility */ 29 | bool m_running; 30 | std::thread m_callbackThread; 31 | LIDARDriverDataCallback m_callback; 32 | 33 | /* Velodyne specific Variables */ 34 | int m_port; 35 | int m_socketDescriptor; 36 | }; 37 | 38 | } /* namespace */ 39 | -------------------------------------------------------------------------------- /HAL/LIDAR/Drivers/Velodyne/VelodyneFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "VelodyneDriver.h" 4 | 5 | namespace hal 6 | { 7 | 8 | class VelodyneFactory : public DeviceFactory 9 | { 10 | public: 11 | VelodyneFactory(const std::string& name) 12 | : DeviceFactory(name) 13 | { 14 | Params() = { 15 | }; 16 | } 17 | 18 | std::shared_ptr GetDevice(const Uri& /*uri*/) 19 | { 20 | VelodyneDriver* pDriver = new VelodyneDriver(); 21 | return std::shared_ptr( pDriver ); 22 | } 23 | }; 24 | 25 | // Register this factory by creating static instance of factory 26 | static VelodyneFactory g_VelodyneFactory("velodyne"); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /HAL/LIDAR/LIDARDriverInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | 10 | namespace hal { 11 | 12 | typedef std::function LIDARDriverDataCallback; 13 | 14 | /////////////////////////////////////////////////////////////////////////////// 15 | /// Generic LIDAR driver interface 16 | class LIDARDriverInterface : public DriverInterface 17 | { 18 | public: 19 | // Pure virtual functions driver writers must implement: 20 | virtual ~LIDARDriverInterface() {} 21 | virtual void RegisterLIDARDataCallback(LIDARDriverDataCallback callback) = 0; 22 | }; 23 | 24 | } /* namespace */ 25 | -------------------------------------------------------------------------------- /HAL/Messages/Camera.proto: -------------------------------------------------------------------------------- 1 | package hal; 2 | 3 | import "Image.proto"; 4 | 5 | message CameraMsg { 6 | optional int32 id = 1; 7 | optional double device_time = 2; 8 | repeated ImageMsg image = 3; 9 | optional double system_time = 4; 10 | } 11 | -------------------------------------------------------------------------------- /HAL/Messages/CameraModel.proto: -------------------------------------------------------------------------------- 1 | package hal; 2 | 3 | import "Pose.proto"; 4 | import "Matrix.proto"; 5 | 6 | message CameraModelMsg { 7 | optional string name = 1; 8 | optional int32 index = 2; 9 | optional int64 serial_number = 3; 10 | optional uint32 version = 4; 11 | optional uint32 width = 5; 12 | optional uint32 height = 6; 13 | optional PoseMsg pose_local_camera = 7; 14 | optional VectorMsg params = 8; 15 | optional string type = 9; 16 | } 17 | -------------------------------------------------------------------------------- /HAL/Messages/Car.proto: -------------------------------------------------------------------------------- 1 | package hal; 2 | 3 | import "Matrix.proto"; 4 | 5 | message CarStateMsg{ 6 | optional double steer_angle= 1; 7 | optional double rear_steer_angle = 2; 8 | optional int32 motor_current = 3; 9 | optional int32 batt_volt =4; 10 | optional double wheel_speed_fl = 5; 11 | optional double wheel_speed_fr = 6; 12 | optional double wheel_speed_rl = 7; 13 | optional double wheel_speed_rr = 8; 14 | optional double swing_angle_fl = 9; 15 | optional double swing_angle_fr = 10; 16 | optional double swing_angle_rl = 11; 17 | optional double swing_angle_rr = 12; 18 | optional int32 device_time = 13; 19 | } 20 | 21 | message CarCommandMsg{ 22 | optional double steering_angle = 1; 23 | optional double rear_steering_angle = 2; 24 | optional double throttle_percent = 3; 25 | optional int32 device_time = 4; 26 | } 27 | 28 | message CarSettingMsg{ 29 | optional int32 max_acc_limit = 1; 30 | } 31 | -------------------------------------------------------------------------------- /HAL/Messages/Command.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace hal { 7 | 8 | inline void ReadCommand( const CommanderMsg &msg, int* worldId, double* force, double* curvature, Eigen::Vector3d* vec, double* forceDt, double* phi, bool* noDelay, bool* noUpdate ) 9 | { 10 | *worldId = (int)msg.worldid(); 11 | *force = msg.force(); 12 | *curvature = msg.curvature(); 13 | 14 | // Torques 15 | vec->resize( msg.torques().data_size() ); 16 | for ( int ii = 0; ii < msg.torques().data_size(); ii++ ) 17 | { vec->operator()(ii) = msg.torques().data(ii); } 18 | 19 | *forceDt = msg.forcedt(); 20 | *phi = msg.phi(); 21 | *noDelay = msg.nodelay(); 22 | *noUpdate = msg.noupdate(); 23 | } 24 | 25 | inline void WriteCommand( const int &worldId, const double &force, const double &curvature, const Eigen::Vector3d &vec, const double &forceDt, const double &phi, const bool &noDelay, const bool &noUpdate, CommanderMsg *msg ) 26 | { 27 | msg->set_worldid(worldId); 28 | msg->set_force(force); 29 | msg->set_curvature(curvature); 30 | 31 | // Torques 32 | msg->mutable_torques()->mutable_data()->Reserve( vec.rows() ); 33 | for ( int ii = 0; ii < vec.rows(); ii++ ) 34 | { msg->mutable_torques()->add_data(vec(ii)); } 35 | 36 | msg->set_forcedt(forceDt); 37 | msg->set_phi(phi); 38 | msg->set_nodelay(noDelay); 39 | msg->set_noupdate(noUpdate); 40 | } 41 | 42 | } // nampespace hal 43 | -------------------------------------------------------------------------------- /HAL/Messages/Command.proto: -------------------------------------------------------------------------------- 1 | package hal; 2 | 3 | import "Matrix.proto"; 4 | 5 | message CommanderMsg { 6 | required int32 worldId = 1; 7 | 8 | // Commands 9 | required double force = 2; 10 | required double curvature = 3; 11 | required VectorMsg torques = 4; 12 | required double forceDt = 5; 13 | required double phi = 6; 14 | 15 | required bool noDelay = 7; 16 | required bool noUpdate = 8; 17 | } -------------------------------------------------------------------------------- /HAL/Messages/Gamepad.proto: -------------------------------------------------------------------------------- 1 | package hal; 2 | 3 | import "Matrix.proto"; 4 | 5 | message GamepadMsg{ 6 | optional int32 device_id = 1; 7 | optional int32 vendor_id = 2; 8 | optional int32 product_id = 3; 9 | optional int32 num_buttons = 4; 10 | optional int32 num_axes = 5; 11 | optional double system_time = 6; 12 | optional VectorMsg buttons = 7; 13 | optional VectorMsg axes = 8; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /HAL/Messages/Header.proto: -------------------------------------------------------------------------------- 1 | package hal; 2 | 3 | import "CameraModel.proto"; 4 | 5 | message Header { 6 | required uint32 version = 1; 7 | optional double date = 2; 8 | optional string description = 3; 9 | optional CameraModelMsg camera_model = 5; 10 | } 11 | -------------------------------------------------------------------------------- /HAL/Messages/Image.proto: -------------------------------------------------------------------------------- 1 | package hal; 2 | 3 | 4 | message ImageInfoMsg { 5 | optional double exposure = 1; 6 | optional double shutter = 2; 7 | optional double gain = 3; 8 | optional double gamma = 4; 9 | optional double baseline = 50; 10 | optional double focal_length = 51; 11 | } 12 | 13 | enum Type { 14 | PB_BYTE = 0x1400; 15 | PB_UNSIGNED_BYTE = 0x1401; 16 | PB_SHORT = 0x1402; 17 | PB_UNSIGNED_SHORT = 0x1403; 18 | PB_INT = 0x1404; 19 | PB_UNSIGNED_INT = 0x1405; 20 | PB_FLOAT = 0x1406; 21 | PB_DOUBLE = 0x140A; 22 | } 23 | 24 | enum Format { 25 | PB_LUMINANCE = 0x1909; 26 | PB_RGB = 0x1907; 27 | PB_RGBA = 0x1908; 28 | PB_RAW = 0x0001; 29 | PB_BGR = 0x80E0; 30 | PB_BGRA = 0x80E1; 31 | } 32 | 33 | message ImageMsg { 34 | optional uint32 width = 1; 35 | optional uint32 height = 2; 36 | optional bytes data = 3; 37 | optional Type type = 4 [default = PB_UNSIGNED_BYTE]; 38 | optional Format format = 5 [default = PB_RGB]; 39 | optional double timestamp = 6; 40 | optional ImageInfoMsg info = 7; 41 | optional uint64 serial_number = 8; 42 | } 43 | -------------------------------------------------------------------------------- /HAL/Messages/ImageArray.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace hal { 9 | 10 | class ImageArray : public std::enable_shared_from_this { 11 | public: 12 | static std::shared_ptr Create() { 13 | return std::shared_ptr(new ImageArray); 14 | } 15 | 16 | CameraMsg& Ref() { 17 | return message_; 18 | } 19 | 20 | int Size() const { 21 | return message_.image_size(); 22 | } 23 | 24 | bool Empty() const { 25 | return message_.image_size() == 0; 26 | } 27 | 28 | double Timestamp() const { 29 | return message_.device_time(); 30 | } 31 | 32 | double DeviceTime() const { 33 | return message_.device_time(); 34 | } 35 | 36 | double SystemTime() const { 37 | return message_.system_time(); 38 | } 39 | 40 | std::shared_ptr at(int idx) const { 41 | if (idx < Size()) { 42 | return std::make_shared(message_.image(idx), shared_from_this()); 43 | } 44 | 45 | // TODO: define ensure macro or throw exception 46 | std::cerr << "HAL Error: Channel index '" << idx 47 | << "' out of bounds: did you split the image stream?" 48 | << std::endl; 49 | exit(1); 50 | } 51 | 52 | std::shared_ptr operator[](int idx) const { 53 | return at(idx); 54 | } 55 | 56 | private: 57 | ImageArray() {} 58 | CameraMsg message_; 59 | }; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /HAL/Messages/Imu.proto: -------------------------------------------------------------------------------- 1 | package hal; 2 | 3 | import "Matrix.proto"; 4 | 5 | message ImuMsg{ 6 | optional int32 id = 1; 7 | optional double device_time = 2; 8 | optional double system_time = 3; 9 | optional VectorMsg accel = 4; 10 | optional VectorMsg gyro = 5; 11 | optional VectorMsg mag = 6; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /HAL/Messages/Lidar.proto: -------------------------------------------------------------------------------- 1 | package hal; 2 | 3 | import "Matrix.proto"; 4 | 5 | message LidarMsg{ 6 | optional int32 id = 1; 7 | optional double device_time = 2; 8 | optional double system_time = 3; 9 | optional MatrixMsg distance = 4; 10 | optional MatrixMsg intensity = 5; 11 | optional VectorMsg rotational_position = 6; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /HAL/Messages/Logger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace hal { 14 | 15 | class Logger { 16 | public: 17 | static Logger& GetInstance(); 18 | 19 | Logger(); 20 | ~Logger(); 21 | 22 | /** Create a new log in the given directory of the format sPrefix_. 23 | * 24 | * is increased by one for every new log file. 25 | */ 26 | std::string LogToFile(const std::string &sLogDir, const std::string &sPrefix); 27 | 28 | /** Write a log to this specific file, overwriting any previous file. */ 29 | void LogToFile(const std::string &fileName); 30 | void StopLogging(); 31 | bool IsLogging(); 32 | void SetMaxBufferSize( unsigned int nBufferSize ); 33 | size_t buffer_size() const; 34 | size_t messages_written() const; 35 | 36 | bool LogMessage(const hal::Msg& message); 37 | 38 | private: 39 | void ThreadFunc(); 40 | 41 | private: 42 | std::list m_qMessages; 43 | std::mutex m_QueueMutex; 44 | std::condition_variable m_QueueCondition; 45 | std::string m_sFilename; 46 | bool m_bShouldRun; 47 | unsigned int m_nMaxBufferSize; 48 | std::thread m_WriteThread; 49 | std::atomic m_nMessagesWritten; 50 | }; 51 | 52 | } /* namespace */ 53 | -------------------------------------------------------------------------------- /HAL/Messages/Matrix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace hal { 7 | 8 | inline void ReadMatrix(const MatrixMsg &msg, Eigen::MatrixXd* mat) { 9 | mat->resize(msg.rows(),msg.data_size()/msg.rows()); 10 | for(int ii = 0 ; ii < msg.data_size() ; ii++){ 11 | mat->operator()(ii) = msg.data(ii); 12 | } 13 | } 14 | 15 | inline void ReadVector(const VectorMsg &msg, Eigen::VectorXd* vec) { 16 | vec->resize(msg.data_size()); 17 | for(int ii = 0 ; ii < msg.data_size() ; ii++){ 18 | vec->operator()(ii) = msg.data(ii); 19 | } 20 | } 21 | 22 | inline void WriteMatrix(const Eigen::MatrixXd &mat, MatrixMsg *msg) { 23 | msg->set_rows(mat.rows()); 24 | msg->mutable_data()->Reserve(mat.rows()*mat.cols()); 25 | for(int ii = 0 ; ii < mat.cols()*mat.rows() ; ii++){ 26 | msg->add_data(mat(ii)); 27 | } 28 | } 29 | 30 | inline void WriteVector(const Eigen::VectorXd &mat, VectorMsg *msg) { 31 | msg->mutable_data()->Reserve(mat.rows()); 32 | for(int ii = 0 ; ii < mat.rows() ; ii++){ 33 | msg->add_data(mat(ii)); 34 | } 35 | } 36 | 37 | } // namespace hal 38 | -------------------------------------------------------------------------------- /HAL/Messages/Matrix.proto: -------------------------------------------------------------------------------- 1 | package hal; 2 | 3 | message MatrixMsg { 4 | required uint32 rows = 1; 5 | // columns deduced by division. Data stored as column major 6 | repeated double data = 2 [packed=true]; 7 | } 8 | 9 | message VectorMsg { 10 | repeated double data = 1 [packed=true]; 11 | } 12 | 13 | message VectorMsgInt32 { 14 | repeated int32 data = 1 [packed=true]; 15 | } 16 | -------------------------------------------------------------------------------- /HAL/Messages/Messages.proto: -------------------------------------------------------------------------------- 1 | package hal; 2 | 3 | import "Camera.proto"; 4 | import "Imu.proto"; 5 | import "Pose.proto"; 6 | import "Lidar.proto"; 7 | import "Gamepad.proto"; 8 | import "Command.proto"; 9 | import "Car.proto"; 10 | 11 | message Msg { 12 | optional double timestamp = 1; 13 | optional CameraMsg camera = 2; 14 | optional ImuMsg imu = 3; 15 | optional PoseMsg pose = 4; 16 | optional LidarMsg lidar = 5; 17 | optional GamepadMsg gamepad = 6; 18 | optional CommanderMsg command = 7; 19 | optional CarStateMsg vehicle_state = 8; 20 | } 21 | -------------------------------------------------------------------------------- /HAL/Messages/NodeCamMessage.proto: -------------------------------------------------------------------------------- 1 | message RegisterNodeCamReqMsg 2 | { 3 | optional bytes uri =1; 4 | } 5 | 6 | message RegisterNodeCamRepMsg 7 | { 8 | optional int32 time_step = 1; 9 | optional int32 regsiter_flag = 2; 10 | optional int32 width = 3; 11 | optional int32 height = 4; 12 | optional int32 channels = 5; 13 | } 14 | 15 | message CamMsg 16 | { 17 | repeated ImageMsg image = 1; 18 | required int32 time_step = 2; 19 | optional int32 size = 3; 20 | } 21 | 22 | message ImageMsg 23 | { 24 | optional bytes image = 1; 25 | optional int32 image_type = 2; 26 | optional int32 image_height = 3; 27 | optional int32 image_width = 4; 28 | } 29 | -------------------------------------------------------------------------------- /HAL/Messages/Pose.h: -------------------------------------------------------------------------------- 1 | #ifndef POSE_H 2 | #define POSE_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace hal { 9 | 10 | template 11 | void WritePoseSE3(const Sophus::SE3Group& pose, PoseMsg* msg) { 12 | msg->set_type(hal::PoseMsg_Type_SE3); 13 | 14 | Eigen::Matrix vec( 15 | Sophus::Map >(pose.data())); 16 | WriteVector(vec.template cast(), msg->mutable_pose()); 17 | } 18 | 19 | template 20 | void ReadPoseSE3(const PoseMsg &msg, Sophus::SE3Group* pose) { 21 | *pose = Sophus::SE3d(Eigen::Map( 22 | msg.pose().data().data())).template cast(); 23 | } 24 | 25 | } 26 | 27 | #endif // POSE_H 28 | -------------------------------------------------------------------------------- /HAL/Messages/Pose.proto: -------------------------------------------------------------------------------- 1 | package hal; 2 | 3 | import "Matrix.proto"; 4 | 5 | message PoseMsg { 6 | enum Type { 7 | SO2 = 1; // stored as a 1d vector [t] 8 | SE2 = 2; // stored as a 3d vector [xy|t] 9 | SO3 = 3; // stored as a 4d vector [ijkw] 10 | SE3 = 4; // stored as a 7d vector [ijkw|xyz] 11 | LatLongAlt = 5; // WGS84. stored as 3d vector [lat lon alt] 12 | Euler = 6; // stored as a 6d vector [pqr|xyz] 13 | RAW = 9; // independent user specific format 14 | } 15 | 16 | optional int32 id = 1; 17 | optional double device_time = 2; 18 | required Type type = 3; 19 | optional VectorMsg pose = 4; // format dependent on type 20 | 21 | // position covariance. Ordered as the pose data is. 22 | optional MatrixMsg covariance = 5; 23 | 24 | optional double system_time = 6; 25 | } 26 | -------------------------------------------------------------------------------- /HAL/Messages/PoseSensor.proto: -------------------------------------------------------------------------------- 1 | package hal; 2 | 3 | import "Pose.proto"; 4 | 5 | message PoseSensorMsg{ 6 | optional int32 id = 1; 7 | optional double deviceTime = 2; 8 | optional PoseMsg pose = 3; 9 | } 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /HAL/Posys/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(HDRS 2 | PosysDevice.h 3 | PosysDriverInterface.h 4 | ) 5 | 6 | add_to_hal_headers( ${HDRS} ) 7 | 8 | add_subdirectory( Drivers ) 9 | -------------------------------------------------------------------------------- /HAL/Posys/Drivers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | subdirlist(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR}) 2 | 3 | foreach(subdir ${SUBDIRS}) 4 | add_subdirectory(${subdir}) 5 | endforeach() 6 | -------------------------------------------------------------------------------- /HAL/Posys/Drivers/Csv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # build the library 2 | set( BUILD_Csv_Posys true CACHE BOOL force ) 3 | 4 | if( BUILD_Csv_Posys ) 5 | add_to_hal_sources( CsvPosysDriver.h CsvPosysDriver.cpp CsvPosysFactory.cpp ) 6 | endif() 7 | -------------------------------------------------------------------------------- /HAL/Posys/Drivers/Csv/CsvPosysDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | namespace hal { 9 | 10 | class CsvPosysDriver : public PosysDriverInterface 11 | { 12 | public: 13 | CsvPosysDriver(const std::string sFile); 14 | ~CsvPosysDriver(); 15 | 16 | void RegisterPosysDataCallback(PosysDriverDataCallback callback); 17 | void RegisterPosysFinishedCallback(PosysDriverFinishedCallback callback); 18 | bool IsRunning() const override { 19 | return m_bShouldRun; 20 | } 21 | 22 | private: 23 | void _ThreadCaptureFunc(); 24 | bool _GetNextTime( double& dNextTime, double& dNextTimePPS ); 25 | 26 | std::ifstream m_pFile; 27 | volatile bool m_bShouldRun; 28 | double m_dNextTime; 29 | double m_dNextTimePPS; 30 | std::thread m_DeviceThread; 31 | PosysDriverDataCallback m_PosysCallback; 32 | PosysDriverFinishedCallback m_PosysFinishedCallback; 33 | }; 34 | 35 | } /* namespace */ 36 | -------------------------------------------------------------------------------- /HAL/Posys/Drivers/Csv/CsvPosysFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "CsvPosysDriver.h" 10 | 11 | namespace hal 12 | { 13 | 14 | class CsvPosysFactory : public DeviceFactory 15 | { 16 | public: 17 | CsvPosysFactory(const std::string& name) 18 | : DeviceFactory(name) 19 | { 20 | Params() = { 21 | }; 22 | } 23 | 24 | std::shared_ptr GetDevice(const Uri& uri) 25 | { 26 | const std::string sDataSourceDir = hal::ExpandTildePath(uri.url); 27 | const int nObjectId = uri.properties.Get("id", 0); 28 | 29 | std::stringstream filename; 30 | filename << sDataSourceDir; 31 | if (hal::IsDir(sDataSourceDir)) { 32 | filename << "/object" << std::setw(2) << std::setfill('0') 33 | << nObjectId << ".csv"; 34 | } 35 | 36 | CsvPosysDriver* pDriver = new CsvPosysDriver(filename.str()); 37 | return std::shared_ptr( pDriver ); 38 | } 39 | }; 40 | 41 | // Register this factory by creating static instance of factory 42 | static CsvPosysFactory g_CsvPosysFactory("csv"); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /HAL/Posys/Drivers/MicroStrain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if( BUILD_MicroStrain ) 2 | add_to_hal_sources( MicroStrainPosysDriver.h MicroStrainPosysDriver.cpp MicroStrainPosysFactory.cpp ) 3 | endif() 4 | -------------------------------------------------------------------------------- /HAL/Posys/Drivers/MicroStrain/MicroStrainPosysDriver.cpp: -------------------------------------------------------------------------------- 1 | #include "MicroStrainPosysDriver.h" 2 | 3 | #include 4 | 5 | using namespace hal; 6 | 7 | 8 | ///////////////////////////////////////////////////////////////////////////////////////// 9 | MicroStrainPosysDriver::MicroStrainPosysDriver() 10 | { 11 | } 12 | 13 | ///////////////////////////////////////////////////////////////////////////////////////// 14 | MicroStrainPosysDriver::~MicroStrainPosysDriver() 15 | { 16 | } 17 | 18 | ///////////////////////////////////////////////////////////////////////////////////////// 19 | void MicroStrainPosysDriver::RegisterPosysDataCallback(PosysDriverDataCallback callback) 20 | { 21 | MicroStrainDriver::RegisterPosysDataCallback(callback); 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /HAL/Posys/Drivers/MicroStrain/MicroStrainPosysDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace hal { 8 | 9 | class MicroStrainPosysDriver : public PosysDriverInterface 10 | { 11 | public: 12 | MicroStrainPosysDriver(); 13 | ~MicroStrainPosysDriver(); 14 | void RegisterPosysDataCallback(PosysDriverDataCallback callback); 15 | bool IsRunning() const override { 16 | return true; 17 | } 18 | }; 19 | 20 | } /* namespace */ 21 | -------------------------------------------------------------------------------- /HAL/Posys/Drivers/MicroStrain/MicroStrainPosysFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "MicroStrainPosysDriver.h" 4 | 5 | namespace hal 6 | { 7 | 8 | class MicroStrainPosysFactory : public DeviceFactory 9 | { 10 | public: 11 | MicroStrainPosysFactory(const std::string& name) 12 | : DeviceFactory(name) 13 | { 14 | Params() = { 15 | }; 16 | } 17 | 18 | std::shared_ptr GetDevice(const Uri& /*uri*/) 19 | { 20 | MicroStrainPosysDriver* pDriver = new MicroStrainPosysDriver(); 21 | return std::shared_ptr( pDriver ); 22 | } 23 | }; 24 | 25 | // Register this factory by creating static instance of factory 26 | static MicroStrainPosysFactory g_MicroStrainPosysFactory2("microstrain"); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /HAL/Posys/Drivers/ProtoReader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_to_hal_sources( ProtoReaderPosysDriver.h ProtoReaderPosysDriver.cpp ProtoReaderPosysFactory.cpp ) 2 | -------------------------------------------------------------------------------- /HAL/Posys/Drivers/ProtoReader/ProtoReaderPosysDriver.cpp: -------------------------------------------------------------------------------- 1 | #include "ProtoReaderPosysDriver.h" 2 | 3 | using namespace hal; 4 | 5 | 6 | ///////////////////////////////////////////////////////////////////////////////////////// 7 | ProtoReaderPosysDriver::ProtoReaderPosysDriver(std::string filename) 8 | : m_reader(hal::Reader::Instance(filename,hal::Msg_Type_Posys)), m_running(false), m_callback(nullptr) 9 | { 10 | } 11 | 12 | 13 | ///////////////////////////////////////////////////////////////////////////////////////// 14 | void ProtoReaderPosysDriver::_ThreadFunc() 15 | { 16 | while( m_running ) { 17 | std::unique_ptr readmsg = m_reader.ReadPoseMsg(); 18 | if(readmsg) { 19 | m_callback( *readmsg ); 20 | } else { 21 | break; 22 | } 23 | } 24 | m_running = false; 25 | } 26 | 27 | ///////////////////////////////////////////////////////////////////////////////////////// 28 | ProtoReaderPosysDriver::~ProtoReaderPosysDriver() 29 | { 30 | m_running = false; 31 | m_reader.StopBuffering(); 32 | m_callbackThread.join(); 33 | } 34 | 35 | ///////////////////////////////////////////////////////////////////////////////////////// 36 | void ProtoReaderPosysDriver::RegisterPosysDataCallback(PosysDriverDataCallback callback) 37 | { 38 | m_callback = callback; 39 | m_running = true; 40 | m_callbackThread = std::thread( &ProtoReaderPosysDriver::_ThreadFunc, this ); 41 | } 42 | -------------------------------------------------------------------------------- /HAL/Posys/Drivers/ProtoReader/ProtoReaderPosysDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace hal { 8 | 9 | class ProtoReaderPosysDriver : public PosysDriverInterface 10 | { 11 | public: 12 | ProtoReaderPosysDriver(std::string filename); 13 | ~ProtoReaderPosysDriver(); 14 | void RegisterPosysDataCallback(PosysDriverDataCallback callback); 15 | bool IsRunning() const override { 16 | return m_running; 17 | } 18 | 19 | private: 20 | void _ThreadFunc(); 21 | 22 | private: 23 | hal::Reader& m_reader; 24 | bool m_running; 25 | std::thread m_callbackThread; 26 | PosysDriverDataCallback m_callback; 27 | }; 28 | 29 | } /* namespace */ 30 | -------------------------------------------------------------------------------- /HAL/Posys/Drivers/ProtoReader/ProtoReaderPosysFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ProtoReaderPosysDriver.h" 4 | 5 | namespace hal 6 | { 7 | 8 | class ProtoReaderPosysFactory : public DeviceFactory 9 | { 10 | public: 11 | ProtoReaderPosysFactory(const std::string& name) 12 | : DeviceFactory(name) 13 | { 14 | Params() = { 15 | }; 16 | } 17 | 18 | std::shared_ptr GetDevice(const Uri& uri) 19 | { 20 | const std::string file = ExpandTildePath(uri.url); 21 | 22 | ProtoReaderPosysDriver* pDriver = new ProtoReaderPosysDriver(file); 23 | return std::shared_ptr( pDriver ); 24 | } 25 | }; 26 | 27 | // Register this factory by creating static instance of factory 28 | static ProtoReaderPosysFactory g_ProtoReaderPosysFactory1("proto"); 29 | static ProtoReaderPosysFactory g_ProtoReaderPosysFactory2("log"); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /HAL/Posys/Drivers/Vicon/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) 2 | 3 | find_package( VRPN QUIET ) 4 | 5 | if( VRPN_FOUND ) 6 | set( BUILD_Vicon true CACHE BOOL force ) 7 | 8 | if( BUILD_Vicon ) 9 | add_to_hal_include_dirs( ${VRPN_INCLUDE_DIR} ) 10 | add_to_hal_libraries( ${VRPN_LIBRARIES} ) 11 | add_to_hal_sources( ViconDriver.h ViconDriver.cpp ViconFactory.cpp ) 12 | endif() 13 | endif() 14 | -------------------------------------------------------------------------------- /HAL/Posys/Drivers/Vicon/ViconDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | namespace hal { 10 | 11 | 12 | class ViconDriver : public PosysDriverInterface 13 | { 14 | public: 15 | ViconDriver(std::string sHost, std::string sTrackedObjs); 16 | ~ViconDriver(); 17 | void RegisterPosysDataCallback(PosysDriverDataCallback callback); 18 | 19 | bool IsRunning() const override { 20 | return m_bRunning; 21 | } 22 | 23 | private: 24 | static void _ThreadFunction(ViconDriver *pVT); 25 | static void VRPN_CALLBACK _ViconHandler(void* uData, const vrpn_TRACKERCB tData); 26 | 27 | private: 28 | PosysDriverDataCallback m_Callback; 29 | 30 | struct TrackerObject 31 | { 32 | std::string m_sName; 33 | unsigned int m_nId; 34 | vrpn_Tracker_Remote* m_pTracker; 35 | ViconDriver* m_pViconDriver; 36 | }; 37 | 38 | std::map< std::string, TrackerObject > m_mObjects; 39 | vrpn_Connection* m_pViconConnection; 40 | 41 | bool m_bRunning; 42 | std::thread* m_pThread; 43 | 44 | }; 45 | 46 | } /* namespace */ 47 | -------------------------------------------------------------------------------- /HAL/Posys/Drivers/Vicon/ViconFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ViconDriver.h" 4 | 5 | namespace hal 6 | { 7 | 8 | class ViconFactory : public DeviceFactory 9 | { 10 | public: 11 | ViconFactory(const std::string& name) 12 | : DeviceFactory(name) 13 | { 14 | Params() = { 15 | }; 16 | } 17 | 18 | std::shared_ptr GetDevice(const Uri& uri) 19 | { 20 | std::vector Splitter = Split(uri.url, ':'); 21 | 22 | if( Splitter.size() != 2 ) { 23 | return nullptr; 24 | } 25 | 26 | ViconDriver* pDriver = new ViconDriver( Splitter[0], Splitter[1] ); 27 | return std::shared_ptr( pDriver ); 28 | } 29 | }; 30 | 31 | // Register this factory by creating static instance of factory 32 | static ViconFactory g_ViconFactory("vicon"); 33 | 34 | 35 | // format: vicon://:[] 36 | // example: vicon://10.0.0.1:[Car,Boat] 37 | 38 | } 39 | -------------------------------------------------------------------------------- /HAL/Posys/PosysDevice.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace hal { 10 | 11 | /// 12 | /// Generic Positioning System Device 13 | class Posys : public PosysDriverInterface { 14 | public: 15 | Posys() {} 16 | 17 | Posys(const std::string& uri) : m_URI(uri) { 18 | m_Posys = DeviceRegistry::Instance().Create(m_URI); 19 | } 20 | 21 | ~Posys() { 22 | Clear(); 23 | } 24 | 25 | void Clear() { 26 | m_Posys = nullptr; 27 | } 28 | 29 | void RegisterPosysDataCallback(PosysDriverDataCallback callback) { 30 | if (m_Posys) { 31 | m_Posys->RegisterPosysDataCallback(callback); 32 | } else { 33 | std::cerr << "ERROR: no driver initialized!\n"; 34 | } 35 | } 36 | 37 | void RegisterPosysFinishedCallback(PosysDriverFinishedCallback callback) { 38 | if (m_Posys) { 39 | m_Posys->RegisterPosysFinishedCallback(callback); 40 | } else { 41 | std::cerr << "ERROR: no driver initialized!\n"; 42 | } 43 | } 44 | 45 | std::string GetDeviceProperty(const std::string& sProperty) { 46 | return m_Posys->GetDeviceProperty(sProperty); 47 | } 48 | 49 | bool IsRunning() const override { 50 | return m_Posys && m_Posys->IsRunning(); 51 | } 52 | 53 | protected: 54 | hal::Uri m_URI; 55 | std::shared_ptr m_Posys; 56 | 57 | }; 58 | 59 | } /* namespace */ 60 | -------------------------------------------------------------------------------- /HAL/Posys/PosysDriverInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | 10 | namespace hal { 11 | 12 | typedef std::function PosysDriverDataCallback; 13 | typedef std::function PosysDriverFinishedCallback; 14 | 15 | /// 16 | /// Generic Posys Driver Interface 17 | class PosysDriverInterface : public DriverInterface { 18 | public: 19 | virtual ~PosysDriverInterface() {} 20 | virtual void RegisterPosysDataCallback(PosysDriverDataCallback callback) = 0; 21 | virtual void RegisterPosysFinishedCallback(PosysDriverFinishedCallback ) {} 22 | virtual bool IsRunning() const = 0; 23 | }; 24 | 25 | } /* namespace hal */ 26 | -------------------------------------------------------------------------------- /HAL/ThirdParty/.gitignore: -------------------------------------------------------------------------------- 1 | ThirdParty -------------------------------------------------------------------------------- /HAL/ThirdParty/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Git) 2 | if(GIT_FOUND) 3 | include(ExternalProject) 4 | ExternalProject_Add(ThirdPartyHAL 5 | GIT_REPOSITORY arpg@arpg-web.colorado.edu:git/ThirdPartyHAL 6 | CONFIGURE_COMMAND cmake -E copy_directory . ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty 7 | BUILD_COMMAND "" 8 | INSTALL_COMMAND "" 9 | BUILD_IN_SOURCE ON 10 | ) 11 | set_target_properties(ThirdPartyHAL PROPERTIES EXCLUDE_FROM_ALL ON) 12 | endif() 13 | 14 | if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty) 15 | # Internal variable. 16 | set(HAL_HAVE_THIRDPARTY 1 CACHE INTERNAL "ThirdParty Flag" FORCE) 17 | set(HAL_THIRDPARTY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty" CACHE INTERNAL "ThirdParty Flag" FORCE) 18 | 19 | # List defines here to be set in the ThirdPartyConfig.h file. 20 | set(HAL_HAVE_TMIX 1 CACHE INTERNAL "ThirdPartyConfig.h Definition" FORCE) 21 | set(HAL_HAVE_LEXUSISF12 1 CACHE INTERNAL "ThirdPartyConfig.h Definition" FORCE) 22 | 23 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) 24 | add_subdirectory(ThirdParty) 25 | endif() 26 | 27 | configure_file( 28 | ${CMAKE_CURRENT_SOURCE_DIR}/ThirdPartyConfig.h.in 29 | ${CMAKE_CURRENT_BINARY_DIR}/ThirdPartyConfig.h) 30 | -------------------------------------------------------------------------------- /HAL/ThirdParty/ThirdPartyConfig.h.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #cmakedefine HAL_HAVE_TMIX 4 | #cmakedefine HAL_HAVE_LEXUSISF12 5 | -------------------------------------------------------------------------------- /HAL/Utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(HDRS 2 | GetPot 3 | PropertyMap.h 4 | StringUtils.h 5 | TicToc.h 6 | Uri.h 7 | ) 8 | 9 | add_to_hal_headers( ${HDRS} ) 10 | 11 | -------------------------------------------------------------------------------- /HAL/config.h.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define HAL_VERSION @HAL_VERSION@ 4 | #define Messages_VERSION @Messages_VERSION@ 5 | 6 | #include 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2013 Autonomous Robotics & Perception Group 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | HAL is a Hardware Abstraction Layer library that provides a simple unified 2 | interface to common functionality. Contains devices and associated device 3 | drivers like cameras, IMUs, GPS, etc. 4 | 5 | Feel free to report any bugs or issues at our GitHub portal. You can find us at: 6 | http://github.com/arpg/ 7 | 8 | Active Developers: 9 | * Sina Aghli 10 | * Michael Kasper 11 | * Andrew Kramer 12 | * John Stechschulte 13 | * Gabe Sibley 14 | * Christoffer Heckman 15 | 16 | Previous Developers (thank you!): 17 | * Juan M. Falquez 18 | * Nima Keivan 19 | * Steven Lovegrove 20 | * Fernando Nobre 21 | 22 | Dependencies 23 | * opencv 24 | * google protobuf 25 | * google glog 26 | * google gflags 27 | * tinyxml2 28 | * Sophus 29 | * Calibu 30 | 31 | sudo apt-get install libprotobuf-dev libopencv-dev libgoogle-glog-dev libtinyxml2-dev protobuf-compiler 32 | -------------------------------------------------------------------------------- /cmake_modules/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | -------------------------------------------------------------------------------- /cmake_modules/FindASSIMP.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find Assimp 2 | # Once done, this will define 3 | # 4 | # ASSIMP_FOUND - system has Assimp 5 | # ASSIMP_INCLUDE_DIR - the Assimp include directories 6 | # ASSIMP_LIBRARIES - link these to use Assimp 7 | 8 | FIND_PATH( ASSIMP_INCLUDE_DIR assimp/mesh.h 9 | /usr/include 10 | /usr/local/include 11 | /opt/local/include 12 | ) 13 | 14 | FIND_LIBRARY( ASSIMP_LIBRARY assimp 15 | /usr/lib64 16 | /usr/lib 17 | /usr/local/lib 18 | /opt/local/lib 19 | ) 20 | 21 | IF(ASSIMP_INCLUDE_DIR AND ASSIMP_LIBRARY) 22 | SET( ASSIMP_FOUND TRUE ) 23 | SET( ASSIMP_LIBRARIES ${ASSIMP_LIBRARY} ) 24 | ENDIF(ASSIMP_INCLUDE_DIR AND ASSIMP_LIBRARY) 25 | 26 | IF(ASSIMP_FOUND) 27 | IF(NOT ASSIMP_FIND_QUIETLY) 28 | MESSAGE(STATUS "Found ASSIMP: ${ASSIMP_LIBRARY}") 29 | ENDIF(NOT ASSIMP_FIND_QUIETLY) 30 | ELSE(ASSIMP_FOUND) 31 | IF(ASSIMP_FIND_REQUIRED) 32 | MESSAGE(FATAL_ERROR "Could not find libASSIMP") 33 | ENDIF(ASSIMP_FIND_REQUIRED) 34 | ENDIF(ASSIMP_FOUND) 35 | -------------------------------------------------------------------------------- /cmake_modules/FindAvahi.cmake: -------------------------------------------------------------------------------- 1 | find_library(AVAHI_LIBRARY-COMMON NAMES avahi-common) 2 | find_library(AVAHI_LIBRARY-CLIENT NAMES avahi-client) 3 | find_path(AVAHI_INCLUDE_DIR avahi-client/publish.h) 4 | include(FindPackageHandleStandardArgs) 5 | find_package_handle_standard_args(Avahi DEFAULT_MSG AVAHI_LIBRARY-COMMON AVAHI_LIBRARY-CLIENT AVAHI_INCLUDE_DIR) 6 | if(AVAHI_FOUND) 7 | set(AVAHI_LIBRARIES ${AVAHI_LIBRARY-COMMON} ${AVAHI_LIBRARY-CLIENT}) 8 | set(AVAHI_INCLUDE_DIRS ${AVAHI_INCLUDE_DIR}) 9 | endif() 10 | -------------------------------------------------------------------------------- /cmake_modules/FindCoreFoundation.cmake: -------------------------------------------------------------------------------- 1 | # Locate Apple CoreFoundation 2 | # This module defines 3 | # COREFOUNDATION_LIBRARY 4 | # COREFOUNDATION_FOUND, if false, do not try to link to gdal 5 | # COREFOUNDATION_INCLUDE_DIR, where to find the headers 6 | # 7 | # $COREFOUNDATION_DIR is an environment variable that would 8 | # correspond to the ./configure --prefix=$COREFOUNDATION_DIR 9 | # 10 | # Created by Christian Frisson. 11 | 12 | IF(APPLE) 13 | FIND_PATH(COREFOUNDATION_INCLUDE_DIR CoreFoundation/CoreFoundation.h) 14 | FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation) 15 | ENDIF() 16 | 17 | 18 | SET(COREFOUNDATION_FOUND "NO") 19 | IF(COREFOUNDATION_LIBRARY AND COREFOUNDATION_INCLUDE_DIR) 20 | SET(COREFOUNDATION_FOUND "YES") 21 | ENDIF() 22 | 23 | -------------------------------------------------------------------------------- /cmake_modules/FindEigen3.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find Eigen3 lib 2 | # Once done this will define 3 | # 4 | # EIGEN3_FOUND - system has eigen lib 5 | # EIGEN3_INCLUDE_DIR - the eigen include directory 6 | 7 | # Copyright (c) 2006, 2007 Montel Laurent, 8 | # Redistribution and use is allowed according to the terms of the BSD license. 9 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 10 | 11 | if (EIGEN3_INCLUDE_DIR) 12 | 13 | # in cache already 14 | set(EIGEN3_FOUND TRUE) 15 | 16 | else (EIGEN3_INCLUDE_DIR) 17 | 18 | find_path(EIGEN3_INCLUDE_DIR NAMES Eigen/Core 19 | PATHS 20 | ${INCLUDE_INSTALL_DIR} 21 | ${KDE4_INCLUDE_DIR} 22 | PATH_SUFFIXES eigen3 23 | ) 24 | 25 | include(FindPackageHandleStandardArgs) 26 | find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR ) 27 | 28 | 29 | mark_as_advanced(EIGEN3_INCLUDE_DIR) 30 | 31 | endif(EIGEN3_INCLUDE_DIR) 32 | 33 | -------------------------------------------------------------------------------- /cmake_modules/FindFREEGLUT.cmake: -------------------------------------------------------------------------------- 1 | # Try to find the FREEGLUT library 2 | # 3 | # FREEGLUT_INCLUDE_DIR 4 | # FREEGLUT_LIBRARY 5 | # FREEGLUT_FOUND 6 | 7 | FIND_PATH( 8 | FREEGLUT_INCLUDE_DIR GL/freeglut.h 9 | ${CMAKE_INCLUDE_PATH} 10 | $ENV{include} 11 | ${OPENGL_INCLUDE_DIR} 12 | /usr/include 13 | /usr/local/include 14 | ) 15 | FIND_LIBRARY( 16 | FREEGLUT_LIBRARY 17 | NAMES freeglut_static freeglut glut 18 | PATH 19 | ${CMAKE_LIBRARY_PATH} 20 | $ENV{lib} 21 | /usr/lib 22 | /usr/local/lib 23 | ) 24 | 25 | IF (FREEGLUT_INCLUDE_DIR AND FREEGLUT_LIBRARY) 26 | SET(FREEGLUT_FOUND TRUE) 27 | ENDIF (FREEGLUT_INCLUDE_DIR AND FREEGLUT_LIBRARY) 28 | 29 | IF (FREEGLUT_FOUND) 30 | IF (NOT FREEGLUT_FIND_QUIETLY) 31 | MESSAGE(STATUS "Found FREEGLUT: ${FREEGLUT_LIBRARY}") 32 | ENDIF (NOT FREEGLUT_FIND_QUIETLY) 33 | ELSE (FREEGLUT_FOUND) 34 | IF (FREEGLUT_FIND_REQUIRED) 35 | MESSAGE(FATAL_ERROR "Could not find FREEGLUT") 36 | ENDIF (FREEGLUT_FIND_REQUIRED) 37 | ENDIF (FREEGLUT_FOUND) 38 | -------------------------------------------------------------------------------- /cmake_modules/FindGFlags.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find gflags 2 | # Once done, this will define 3 | # 4 | # GFlags_FOUND - system has gflags 5 | # GFlags_INCLUDE_DIRS - the gflags include directories 6 | # GFlags_LIBRARIES - link these to use gflags 7 | 8 | # Find header and lib 9 | find_path(GFlags_INCLUDE_DIR NAMES gflags/gflags.h) 10 | find_library(GFlags_LIBRARIES NAMES gflags) 11 | 12 | include(FindPackageHandleStandardArgs) 13 | find_package_handle_standard_args(GFlags DEFAULT_MSG GFlags_INCLUDE_DIR GFlags_LIBRARIES) 14 | set(GFLAGS_INCLUDE_DIRS ${GFlags_INCLUDE_DIRS}) 15 | set(GFLAGS_LIBRARIES ${GFlags_LIBRARIES}) 16 | -------------------------------------------------------------------------------- /cmake_modules/FindGLUES.cmake: -------------------------------------------------------------------------------- 1 | # Try to find the GLUES lib and include files 2 | # 3 | # GLUES_INCLUDE_DIR 4 | # GLUES_LIBRARIES 5 | # GLUES_FOUND 6 | 7 | FIND_PATH( GLUES_INCLUDE_DIR glues/glues.h 8 | /usr/include 9 | /usr/local/include 10 | /opt/include 11 | /opt/local/include 12 | ${CMAKE_INSTALL_PREFIX}/include 13 | ) 14 | 15 | FIND_LIBRARY( GLUES_LIBRARY glues 16 | /usr/lib64 17 | /usr/lib 18 | /usr/local/lib 19 | /opt/local/lib 20 | /opt/local/lib64 21 | ${CMAKE_INSTALL_PREFIX}/lib 22 | ) 23 | 24 | IF(GLUES_INCLUDE_DIR AND GLUES_LIBRARY) 25 | SET( GLUES_FOUND TRUE ) 26 | SET( GLUES_LIBRARIES ${GLUES_LIBRARY} ) 27 | ENDIF(GLUES_INCLUDE_DIR AND GLUES_LIBRARY) 28 | 29 | IF(GLUES_FOUND) 30 | IF(NOT GLUES_FIND_QUIETLY) 31 | MESSAGE(STATUS "Found GLUES: ${GLUES_LIBRARY}") 32 | ENDIF(NOT GLUES_FIND_QUIETLY) 33 | ELSE(GLUES_FOUND) 34 | IF(GLUES_FIND_REQUIRED) 35 | MESSAGE(FATAL_ERROR "Could not find GLUES") 36 | ENDIF(GLUES_FIND_REQUIRED) 37 | ENDIF(GLUES_FOUND) 38 | 39 | -------------------------------------------------------------------------------- /cmake_modules/FindGLog.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find glog (or miniglog for Android) 2 | # Once done, this will define 3 | # 4 | # GLog_FOUND - system has glog 5 | # GLog_INCLUDE_DIRS - the glog include directories 6 | # GLog_LIBRARIES - link these to use glog 7 | 8 | # Find header and lib 9 | find_path(GLog_INCLUDE_DIR NAMES glog/logging.h) 10 | find_library(GLog_LIBRARIES NAMES glog) 11 | 12 | include(FindPackageHandleStandardArgs) 13 | find_package_handle_standard_args(GLog DEFAULT_MSG GLog_INCLUDE_DIR GLog_LIBRARIES) 14 | set(GLOG_INCLUDE_DIRS ${GLog_INCLUDE_DIRS}) 15 | set(GLOG_LIBRARIES ${GLog_LIBRARIES}) 16 | -------------------------------------------------------------------------------- /cmake_modules/FindPCAN.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find peak-linux driver 2 | # Once done, this will define 3 | # 4 | # ZeroMQ_FOUND - system has pcan 5 | # ZeroMQ_INCLUDE_DIRS - the libpcan include directories 6 | 7 | include(LibFindMacros) 8 | 9 | IF(UNIX) 10 | # Include dir 11 | find_path(PCAN_INCLUDE_DIR 12 | NAMES libpcan.h 13 | PATHS /usr/include ${PCAN_PKGCONF_INCLUDE_DIRS} 14 | ) 15 | #Library Path 16 | find_library(PCAN_LIBRARY 17 | NAMES libpcan.so 18 | PATHS /usr/lib /usr/local/lib 19 | ) 20 | ENDIF() 21 | 22 | # Set the include dir variables and the libraries and let libfind_process do the rest. 23 | # NOTE: Singular variables for this library, plural for libraries this this lib depends on. 24 | set(PCAN_PROCESS_INCLUDES PCAN_INCLUDE_DIR PCAN_INCLUDE_DIRS) 25 | set(PCAN_PROCESS_LIBS PCAN_LIBRARY PCAN_LIBRARIES) 26 | libfind_process(PCAN) 27 | -------------------------------------------------------------------------------- /cmake_modules/FindPackage.cmake.in: -------------------------------------------------------------------------------- 1 | 2 | SET( @PACKAGE_PKG_NAME@_LIBRARIES @PACKAGE_LINK_LIBS@ CACHE INTERNAL "@PACKAGE_PKG_NAME@ libraries" FORCE ) 3 | SET( @PACKAGE_PKG_NAME@_INCLUDE_DIRS @PACKAGE_INCLUDE_DIRS@ CACHE INTERNAL "@PACKAGE_PKG_NAME@ include directories" FORCE ) 4 | SET( @PACKAGE_PKG_NAME@_LIBRARY_DIRS @PACKAGE_LINK_DIRS@ CACHE INTERNAL "@PACKAGE_PKG_NAME@ library directories" FORCE ) 5 | 6 | mark_as_advanced( @PACKAGE_PKG_NAME@_LIBRARIES ) 7 | mark_as_advanced( @PACKAGE_PKG_NAME@_LIBRARY_DIRS ) 8 | mark_as_advanced( @PACKAGE_PKG_NAME@_INCLUDE_DIRS ) 9 | 10 | 11 | -------------------------------------------------------------------------------- /cmake_modules/FindRealSense2.cmake: -------------------------------------------------------------------------------- 1 | include(FindPackageHandleStandardArgs) 2 | 3 | find_path(RealSense2_INCLUDE_DIR "librealsense2/rs.h" 4 | /usr/include 5 | /usr/local/include 6 | /opt/local/include 7 | ) 8 | 9 | find_library(RealSense2_LIBRARIES NAMES "realsense2" 10 | /usr/lib64 11 | /usr/lib 12 | /usr/local/lib 13 | /opt/local/lib 14 | ) 15 | 16 | find_package_handle_standard_args("RealSense2" DEFAULT_MSG 17 | RealSense2_INCLUDE_DIR RealSense2_LIBRARIES) 18 | 19 | set(RealSense2_FOUND ${RealSense2_FOUND} CACHE BOOL "RealSense2 was found or not" FORCE) 20 | mark_as_advanced(RealSense2_INCLUDE_DIR RealSense2_LIBRARIES) 21 | -------------------------------------------------------------------------------- /cmake_modules/FindTinyXML2.cmake: -------------------------------------------------------------------------------- 1 | # FractalImages 2 | # Copyright (C) 2012 Sven Hertle 3 | # 4 | # This program is free software; you can redistribute it and/or modify it under 5 | # the terms of the GNU General Public License as published by the Free Software 6 | # Foundation; either version 3 of the License, or (at your option) any later 7 | # version. 8 | # 9 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 10 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 11 | # PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License along with 14 | # this program; if not, see . 15 | 16 | # Find TinyXML2 17 | # 18 | # TinyXML2_FOUND True if TinyXML2 was found 19 | # TinyXML2_INCLUDE_DIR Directory with headers 20 | # TinyXML2_LIBRARIES List of libraries 21 | # 22 | 23 | find_path(TinyXML2_INCLUDE_DIR "tinyxml2.h") 24 | 25 | find_library(TinyXML2_LIBRARIES NAMES "tinyxml2") 26 | 27 | include(FindPackageHandleStandardArgs) 28 | find_package_handle_standard_args("TinyXML2" DEFAULT_MSG TinyXML2_INCLUDE_DIR TinyXML2_LIBRARIES) 29 | set(TinyXML2_FOUND ${TINYXML2_FOUND} CACHE BOOL "TinyXML2 was found or not" FORCE) 30 | 31 | mark_as_advanced(TinyXML2_INCLUDE_DIR TinyXML2_LIBRARIES) 32 | -------------------------------------------------------------------------------- /cmake_modules/FindZeroMQ.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find libzmq 2 | # Once done, this will define 3 | # 4 | # ZeroMQ_FOUND - system has libzmq 5 | # ZeroMQ_INCLUDE_DIRS - the libzmq include directories 6 | # ZeroMQ_LIBRARIES - link these to use libzmq 7 | 8 | include(LibFindMacros) 9 | 10 | IF (UNIX) 11 | # Use pkg-config to get hints about paths 12 | libfind_pkg_check_modules(ZeroMQ_PKGCONF libzmq) 13 | 14 | # Include dir 15 | find_path(ZeroMQ_INCLUDE_DIR 16 | NAMES zmq.h 17 | PATHS ${ZEROMQ_ROOT}/include ${ZeroMQ_PKGCONF_INCLUDE_DIRS} 18 | ) 19 | 20 | # Finally the library itself 21 | find_library(ZeroMQ_LIBRARY 22 | NAMES zmq 23 | PATHS ${ZEROMQ_ROOT}/lib ${ZeroMQ_PKGCONF_LIBRARY_DIRS} 24 | ) 25 | ELSEIF (WIN32) 26 | find_path(ZeroMQ_INCLUDE_DIR 27 | NAMES zmq.h 28 | PATHS ${ZEROMQ_ROOT}/include ${CMAKE_INCLUDE_PATH} 29 | ) 30 | # Finally the library itself 31 | find_library(ZeroMQ_LIBRARY 32 | NAMES libzmq 33 | PATHS ${ZEROMQ_ROOT}/lib ${CMAKE_LIB_PATH} 34 | ) 35 | ENDIF() 36 | 37 | # Set the include dir variables and the libraries and let libfind_process do the rest. 38 | # NOTE: Singular variables for this library, plural for libraries this this lib depends on. 39 | set(ZeroMQ_PROCESS_INCLUDES ZeroMQ_INCLUDE_DIR ZeroMQ_INCLUDE_DIRS) 40 | set(ZeroMQ_PROCESS_LIBS ZeroMQ_LIBRARY ZeroMQ_LIBRARIES) 41 | libfind_process(ZeroMQ) 42 | -------------------------------------------------------------------------------- /cmake_modules/FindZeroMQPP.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find libzmqpp 2 | # Once done, this will define 3 | # 4 | # ZeroMQPP_FOUND - system has libzmqpp 5 | # ZeroMQPP_INCLUDE_DIRS - the libzmqpp include directories 6 | # ZeroMQPP_LIBRARIES - link these to use libzmqpp 7 | 8 | include(LibFindMacros) 9 | 10 | IF (UNIX) 11 | 12 | # Include dir 13 | find_path(ZeroMQPP_INCLUDE_DIR 14 | NAMES zmqpp/zmqpp.hpp 15 | PATHS ${ZEROMQPP_ROOT}/include /usr/local/include 16 | ) 17 | 18 | # Finally the library itself 19 | find_library(ZeroMQPP_LIBRARY 20 | NAMES zmqpp 21 | PATHS ${ZEROMQPP_ROOT}/lib /usr/local/lib 22 | ) 23 | ELSEIF (WIN32) 24 | find_path(ZeroMQPP_INCLUDE_DIR 25 | NAMES zmqpp.hpp 26 | PATHS ${ZEROMQPP_ROOT}/include ${CMAKE_INCLUDE_PATH} 27 | ) 28 | # Finally the library itself 29 | find_library(ZeroMQPP_LIBRARY 30 | NAMES libzmqpp 31 | PATHS ${ZEROMQPP_ROOT}/lib ${CMAKE_LIB_PATH} 32 | ) 33 | ENDIF() 34 | 35 | # Set the include dir variables and the libraries and let libfind_process do the rest. 36 | # NOTE: Singular variables for this library, plural for libraries this this lib depends on. 37 | set(ZeroMQPP_PROCESS_INCLUDES ZeroMQPP_INCLUDE_DIR ZeroMQPP_INCLUDE_DIRS) 38 | set(ZeroMQPP_PROCESS_LIBS ZeroMQPP_LIBRARY ZeroMQPP_LIBRARIES) 39 | libfind_process(ZeroMQPP) 40 | 41 | -------------------------------------------------------------------------------- /cmake_modules/PackageConfig.cmake.in: -------------------------------------------------------------------------------- 1 | SET( @PACKAGE_PKG_NAME@_LIBRARIES "@PACKAGE_LINK_LIBS@" CACHE INTERNAL "@PACKAGE_PKG_NAME@ libraries" FORCE ) 2 | SET( @PACKAGE_PKG_NAME@_INCLUDE_DIRS @PACKAGE_INCLUDE_DIRS@ CACHE INTERNAL "@PACKAGE_PKG_NAME@ include directories" FORCE ) 3 | SET( @PACKAGE_PKG_NAME@_LIBRARY_DIRS @PACKAGE_LINK_DIRS@ CACHE INTERNAL "@PACKAGE_PKG_NAME@ library directories" FORCE ) 4 | 5 | mark_as_advanced( @PACKAGE_PKG_NAME@_LIBRARIES ) 6 | mark_as_advanced( @PACKAGE_PKG_NAME@_LIBRARY_DIRS ) 7 | mark_as_advanced( @PACKAGE_PKG_NAME@_INCLUDE_DIRS ) 8 | 9 | 10 | 11 | # Compute paths 12 | get_filename_component( PACKAGE_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH ) 13 | 14 | # This file, when used for INSTALLED code, does not use Targets... sigh. 15 | ## Library dependencies (contains definitions for IMPORTED targets) 16 | #if(NOT TARGET "@PACKAGE_PKG_NAME@_LIBRARIES" AND NOT "@PACKAGE_PKG_NAME@_BINARY_DIR") 17 | # include( "${PACKAGE_CMAKE_DIR}/@PACKAGE_PKG_NAME@Targets.cmake" ) 18 | # include( "${PACKAGE_CMAKE_DIR}/@PACKAGE_PKG_NAME@ConfigVersion.cmake" ) 19 | #endif() 20 | 21 | #SET(@PACKAGE_PKG_NAME@_LIBRARIES @PACKAGE_LIBRARIES@) 22 | #SET(@PACKAGE_PKG_NAME@_LIBRARY @PACKAGE_LIBRARY@) 23 | #SET(@PACKAGE_PKG_NAME@_INCLUDE_DIRS @PACKAGE_INCLUDE_DIRS@) 24 | #SET(@PACKAGE_PKG_NAME@_LINK_DIRS @PACKAGE_LINK_DIRS@) 25 | -------------------------------------------------------------------------------- /cmake_modules/PackageConfigVersion.cmake.in: -------------------------------------------------------------------------------- 1 | set(PACKAGE_VERSION "@PACKAGE_VERSION@") 2 | 3 | # Check build type is valid 4 | if( "System:${CMAKE_SYSTEM_NAME},Android:${ANDROID},iOS:${IOS}" STREQUAL 5 | "System:@CMAKE_SYSTEM_NAME@,Android:@ANDROID@,iOS:@IOS@" ) 6 | # Check whether the requested PACKAGE_FIND_VERSION is compatible 7 | if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") 8 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 9 | else() 10 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 11 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 12 | set(PACKAGE_VERSION_EXACT TRUE) 13 | endif() 14 | endif() 15 | else() 16 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 17 | endif() 18 | -------------------------------------------------------------------------------- /cmake_modules/PkgConfig.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: @PACKAGE_PKG_NAME@ 7 | Description: @PACKAGE_DESCRIPTION@ 8 | Version: @PACKAGE_VERSION@ 9 | Cflags: @PACKAGE_CFLAGS@ 10 | Libs: -L${libdir} @PACKAGE_LIBS@ @PACKAGE_LIB_LINK@ 11 | 12 | -------------------------------------------------------------------------------- /cmake_modules/README.md: -------------------------------------------------------------------------------- 1 | rpg-cmake 2 | ========= 3 | 4 | RPG's collection of reusable CMake scripts. 5 | -------------------------------------------------------------------------------- /cmake_modules/SetPlatformVars.cmake: -------------------------------------------------------------------------------- 1 | ## Compiler configuration 2 | IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) 3 | SET(_GCC_ 1) 4 | ENDIF() 5 | 6 | IF(MSVC) 7 | SET(_MSVC_ 1) 8 | ENDIF() 9 | 10 | ## Platform configuration 11 | IF(WIN32 OR WIN64) 12 | SET(_WIN_ 1) 13 | ENDIF() 14 | 15 | IF(UNIX) 16 | SET(_UNIX_ 1) 17 | ENDIF() 18 | 19 | IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 20 | SET(_OSX_ 1) 21 | ENDIF() 22 | 23 | IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") 24 | SET(_LINUX_ 1) 25 | ENDIF() 26 | 27 | IF(ANDROID) 28 | SET(_ANDROID_ 1) 29 | ENDIF() 30 | -------------------------------------------------------------------------------- /cmake_modules/SetSourceFlags.cmake: -------------------------------------------------------------------------------- 1 | function(set_source_flags src_file build_type) 2 | get_source_file_property(SRC_LANG "${src_file}" LANGUAGE) 3 | 4 | if("${SRC_LANG}" STREQUAL CXX) 5 | set(src_file_flags "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${build_type}}") 6 | elseif("${SRC_LANG}" STREQUAL C) 7 | set(src_file_flags "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${build_type}}") 8 | else() 9 | return() 10 | endif() 11 | 12 | set_source_files_properties("${src_file}" PROPERTIES COMPILE_FLAGS "${src_file_flags}") 13 | endfunction() -------------------------------------------------------------------------------- /cmake_modules/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | ## A simple uninstall script. 2 | ## Alternatively UNIX users can run/sudo `xargs rm < install_manifest.txt` in the build directory. 3 | 4 | set(unfile ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) 5 | file(WRITE ${unfile} "IF(NOT EXISTS \"install_manifest.txt\")\n") 6 | file(APPEND ${unfile} "MESSAGE(\"FATAL_ERROR Cannot find \\\"install manifest\\\": install_manifest.txt\")\n") 7 | file(APPEND ${unfile} "ENDIF(NOT EXISTS \"install_manifest.txt\")\n") 8 | file(APPEND ${unfile} "FILE(READ \"install_manifest.txt\" files)\n") 9 | file(APPEND ${unfile} "STRING(REGEX REPLACE \"\\n\" \";\" files \"\${files}\")\n") 10 | file(APPEND ${unfile} "FOREACH(file \${files})\n") 11 | file(APPEND ${unfile} " MESSAGE(STATUS \"Uninstalling \\\"\${file}\\\"\")\n") 12 | file(APPEND ${unfile} " IF(EXISTS \"\${file}\")\n") 13 | file(APPEND ${unfile} " EXEC_PROGRAM(\n") 14 | file(APPEND ${unfile} " \"\${CMAKE_COMMAND}\" ARGS \"-E remove \\\"\${file}\\\"\"\n") 15 | file(APPEND ${unfile} " OUTPUT_VARIABLE rm_out\n") 16 | file(APPEND ${unfile} " RETURN_VALUE rm_retval\n") 17 | file(APPEND ${unfile} " )\n") 18 | file(APPEND ${unfile} " IF(\"\${rm_retval}\" STREQUAL 0\)\n") 19 | file(APPEND ${unfile} " ELSE(\"\${rm_retval}\" STREQUAL 0\)\n") 20 | file(APPEND ${unfile} " MESSAGE(FATAL_ERROR \"Problem when removing \\\"\${file}\\\"\")\n") 21 | file(APPEND ${unfile} " ENDIF(\"\${rm_retval}\" STREQUAL 0)\n") 22 | file(APPEND ${unfile} " ELSE(EXISTS \"\${file}\")\n") 23 | file(APPEND ${unfile} " MESSAGE(STATUS \"File \\\"\${file}\\\" does not exist. \")\n") 24 | file(APPEND ${unfile} " ENDIF(EXISTS \"\${file}\")\n") 25 | file(APPEND ${unfile} "ENDFOREACH(file)\n") 26 | 27 | -------------------------------------------------------------------------------- /cmake_modules/def_test.cmake: -------------------------------------------------------------------------------- 1 | include(CMakeParseArguments) 2 | include(FindGTest) 3 | 4 | function(def_test test) 5 | 6 | string(TOUPPER ${test} TEST) 7 | 8 | set(TEST_OPTIONS) 9 | set(TEST_SINGLE_ARGS) 10 | set(TEST_MULTI_ARGS SOURCES DEPENDS CONDITIONS LINK_LIBS) 11 | cmake_parse_arguments(test 12 | "${TEST_OPTIONS}" 13 | "${TEST_SINGLE_ARGS}" 14 | "${TEST_MULTI_ARGS}" 15 | "${ARGN}" 16 | ) 17 | 18 | if(NOT test_SOURCES) 19 | message(FATAL_ERROR "def_test for ${TEST} has an empty source list.") 20 | endif() 21 | 22 | set(cache_var BUILD_${TEST}) 23 | set(${cache_var} ON CACHE BOOL "Enable ${TEST} compilation.") 24 | 25 | if(test_CONDITIONS) 26 | foreach(cond ${test_CONDITIONS}) 27 | if(NOT ${cond}) 28 | set(${cache_var} OFF) 29 | message("${cache_var} is false because ${cond} is false.") 30 | return() 31 | endif() 32 | endforeach() 33 | endif() 34 | 35 | if(test_DEPENDS) 36 | foreach(dep ${test_DEPENDS}) 37 | if(NOT TARGET ${dep}) 38 | set(${cache_var} OFF) 39 | message("${cache_var} is false because ${dep} is not being built.") 40 | return() 41 | endif() 42 | endforeach() 43 | endif() 44 | 45 | if(${cache_var}) 46 | add_executable(${test} ${test_SOURCES}) 47 | gtest_add_tests(${test} "" ${test_SOURCES}) 48 | 49 | # Always build tests debug so they can be debugged! 50 | set_target_properties(${test} PROPERTIES 51 | COMPILE_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}") 52 | 53 | target_link_libraries(${test} 54 | gtest gtest_main 55 | ${test_DEPENDS} 56 | ${test_LINK_LIBS}) 57 | endif() 58 | endfunction() -------------------------------------------------------------------------------- /cmake_modules/set_git_version.cmake: -------------------------------------------------------------------------------- 1 | ####################################################################################### 2 | # get_git_version.cmake - Function for setting up versions based on GIT. 3 | # 4 | # get_git_version - Takes a variable name and sets it to the GIT tag version. 5 | # 6 | # If GIT package is not found, sets default version to 1.0.0 7 | ####################################################################################### 8 | 9 | function(set_git_version var) 10 | find_package(GIT QUIET) 11 | if(GIT_FOUND) 12 | execute_process(COMMAND ${GIT_EXECUTABLE} describe --abbrev=0 13 | RESULT_VARIABLE GIT_TAG_RESULT 14 | OUTPUT_VARIABLE GIT_TAG_VERSION 15 | OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) 16 | if(GIT_TAG_RESULT EQUAL 0) 17 | set(${var} ${GIT_TAG_VERSION} CACHE INTERNAL "Version Number" FORCE) 18 | else() 19 | set(${var} "1.0.0" CACHE INTERNAL "Version Number" FORCE) 20 | message(STATUS "GIT not found! ${var} set to default value: ${${var}}") 21 | endif() 22 | else() 23 | set(${var} "1.0.0" CACHE INTERNAL "Version Number" FORCE) 24 | message(STATUS "GIT not found! ${var} set to default value: ${${var}}") 25 | endif() 26 | endfunction() 27 | --------------------------------------------------------------------------------