MRPT / mvsim

Vehicle and mobile robotics simulator. C++ & Python API. Use it as a standalone application or via ROS 1 or ROS 2
https://mvsimulator.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
301 stars 46 forks source link

mvsim compilation error ContainerReadOnlyProxyAccessor has no member named resize #3

Closed Logrus closed 8 years ago

Logrus commented 8 years ago

Problem

mvsim package doesn't compile via catkin_make with the following error message:

[ 82%] Building CXX object mvsim/libmvsim/CMakeFiles/mvsim.dir/src/Sensors/LaserScanner.cpp.o
/home/jun/mrpt_ros_packages/src/mvsim/libmvsim/src/Sensors/LaserScanner.cpp: In member function ‘virtual void mvsim::LaserScanner::loadConfigFrom(const rapidxml::xml_node<char>*)’:
/home/jun/mrpt_ros_packages/src/mvsim/libmvsim/src/Sensors/LaserScanner.cpp:66:20: error: ‘struct mrpt::utils::ContainerReadOnlyProxyAccessor<std::vector<float> >’ has no member named ‘resize’
  m_scan_model.scan.resize(nRays);
                    ^
/home/jun/mrpt_ros_packages/src/mvsim/libmvsim/src/Sensors/LaserScanner.cpp:67:26: error: ‘struct mrpt::utils::ContainerReadOnlyProxyAccessor<std::vector<char> >’ has no member named ‘resize’
  m_scan_model.validRange.resize(nRays);
                          ^
/home/jun/mrpt_ros_packages/src/mvsim/libmvsim/src/Sensors/LaserScanner.cpp: In member function ‘virtual void mvsim::LaserScanner::simul_post_timestep(const mvsim::TSimulContext&)’:
/home/jun/mrpt_ros_packages/src/mvsim/libmvsim/src/Sensors/LaserScanner.cpp:199:13: error: ‘struct mrpt::utils::ContainerReadOnlyProxyAccessor<std::vector<float> >’ has no member named ‘resize’
   scan.scan.resize(nRays);
             ^
/home/jun/mrpt_ros_packages/src/mvsim/libmvsim/src/Sensors/LaserScanner.cpp:200:19: error: ‘struct mrpt::utils::ContainerReadOnlyProxyAccessor<std::vector<char> >’ has no member named ‘resize’
   scan.validRange.resize(nRays);
                   ^
/home/jun/mrpt_ros_packages/src/mvsim/libmvsim/src/Sensors/LaserScanner.cpp:211:23: error: assignment of read-only location ‘scan.mrpt::obs::CObservation2DRangeScan::validRange.mrpt::utils::ContainerReadOnlyProxyAccessor<STLCONTAINER>::operator[]<std::vector<char> >(((int)i))’
    scan.validRange[i] = callback.m_hit ? 1:0;
                       ^
/home/jun/mrpt_ros_packages/src/mvsim/libmvsim/src/Sensors/LaserScanner.cpp:213:30: error: invalid initialization of reference of type ‘float&’ from expression of type ‘const value_type {aka const float}’
    float &range = scan.scan[i];
                              ^
/home/jun/mrpt_ros_packages/src/mvsim/libmvsim/src/Sensors/LaserScanner.cpp:237:17: error: ‘struct mrpt::utils::ContainerReadOnlyProxyAccessor<std::vector<float> >’ has no member named ‘assign’
  lastScan->scan.assign(nRays,maxRange);
                 ^
/home/jun/mrpt_ros_packages/src/mvsim/libmvsim/src/Sensors/LaserScanner.cpp:238:23: error: ‘struct mrpt::utils::ContainerReadOnlyProxyAccessor<std::vector<char> >’ has no member named ‘assign’
  lastScan->validRange.assign(nRays, 0);
                       ^
/home/jun/mrpt_ros_packages/src/mvsim/libmvsim/src/Sensors/LaserScanner.cpp:248:23: error: assignment of read-only location ‘lastScan->mrpt::obs::CObservation2DRangeScan::scan.mrpt::utils::ContainerReadOnlyProxyAccessor<STLCONTAINER>::operator[]<std::vector<float> >(((int)i))’
     lastScan->scan[i] = std::min(lastScan->scan[i], it->scan[i]);
                       ^
/home/jun/mrpt_ros_packages/src/mvsim/libmvsim/src/Sensors/LaserScanner.cpp:249:29: error: assignment of read-only location ‘lastScan->mrpt::obs::CObservation2DRangeScan::validRange.mrpt::utils::ContainerReadOnlyProxyAccessor<STLCONTAINER>::operator[]<std::vector<char> >(((int)i))’
     lastScan->validRange[i] = 1; // valid
                             ^
make[2]: *** [mvsim/libmvsim/CMakeFiles/mvsim.dir/src/Sensors/LaserScanner.cpp.o] Error 1
make[1]: *** [mvsim/libmvsim/CMakeFiles/mvsim.dir/all] Error 2
make: *** [all] Error 2

Reason

After this commit https://github.com/MRPT/mrpt/commit/12c210cefd8edf33909a590b2db8efdb1fc079a2 the interface has changed.

Proposed solution

After briefly looking over the changes in original commit I think this should fix the problem https://github.com/Logrus/mvsim/commit/ff167a02387e72c5498e99197e1e29b2001a08eb but it is worth looking over the commit, since I am not really familiar with this part.

jlblancoc commented 8 years ago

Closed after PR #4