-
Notifications
You must be signed in to change notification settings - Fork 24
Tutorial Reading VI Data
Below you find a self-explanatory "Hello World" example that you can use to interface the VI-Sensor.
#include <iostream>
#include "boost/bind.hpp"
#include <visensor/visensor.hpp>
void ImageCallback(visensor::ViFrame::Ptr frame_ptr) {
// The struct visensor::ViFrame is defined in
// libvisensor/include/visensor/visensor_datatypes.hpp
std::cout << "Received image msg" << std::endl;
}
void ImuCallback(boost::shared_ptr<visensor::ViImuMsg> imu_ptr) {
// The struct visensor::ViImuMsg is defined in
// libvisensor/include/visensor/visensor_datatypes.hpp
std::cout << "Received IMU msg" << std::endl;
}
int main(int argc, char** argv) {
visensor::ViSensorDriver drv;
try {
drv.init();
} catch (visensor::exceptions::ConnectionException const &ex) {
std::cout << ex.what() << "\n";
return 1;
}
std::cout << "Opened VI-Sensor" << std::endl;
// set callback for image messages
drv.setCameraCallback(boost::bind(ImageCallback, _1));
// set callback for IMU messages
drv.setImuCallback(boost::bind(ImuCallback, _1));
drv.startAllCameras();
drv.startAllImus();
//Setting camera parameter
drv.setSensorConfigParam(visensor::SensorId::CAM0, "coarse_shutter_width", 600);
std::cout << "Waiting for user input to end program." << std::endl;
char a;
std::cin >> a;
return 0;
}Once you installed the libvisensor as desribed here, you can copy paste the source code above into a cpp file and compile it using
g++ main.cpp -I/usr/local/include/ -l visensor
A slightly more complex example which also displays the incoming images using openCV is found in this github repo.
Copyright © 2015, Skybotix AG, Switzerland
Copyright © 2015, Autonomous Systems Lab, ETH Zurich, Switzerland
All rights reserved.
Connecting the Sensor
Software Requirements
Updating the Sensor Firmware
Getting started in ROS
Configuring the Sensor
ROS Topics and Services
Getting Extrinsic and Intrinsic Calibrations
Compiling the VI Sensor Driver Standalone (Without ROS)
Setting Sensor Parameters
Tutorial: Reading VI Data
Tutorial: Dense Reconstruction
Running FOVIS (ROS)
Running VISO2 (ROS)