code-iai / ROSIntegrationVision

Support for ROS-enabled RGBD data acquisition in Unreal Engine Projects
75 stars 34 forks source link

Compilation issue on Windows for UVisionComponent::convertDepth #28

Closed harveybia closed 4 years ago

harveybia commented 4 years ago

I tried adding the plugin to my existing project, my CPU has F16C Intrinsic Support but I'm getting compilation issues when rebuilding the project:

Building UE4Editor...
Using Visual Studio 2019 14.26.28806 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
Building 6 actions with 8 processes...
  @progress 'Compiling C++ source code...' 0%
  @progress 'Compiling C++ source code...' 17%
  [1/6] Default.rc2
  @progress 'Compiling C++ source code...' 33%
  [2/6] Module.ROSIntegrationVision.cpp
  E:/<redacted>/Plugins/ROSIntegrationVision/Source/ROSIntegrationVision/Private/VisionComponent.cpp(749): error C2678: binary '/': no operator found which takes a left-hand operand of type '__m128' (or there is no acceptable conversion)
  E:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\Misc/FrameRate.h(242): note: could be 'double operator /(FFrameTime,FFrameRate)'
  E:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\Misc/FrameRate.h(222): note: or       'TRange<double> operator /(const TRange<FFrameNumber> &,FFrameRate)'
  E:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\Misc/FrameRate.h(217): note: or       'double operator /(FFrameNumber,FFrameRate)'
  E:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\Misc/FrameRate.h(212): note: or       'FFrameRate operator /(FFrameRate,FFrameRate)'
  E:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\Misc/FrameTime.h(276): note: or       'FFrameTime operator /(FFrameTime,float)'
  E:/<redacted>/Plugins/ROSIntegrationVision/Source/ROSIntegrationVision/Private/VisionComponent.cpp(750): note: while trying to match the argument list '(__m128, int)'
  @progress 'Compiling C++ source code...' 50%
  [3/6] Module.ROSIntegrationVision.gen.cpp
LogInit: Warning: Still incompatible or missing module: ROSIntegrationVision
LogCore: Engine exit requested (reason: EngineExit() was called)
LogExit: Preparing to exit.

I'm not sure if I am missing some dependencies but I found a workaround to solve this problem:

Change:

void UVisionComponent::convertDepth(const uint16_t *in, __m128 *out) const
{
  const size_t size = (Width * Height) / 4;
  for (size_t i = 0; i < size; ++i, in += 4, ++out)
  {
    // Divide by 100 here in order to convert UU (cm) into ROS units (m)
    *out = _mm_cvtph_ps(_mm_set_epi16(
      0, 0, 0, 0, *(in + 3), *(in + 2), *(in + 1), *(in + 0))) / 100;
  }
}

to:

void UVisionComponent::convertDepth(const uint16_t *in, __m128 *out) const
{
  const size_t size = (Width * Height) / 4;
  for (size_t i = 0; i < size; ++i, in += 4, ++out)
  {
    // Divide by 100 here in order to convert UU (cm) into ROS units (m)
    *out = _mm_cvtph_ps(
      _mm_div_epi16(
        _mm_set_epi16(0, 0, 0, 0, *(in + 3), *(in + 2), *(in + 1), *(in + 0)),
        _mm_set_epi16(100, 100, 100, 100, 100, 100, 100, 100)
      )
    );// / 100;
  }
}

I checked the depth output and the value seem correct. Has anyone else experienced this issue? Should I open a pull request for this?

harveybia commented 4 years ago

Fix can be found at: https://github.com/harveybia/ROSIntegrationVision/commit/cd4ced2bdb4d18752305d5f0f5fe3118f09fe8bd

Sanic commented 4 years ago

Hi @harveybia Thanks for your report and the workaround. On which UE4 version are you running this?

harveybia commented 4 years ago

Hi @harveybia Thanks for your report and the workaround. On which UE4 version are you running this?

My UE4 version is: 4.25.1

Tim-Fronsee commented 4 years ago

@harveybia

I can confirm I also receive the same compiler error on 4.25.3 on Windows.
Your solution appears to resolve it, thank you.

Mind opening up a PR with the fix?