
I am trying to simulate a small UAV flying over a terrain, with a lidar (ray) sensor and a camera. I have been successful with a straight flight, but the simulation is very slow. The sensors have a rate of 10 Hz, but the images and lidar data are generated with several seconds 10-20 between frames. This is slow, but tolerable. When I try a banked turn, the simulation slows to a frame every 20-30 minutes. I am using the .sdf file and plugin below. The plugin was generated using a Matlab script to create the banked turn. The heightmap (mtn_height.jpg) is at a resolution of 2049x2049 pixels and the texture (texture_trimmed.png) is of resolution 3993x3992 pixels.
Why is this so slow? I realize this is a lot of computation, but I am amazed that the banked turn takes so much longer than the straight flight over the same terrain. Is there some way to speed this up? Am I using a very inefficient method?
I thought I read that the ray sensor could be sped up using a GPU. Is this available, and if so, how do I get and use it?
Thanks.
1.0 1.0 1.0 1 0.5 0.5 0.5 1 false 1000 0.0005 0.3<model name="heightmap"> <static>true</static> <link name="height"> <collision name="collision"> <geometry> <heightmap> <uri>file://media/materials/textures/wasatch_calls_fort_canyon/mtn_height.jpg</uri> <size>1000 1000 530</size> <pos>0 0 100</pos> </heightmap> </geometry> </collision> <visual name="visual_abcedf"> <cast_shadows>false</cast_shadows> <geometry> <heightmap> <use_terrain_paging>false</use_terrain_paging> <texture> <diffuse>file://media/materials/textures/wasatch_calls_fort_canyon/texture_trimmed.png</diffuse> <normal>file://media/materials/textures/flat_normal.png</normal> <size>1000</size> </texture> <uri>file://media/materials/textures/wasatch_calls_fort_canyon/mtn_height.jpg</uri> <size>1000 1000 530</size> <pos>0 0 100</pos> </heightmap> </geometry> </visual> </link> </model> <model name='texelcamera'> <link name='link'> <pose frame=''>0 0 0 0 1.57079 0</pose> <inertial> <inertia> <ixx>1</ixx> <ixy>0</ixy> <ixz>0</ixz> <iyy>1</iyy> <iyz>0</iyz> <izz>1</izz> </inertia> <mass>0.1</mass> <pose frame=''>0 0 0 0 -0 0</pose> </inertial> <self_collide>0</self_collide> <kinematic>0</kinematic> <sensor name='camera' type='camera'> <pose frame='texsensor'>0 0 0 0 0 0</pose> <camera name='__default__'> <horizontal_fov>0.35</horizontal_fov> <image> <width>1024</width> <height>350</height> <format>BGR_INT8</format> </image> <clip> <near>0.1</near> <far>2000</far> </clip> </camera> <always_on>true</always_on> <update_rate>10</update_rate> <!--For 1.0 m spacing --> <visualize>true</visualize> </sensor> <sensor name='laser' type='ray'> <pose frame='texsensor'>0 0 0 0 0 0</pose> <ray> <scan> <horizontal> <samples>210</samples> <resolution>1</resolution> <min_angle>-0.175</min_angle> <max_angle>0.175</max_angle> </horizontal> <vertical> <samples>1</samples> <min_angle>0</min_angle> <max_angle>0</max_angle> </vertical> </scan> <range> <min>0.08</min> <max>2000</max> <resolution>0.01</resolution> </range> </ray> <always_on>true</always_on> <update_rate>10</update_rate> <!-- For 1.0 m spacing --> <visualize>true</visualize> </sensor> <gravity>false</gravity> </link> <static>false</static> <allow_auto_disable>true</allow_auto_disable> <plugin name='push_animate' filename='libanimated_box.so'/> <pose frame=''>0 0 0 0 0 0</pose> </model> #include <boost/bind.hpp> #include <gazebo/gazebo.hh> #include <ignition/math.hh> #include <gazebo/physics/physics.hh> #include <gazebo/common/common.hh> #include <stdio.h>
namespace gazebo { class AnimatedBox : public ModelPlugin { public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /_sdf/) { this->model = _parent; gazebo::common::PoseAnimationPtr anim( new gazebo::common::PoseAnimation("test", 20.455694, true));
gazebo::common::PoseKeyFrame *key; key = anim->CreateKeyFrame(0.000000); key->Translation(ignition::math::Vector3d(-188.466132, -229.347724, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.001306, 0.000000, 1.636880)); key = anim->CreateKeyFrame(0.343233); key->Translation(ignition::math::Vector3d(-188.806868, -224.210510, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.001306, 0.000000, 1.636880)); key = anim->CreateKeyFrame(0.686442); key->Translation(ignition::math::Vector3d(-189.146074, -219.073566, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.001446, 0.000000, 1.636571)); key = anim->CreateKeyFrame(1.029624); key->Translation(ignition::math::Vector3d(-189.483589, -213.936920, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.001606, 0.000000, 1.636229)); key = anim->CreateKeyFrame(1.372775); key->Translation(ignition::math::Vector3d(-189.819226, -208.800605, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.001790, 0.000000, 1.635849)); key = anim->CreateKeyFrame(1.715893); key->Translation(ignition::math::Vector3d(-190.152768, -203.664659, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.002003, 0.000000, 1.635423)); key = anim->CreateKeyFrame(2.058973); key->Translation(ignition::math::Vector3d(-190.483968, -198.529127, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.002251, 0.000000, 1.634947)); key = anim->CreateKeyFrame(2.402011); key->Translation(ignition::math::Vector3d(-190.812536, -193.394058, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.002541, 0.000000, 1.634410)); key = anim->CreateKeyFrame(2.745001); key->Translation(ignition::math::Vector3d(-191.138135, -188.259513, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.002883, 0.000000, 1.633802)); key = anim->CreateKeyFrame(3.087938); key->Translation(ignition::math::Vector3d(-191.460367, -183.125562, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.003287, 0.000000, 1.633111)); key = anim->CreateKeyFrame(3.430814); key->Translation(ignition::math::Vector3d(-191.778762, -177.992287, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.003768, 0.000000, 1.632321)); key = anim->CreateKeyFrame(3.773621); key->Translation(ignition::math::Vector3d(-192.092761, -172.859788, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.004346, 0.000000, 1.631412)); key = anim->CreateKeyFrame(4.116347); key->Translation(ignition::math::Vector3d(-192.401692, -167.728182, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.005046, 0.000000, 1.630361)); key = anim->CreateKeyFrame(4.458981); key->Translation(ignition::math::Vector3d(-192.704743, -162.597613, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.005900, 0.000000, 1.629135)); key = anim->CreateKeyFrame(4.801508); key->Translation(ignition::math::Vector3d(-193.000927, -157.468254, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.006951, 0.000000, 1.627698)); key = anim->CreateKeyFrame(5.143909); key->Translation(ignition::math::Vector3d(-193.289027, -152.340322, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.008259, 0.000000, 1.625996)); key = anim->CreateKeyFrame(5.486163); key->Translation(ignition::math::Vector3d(-193.567534, -147.214080, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.009901, 0.000000, 1.623966)); key = anim->CreateKeyFrame(5.828241); key->Translation(ignition::math::Vector3d(-193.834557, -142.089864, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.011985, 0.000000, 1.621521)); key = anim->CreateKeyFrame(6.170109); key->Translation(ignition::math::Vector3d(-194.087702, -136.968094, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.014663, 0.000000, 1.618545)); key = anim->CreateKeyFrame(6.511724); key->Translation(ignition::math::Vector3d(-194.323901, -131.849313, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.018143, 0.000000, 1.614884)); key = anim->CreateKeyFrame(6.853032); key->Translation(ignition::math::Vector3d(-194.539184, -126.734220, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.022717, 0.000000, 1.610329)); key = anim->CreateKeyFrame(7.193965); key->Translation(ignition::math::Vector3d(-194.728355, -121.623731, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.028796, 0.000000, 1.604592)); key = anim->CreateKeyFrame(7.534435); key->Translation(ignition::math::Vector3d(-194.884545, -116.519057, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.036949, 0.000000, 1.597280)); key = anim->CreateKeyFrame(7.874337); key->Translation(ignition::math::Vector3d(-194.998599, -111.421813, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.047935, 0.000000, 1.587853)); key = anim->CreateKeyFrame(8.213537); key->Translation(ignition::math::Vector3d(-195.058279, -106.334157, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.062701, 0.000000, 1.575587)); key = anim->CreateKeyFrame(8.551884); key->Translation(ignition::math::Vector3d(-195.047285, -101.258963, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.082234, 0.000000, 1.559548)); key = anim->CreateKeyFrame(8.889219); key->Translation(ignition::math::Vector3d(-194.944278, -96.199992, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.107082, 0.000000, 1.538632)); key = anim->CreateKeyFrame(9.225412); key->Translation(ignition::math::Vector3d(-194.722415, -91.161980, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.136337, 0.000000, 1.511772)); key = anim->CreateKeyFrame(9.560434); key->Translation(ignition::math::Vector3d(-194.350424, -86.150439, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.166226, 0.000000, 1.478398)); key = anim->CreateKeyFrame(9.894446); key->Translation(ignition::math::Vector3d(-193.796629, -81.170955, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.189626, 0.000000, 1.439130)); key = anim->CreateKeyFrame(10.227859); key->Translation(ignition::math::Vector3d(-193.036358, -76.227878, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.198621, 0.000000, 1.396263)); key = anim->CreateKeyFrame(10.561273); key->Translation(ignition::math::Vector3d(-192.060147, -71.322877, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.189626, 0.000000, 1.353396)); key = anim->CreateKeyFrame(10.895285); key->Translation(ignition::math::Vector3d(-190.877460, -66.454284, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.166226, 0.000000, 1.314128)); key = anim->CreateKeyFrame(11.230307); key->Translation(ignition::math::Vector3d(-189.512969, -61.617747, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.136337, 0.000000, 1.280754)); key = anim->CreateKeyFrame(11.566500); key->Translation(ignition::math::Vector3d(-187.998351, -56.807682, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.107082, 0.000000, 1.253894)); key = anim->CreateKeyFrame(11.903835); key->Translation(ignition::math::Vector3d(-186.364876, -52.018575, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.082234, 0.000000, 1.232979)); key = anim->CreateKeyFrame(12.242182); key->Translation(ignition::math::Vector3d(-184.639389, -47.245692, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.062701, 0.000000, 1.216940)); key = anim->CreateKeyFrame(12.581382); key->Translation(ignition::math::Vector3d(-182.843227, -42.485271, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.047935, 0.000000, 1.204674)); key = anim->CreateKeyFrame(12.921284); key->Translation(ignition::math::Vector3d(-180.992690, -37.734437, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.036949, 0.000000, 1.195247)); key = anim->CreateKeyFrame(13.261754); key->Translation(ignition::math::Vector3d(-179.100019, -32.991033, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.028796, 0.000000, 1.187935)); key = anim->CreateKeyFrame(13.602687); key->Translation(ignition::math::Vector3d(-177.174367, -28.253444, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.022717, 0.000000, 1.182198)); key = anim->CreateKeyFrame(13.943995); key->Translation(ignition::math::Vector3d(-175.222601, -23.520460, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.018143, 0.000000, 1.177643)); key = anim->CreateKeyFrame(14.285610); key->Translation(ignition::math::Vector3d(-173.249920, -18.791164, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.014663, 0.000000, 1.173982)); key = anim->CreateKeyFrame(14.627478); key->Translation(ignition::math::Vector3d(-171.260294, -14.064856, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.011985, 0.000000, 1.171006)); key = anim->CreateKeyFrame(14.969556); key->Translation(ignition::math::Vector3d(-169.256789, -9.340995, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.009901, 0.000000, 1.168561)); key = anim->CreateKeyFrame(15.311810); key->Translation(ignition::math::Vector3d(-167.241800, -4.619159, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.008259, 0.000000, 1.166530)); key = anim->CreateKeyFrame(15.654211); key->Translation(ignition::math::Vector3d(-165.217219, 0.100986, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.006951, 0.000000, 1.164829)); key = anim->CreateKeyFrame(15.996738); key->Translation(ignition::math::Vector3d(-163.184553, 4.819705, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.005900, 0.000000, 1.163391)); key = anim->CreateKeyFrame(16.339372); key->Translation(ignition::math::Vector3d(-161.145020, 9.537214, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.005046, 0.000000, 1.162166)); key = anim->CreateKeyFrame(16.682098); key->Translation(ignition::math::Vector3d(-159.099607, 14.253685, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.004346, 0.000000, 1.161115)); key = anim->CreateKeyFrame(17.024905); key->Translation(ignition::math::Vector3d(-157.049126, 18.969263, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.003768, 0.000000, 1.160206)); key = anim->CreateKeyFrame(17.367781); key->Translation(ignition::math::Vector3d(-154.994249, 23.684066, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.003287, 0.000000, 1.159416)); key = anim->CreateKeyFrame(17.710718); key->Translation(ignition::math::Vector3d(-152.935536, 28.398192, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.002883, 0.000000, 1.158725)); key = anim->CreateKeyFrame(18.053708); key->Translation(ignition::math::Vector3d(-150.873455, 33.111725, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.002541, 0.000000, 1.158117)); key = anim->CreateKeyFrame(18.396746); key->Translation(ignition::math::Vector3d(-148.808405, 37.824734, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.002251, 0.000000, 1.157580)); key = anim->CreateKeyFrame(18.739826); key->Translation(ignition::math::Vector3d(-146.740724, 42.537279, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.002003, 0.000000, 1.157103)); key = anim->CreateKeyFrame(19.082944); key->Translation(ignition::math::Vector3d(-144.670699, 47.249411, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.001790, 0.000000, 1.156678)); key = anim->CreateKeyFrame(19.426095); key->Translation(ignition::math::Vector3d(-142.598581, 51.961174, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.001606, 0.000000, 1.156298)); key = anim->CreateKeyFrame(19.769277); key->Translation(ignition::math::Vector3d(-140.524585, 56.672605, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.001446, 0.000000, 1.155955)); key = anim->CreateKeyFrame(20.112485); key->Translation(ignition::math::Vector3d(-138.448896, 61.383738, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.001306, 0.000000, 1.155647)); key = anim->CreateKeyFrame(20.455694); key->Translation(ignition::math::Vector3d(-136.371679, 66.094602, 1250.000000)); key->Rotation(ignition::math::Quaterniond(0.001306, 0.000000, 1.155647)); _parent->SetAnimation(anim); } private: physics::ModelPtr model; private: event::ConnectionPtr updateConnection; }; GZ_REGISTER_MODEL_PLUGIN(AnimatedBox) }
Originally posted by sebudge on Gazebo Answers with karma: 36 on 2017-03-03
Post score: 0
Original comments
Comment by iche033 on 2017-03-03:
is it slow because of a low real time factor or low FPS?
Real time factor:
- increase max_step_size
- Reduce ode from default 50 to something lower (sacrifices accuracy)
FPS:
- turn off camera visualization by setting to false.
- reduce heightmap resolution
- reduce texture resolution
Comment by iche033 on 2017-03-03:
is it slow because of a low real time factor or low FPS?
Real time factor:
- increase max_step_size,
- Reduce ode from default 50 to something lower (sacrifices accuracy).
FPS:
- turn off camera visualization by setting to false,
- reduce heightmap resolution,
- reduce texture resolution.