Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

Commit

Permalink
I neglected GIT a bit so this commit is way to big
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris committed Sep 16, 2019
1 parent 5ca0cb6 commit 329568b
Show file tree
Hide file tree
Showing 15 changed files with 172 additions and 27 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ The interface has the following capabilities:
# VR 360 cam
This tool renders omnidirectional stereo images for a V-REP vision sensor. You don't need any physical VR device to use this tool (only to view the result). The theory behind this rendering process is exelently explained here : https://developers.google.com/vr/jump/rendering-ods-content.pdf.

Some videos produced with this tool:
- https://youtu.be/7O629j58bTI
- https://youtu.be/pFAptrCYhaQ

To use this tool, import the VR360_cam.ttm model in your V-REP scene. Next launch VR360_cam.exe (maybe as administrator, a file is saved in the location of the .exe file, this action could require administrator privileges).
This process is demonstrated at the end of this video https://youtu.be/ozam2Ew7RdA.

Expand Down Expand Up @@ -88,3 +92,21 @@ Please cite this paper if the interface is used in a relevant context (camera pl
publisher={Multidisciplinary Digital Publishing Institute}
}

# Enabling Humans to Plan Inspection Paths Using a Virtual Reality Interface
The interface also contains the implementation of the paper "Enabling Humans to Plan Inspection Paths Using a Virtual Reality Interface" available at https://arxiv.org/abs/1909.06077

The usage is the same as in the demo scene: Hello_camera_coverage.ttt. To visualize the quality on a mesh, just make the mesh a child of the Field model.

Additional signals:
- To reset a measurement state: sim.setIntegerSignal("ResetMeasurement", 1)
- To record a path: sim.setIntegerSignal("MeasurementInProgress", 1)

Please cite this paper if the interface is used in a relevant context (Robotic inspection planning)

@article{bogaerts2019enabling,
title={Enabling Humans to Plan Inspection Paths Using a Virtual Reality Interface},
author={Bogaerts, Boris and Sels, Seppe and Vanlanduit, Steve and Penne, Rudi},
journal={arXiv preprint arXiv:1909.06077},
year={2019}
}

4 changes: 0 additions & 4 deletions V-REP VR Interface/V-REP VR Interface.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@
<ResourceCompile Include="V-REP VR Interface.rc" />
<ResourceCompile Include="V-REP VR Interface2.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="..\geen_titel_1_OHv_icon.ico" />
<Image Include="C:\Users\Boris\Downloads\geen_titel_1_OHv_icon.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
Binary file modified V-REP data/Scenes/Hello_camera_coverage.ttt
Binary file not shown.
14 changes: 14 additions & 0 deletions vrep_vtk_engine/pathObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ vtkSmartPointer<vtkActor> pathObject::getActor() {
return lineActor;
}

vtkSmartPointer<vtkActor> pathObject::getNewActor() {
vtkSmartPointer<vtkActor> newActor = vtkSmartPointer<vtkActor>::New();
vtkSmartPointer<vtkPolyData> newLineData = vtkSmartPointer<vtkPolyData>::New();
vtkSmartPointer<vtkPolyDataMapper> newLineMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
newLineData->ShallowCopy(polyData);
newLineMapper->SetInputData(newLineData);
newActor->SetMapper(newLineMapper);
newActor->SetUserTransform(pose);
newActor->GetProperty()->SetColor(0.7, 0.14, 0.56);
newActor->GetProperty()->SetLineWidth(5.0);
newActor->PickableOff();
return newActor;
}

void pathObject::update() {
if (exist) {
simxInt succes;
Expand Down
1 change: 1 addition & 0 deletions vrep_vtk_engine/pathObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class pathObject
~pathObject();
void update();
vtkSmartPointer<vtkActor> getActor();
vtkSmartPointer<vtkActor> getNewActor();
protected:
int clientID;
bool exist = false;
Expand Down
8 changes: 7 additions & 1 deletion vrep_vtk_engine/renderwindow_support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <thread>
#include <chrono>
#include <ppl.h>
#include "vrep_plot_container.h"

void handleFunc(renderwindow_support *sup) {
cout << "Vision sensor thread activated" << endl;
Expand Down Expand Up @@ -181,7 +182,8 @@ void renderwindow_support::activate_interactor() {
renderer->AddActor(path->getActor());
renderer->Modified();


// Create plot container
vrep_plot_container *cont = new vrep_plot_container(clientID, renderer);

// Manage vision sensor thread (if necessary)
std::thread camThread;
Expand All @@ -197,6 +199,10 @@ void renderwindow_support::activate_interactor() {
chrono->increment();

path->update();

// add plot content
cont->update();

if (isReady()) {
syncData();
//grid->updatMap();
Expand Down
99 changes: 85 additions & 14 deletions vrep_vtk_engine/stereoPanorama_renderwindow_support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@
#include <vtkOutputWindow.h>
#include <vtkFileOutputWindow.h>
#include <vtkPNGWriter.h>
#include <vtkPNGReader.h>
#include "vrep_plot_container.h"
#include <vtkAlgorithmOutput.h>

#define PI 3.14159265



stereoPanorama_renderwindow_support::stereoPanorama_renderwindow_support(int cid, int ref, int interactor)
{
refH = ref;
Expand All @@ -65,7 +70,7 @@ stereoPanorama_renderwindow_support::stereoPanorama_renderwindow_support(int cid

vtkOutputWindow* ow = vtkOutputWindow::GetInstance();
vtkFileOutputWindow* fow = vtkFileOutputWindow::New();
fow->SetFileName("debug.log");
fow->SetFileName("VR360_debug.log");
if (ow)
{
ow->SetInstance(fow);
Expand Down Expand Up @@ -115,7 +120,12 @@ void stereoPanorama_renderwindow_support::addVrepScene(vrep_scene_content *vrepS
}
}
if (vrepScene->isVolumePresent()) {
renderer[k]->AddViewProp(vrepScene->getVolume());
if (k == 0) {
renderer[k]->AddVolume(vrepScene->getVolume());
}
else {
renderer[k]->AddVolume(vrepScene->getNawVolume());
}
grid = vrepScene->vol;
//renderer[k]->ResetCamera();
}
Expand Down Expand Up @@ -196,6 +206,41 @@ void stereoPanorama_renderwindow_support::syncData() {
vrepScene->transferVisionSensorData();
}

//vtkSmartPointer<vtkAlgorithmOutput> runFXAA(vtkSmartPointer<vtkImageData> im) {
// vtkSmartPointer<vtkOpenGLRenderer> render = vtkSmartPointer<vtkOpenGLRenderer>::New();
// vtkSmartPointer<vtkRenderWindow> renwin = vtkSmartPointer<vtkRenderWindow>::New();
// vtkSmartPointer<vtkOpenVRRenderWindowInteractor> renwinI = vtkSmartPointer<vtkOpenVRRenderWindowInteractor>::New();
//
// vtkSmartPointer<vtkOpenGLTexture> tex = vtkSmartPointer<vtkOpenGLTexture>::New();
// vtkSmartPointer<vtkWindowToImageFilter> fi = vtkSmartPointer<vtkWindowToImageFilter>::New();
// tex->SetInputData(im);
// tex->Update();
// render->SetTexturedBackground(true);
// render->SetBackgroundTexture(tex);
// render->UseFXAAOn();
// renwin->AddRenderer(render);
// renwin->SetSize(im->GetDimensions()[0], im->GetDimensions()[1]);
// renwin->SetAlphaBitPlanes(1);
// //renwin->SetOffScreenRendering(true);
//
// renwinI->SetRenderWindow(renwin);
// fi->SetInput(renwin);
// fi->SetInputBufferTypeToRGBA();
// fi->ShouldRerenderOff();
// cout << "Did this" << endl;
// render->Render();
// cout << "Did this" << endl;
// fi->Modified();
// fi->ReadFrontBufferOff();
// fi->Update();
// render->Delete();
// renwin->Delete();
// renwinI->Delete();
// tex->Delete();
// return fi->GetOutputPort();
//}



void stereoPanorama_renderwindow_support::renderStrip(float dist, bool left, bool top, int k, int width, int height) {
vtkSmartPointer<vtkImageAppend> horizontal = vtkSmartPointer<vtkImageAppend>::New();
Expand Down Expand Up @@ -227,10 +272,7 @@ void stereoPanorama_renderwindow_support::renderStrip(float dist, bool left, boo
prePose->Modified();
vr_camera[k]->SetModelTransformMatrix(prePose->GetMatrix());
vr_camera[k]->Modified();

//vr_camera[k]->Modified();
renderer[k]->Render();
//vr_renderWindowInteractor[k]->Render();
filter[k]->Modified();
filter[k]->ReadFrontBufferOff();
filter[k]->Update();
Expand Down Expand Up @@ -275,22 +317,38 @@ void stereoPanorama_renderwindow_support::activate_interactor() {

// Search for dynamic path object
path = new pathObject(clientID);
for (int k = 0; k < 1; k++) {
renderer[k]->AddActor(path->getActor());
for (int k = 0; k < vr_camera.size(); k++) {
vtkSmartPointer<vtkActor> temp;
if (k == 0) {
temp = path->getActor();
}
else {
temp = path->getNewActor();
}
renderer[k]->AddActor(temp);
renderer[k]->Modified();
}
std::string fileName = ExePath();
fileName.append("\\imageTransfer.png");
//vrepScene->vol->toggleMode();
cout << "Temporary file save location : " << fileName << endl;

// Define plot container
vrep_plot_container *pc = new vrep_plot_container(clientID, renderer);

if (core == 1) {
cout << "Multi core rendering activated" << endl;
}else{
cout << "Single core rendering activated" << endl;
}
while (true) {
for (int i = 0; i < 2; i++) {
if (vrepScene->startVisionSensorThread()) { // if vision sensor
vrepScene->updateVisionSensorObjectPose();
coverage = vrepScene->updateVisionSensorRender();
syncData();
}
//checkBackground();
updatePose();
checkLayers();
path->update();
Expand All @@ -301,6 +359,10 @@ void stereoPanorama_renderwindow_support::activate_interactor() {
if (trigger == 0) {
continue;
}

// update plot container
pc->update();

vtkSmartPointer<vtkImageAppend> vertical = vtkSmartPointer<vtkImageAppend>::New();
vertical->SetAppendAxis(1);
cout << "Started rendering image" << endl;
Expand All @@ -327,8 +389,11 @@ void stereoPanorama_renderwindow_support::activate_interactor() {
for (int i = 0; i < 4; i++) {
vertical->AddInputData(slice[i]); // top left
}

vtkSmartPointer<vtkPNGWriter> wr = vtkSmartPointer<vtkPNGWriter>::New();
wr->SetFileName(fileName.c_str());
vertical->Update();
//wr->SetInputConnection(runFXAA(vertical->GetOutput()));
wr->SetInputConnection(vertical->GetOutputPort());
wr->Write();

Expand Down Expand Up @@ -370,24 +435,30 @@ void stereoPanorama_renderwindow_support::activateMainCam(int height) {
renderer[k]->SetTwoSidedLighting(false);
renderer[k]->LightFollowCameraOff();
renderer[k]->AutomaticLightCreationOff();
//renderer[k]->UseDepthPeelingForVolumesOn();
//renderer[k]->SetMaximumNumberOfPeels(0);
//renderer[k]->SetUseDepthPeeling(true);
renderer[k]->UseDepthPeelingForVolumesOn();
renderer[k]->SetUseDepthPeeling(true);
renderer[k]->SetMaximumNumberOfPeels(20);
renderer[k]->Modified();
renderer[k]->SetBackground(data[0], data[1], data[2]);
renderer[k]->SetBackground2(data[3], data[4], data[5]);
renderer[k]->SetGradientBackground(true);
//renderer[k]->SetBackground(data[0], data[1], data[2]);
//renderer[k]->SetBackground2(data[3], data[4], data[5]);
//renderer[k]->SetGradientBackground(true);
//renderer[k]->SetBackground(1,1,1);
renderer[k]->SetBackgroundAlpha(0.0); //-> re activate this
//renderer[k]->SetUseFXAA(true);

renderWindow[k]->AddRenderer(renderer[k]);

renderWindow[k]->SetSize(121.0, height); // make shure we have a 'middle' pixel
renderWindow[k]->SetOffScreenRendering(true);
renderWindow[k]->Initialize();
renderWindow[k]->SetDesiredUpdateRate(10000.0);
renderWindow[k]->SetAlphaBitPlanes(1); // -> re activate this
//renderWindow[k]->SetAlphaBitPlanes(true);
//renderWindow[k]->SetMultiSamples(0);
renderWindow[k]->SetMultiSamples(0);
vr_renderWindowInteractor[k]->SetRenderWindow(renderWindow[k]);
vr_renderWindowInteractor[k]->Initialize();
filter[k]->SetInput(renderWindow[k]);
filter[k]->SetInputBufferTypeToRGBA(); //-> re activate this
filter[k]->ShouldRerenderOff();
}
}
Expand Down
7 changes: 5 additions & 2 deletions vrep_vtk_engine/stereoPanorama_renderwindow_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class stereoPanorama_renderwindow_support
void dynamicAddObjects();

void syncData();

//void checkBackground();
timerClass *chrono = new timerClass;
protected:
vrep_scene_content * vrepScene;
Expand All @@ -84,13 +84,16 @@ class stereoPanorama_renderwindow_support
int refH;
int update = 10;
int useInteractor = true;
std::vector<vtkSmartPointer<vtkOpenGLRenderer>> renderer;
std::vector<vtkSmartPointer<vtkRenderer>> renderer;
std::vector<vtkSmartPointer<vtkWin32OpenGLRenderWindow>> renderWindow;
std::vector<vtkSmartPointer<vtkWin32RenderWindowInteractor>> vr_renderWindowInteractor;
std::vector<vtkSmartPointer<vtkOpenGLCamera>> vr_camera;
std::vector<vtkSmartPointer<vtkTransform>> pose;
std::vector<vtkSmartPointer<vtkImageData>> slice;

//vtkSmartPointer<vtkExtractVOI> backGroundSlicer = nullptr;
//vtkSmartPointer<vtkImageData> backGround = nullptr;

std::vector<vtkSmartPointer<vtkWindowToImageFilter>> filter;

vrep_volume_grid *grid;
Expand Down
9 changes: 9 additions & 0 deletions vrep_vtk_engine/vr_renderwindow_support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
#include <vtkOBJImporter.h>
#include <vtkActorCollection.h>
#include <vtkPolyDataMapper.h>

#include "vrep_plot_container.h"
// Sorry this is purely vtk's fault, stupid function handles etc
class miniClass {
public:
Expand Down Expand Up @@ -480,6 +482,9 @@ void vr_renderwindow_support::activate_interactor() {
}else{
camThread.~thread();
}

// Define plot container
vrep_plot_container *pc = new vrep_plot_container(clientID, renderer);

// Start the render loop
while (true) {
Expand All @@ -497,6 +502,10 @@ void vr_renderwindow_support::activate_interactor() {
updateText(); // change framerate text
path->update();
checkLayers();

// update plot container
pc->update();

if (isReady()) {
syncData(); // transfer information of vision sensor in differend thread to this thread
//grid->updatMap();
Expand Down
2 changes: 1 addition & 1 deletion vrep_vtk_engine/vrep_mesh_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ vtkSmartPointer<vtkActor> vrep_mesh_object::getNewActor() {
vtkSmartPointer<vtkPolyData> PD = vtkSmartPointer<vtkPolyData>::New();
newPM->SetLookupTable(vrep_polyData_mapper->GetLookupTable());
PD->DeepCopy(meshData);
//PD->GetPointData()->SetScalars(meshData->GetPointData()->GetScalars()); // if visibility computation
PD->GetPointData()->SetScalars(meshData->GetPointData()->GetScalars()); // if visibility computation
newPM->SetInputData(PD);
newActor->SetMapper(newPM);
if (texturedObject) {
Expand Down
4 changes: 2 additions & 2 deletions vrep_vtk_engine/vrep_scene_content.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ void vrep_scene_content::vrep_get_object_pose() {
float vrep_scene_content::computeScalarField() {
if (firstTime) {
if (volumePresent) {
scalar = vol->getScalars();
//scalar->SetNumberOfValues(vol->getNumberOfValues());
//scalar = vol->getScalars();
scalar->SetNumberOfValues(vol->getNumberOfValues());
state->SetNumberOfValues(vol->getNumberOfValues());
}
else {
Expand Down
1 change: 1 addition & 0 deletions vrep_vtk_engine/vrep_scene_content.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class vrep_scene_content
int getNumActors();
int getNumRenders() { return camsContainer.size(); };
vtkSmartPointer<vtkVolume> getVolume() { return volume; };
vtkSmartPointer<vtkVolume> getNawVolume() { return vol->getNewVolume(); }
vtkSmartPointer<vtkActor> getPanelActor(int i) { return camsContainer[i].getActor(); };
vtkSmartPointer<vtkActor> getNewPanelActor(int i) { return camsContainer[i].getNewactor(); };
vtkSmartPointer<vtkLight> getLight(int i) { return lights[i].getLight(); };
Expand Down
Loading

0 comments on commit 329568b

Please sign in to comment.