Camera fixes to SDF to USD converter#787
Conversation
Signed-off-by: ahcorde <ahcorde@gmail.com>
| usdCamera.CreateHorizontalApertureAttr().Set( | ||
| static_cast<float>(sdfCamera->HorizontalFov().Degree())); | ||
|
|
||
| // TODO(adlarkin) Do I need to handle the following in USD | ||
| // (I don't think there's an SDF equivalent): | ||
| // * horizontal and vertical aperture (there's also an offset for these) |
There was a problem hiding this comment.
| usdCamera.CreateHorizontalApertureAttr().Set( | |
| static_cast<float>(sdfCamera->HorizontalFov().Degree())); | |
| // TODO(adlarkin) Do I need to handle the following in USD | |
| // (I don't think there's an SDF equivalent): | |
| // * horizontal and vertical aperture (there's also an offset for these) | |
| usdCamera.CreateHorizontalApertureAttr().Set( | |
| static_cast<float>(sdfCamera->HorizontalFov().Degree())); |
I believe the TODO can be removed since you addressed the horizontal aperture attribute.
| // TODO(adlarkin) check units to make sure they match (no documented units for SDF) | ||
| usdCamera.CreateFocalLengthAttr().Set( | ||
| static_cast<float>(sdfCamera->LensFocalLength())); | ||
| static_cast<float>(sdfCamera->LensFocalLength() * 10)); |
There was a problem hiding this comment.
Can you add a comment that explains why you are multiplying by 10? I assume it's because SDF and USD use different units. It would be nice to have this documented in case someone else has to look at this code later.
| @@ -44,11 +44,14 @@ namespace usd | |||
|
|
|||
| // TODO(adlarkin) check units to make sure they match (no documented units for SDF) | |||
There was a problem hiding this comment.
If the conversions below seem to be okay regarding units, can we remove this comment?
| ignition::math::Pose3d poseCamera(0, 0, 0, 1.57, 0, -1.57); | ||
| usd::SetPose(poseCamera * _sensor.RawPose(), _stage, sdfSensorPath); |
There was a problem hiding this comment.
I just read the following note in the UsdGeomCamera docs:
Cameras in USD are always "Y up", regardless of the stage's orientation (i.e. UsdGeomGetStageUpAxis()).
This means that the inverse of 'camXform' (the VIEW half of the MODELVIEW transform in OpenGL parlance) will transform the world such that the camera is at the origin, looking down the -Z axis, with +Y as the up axis, and +X pointing to the right.
This describes a right handed coordinate system.
So, are you applying the rotations here to fix the default camera direction? If so, that makes sense, but would you mind adding a comment that explains why this has to be done? You can even reference the link I just included above in the comment if that's easiest
Signed-off-by: ahcorde <ahcorde@gmail.com>
Signed-off-by: ahcorde <ahcorde@gmail.com>
Signed-off-by: ahcorde <ahcorde@gmail.com>
|
I converted this file https://app.ignitionrobotics.org/OpenRobotics/fuel/models/SOPHISTICATED_ENGINEERING_X2_SENSOR_CONFIG_1 and cameras are in the right poses |
There was a problem hiding this comment.
I converted this file https://app.ignitionrobotics.org/OpenRobotics/fuel/models/SOPHISTICATED_ENGINEERING_X2_SENSOR_CONFIG_1 and cameras are in the right poses
How are you testing this? I am using the following SDF file:
ugv.sdf
<?xml version="1.0" ?>
<sdf version="1.6">
<world name="empty">
<physics name="1ms" type="ignored">
<max_step_size>0.001</max_step_size>
<real_time_factor>1.0</real_time_factor>
</physics>
<plugin
filename="ignition-gazebo-physics-system"
name="ignition::gazebo::systems::Physics">
</plugin>
<plugin
filename="ignition-gazebo-user-commands-system"
name="ignition::gazebo::systems::UserCommands">
</plugin>
<plugin
filename="ignition-gazebo-scene-broadcaster-system"
name="ignition::gazebo::systems::SceneBroadcaster">
</plugin>
<plugin
filename="ignition-gazebo-contact-system"
name="ignition::gazebo::systems::Contact">
</plugin>
<light type="directional" name="sun">
<cast_shadows>true</cast_shadows>
<pose>0 0 10 0 0 0</pose>
<diffuse>0.8 0.8 0.8 1</diffuse>
<specular>0.2 0.2 0.2 1</specular>
<attenuation>
<range>1000</range>
<constant>0.9</constant>
<linear>0.01</linear>
<quadratic>0.001</quadratic>
</attenuation>
<direction>-0.5 0.1 -0.9</direction>
</light>
<model name="ground_plane">
<static>true</static>
<link name="link">
<collision name="collision">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>100 100</size>
</plane>
</geometry>
</collision>
<visual name="visual">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>100 100</size>
</plane>
</geometry>
<material>
<ambient>0.8 0.8 0.8 1</ambient>
<diffuse>0.8 0.8 0.8 1</diffuse>
<specular>0.8 0.8 0.8 1</specular>
</material>
</visual>
</link>
</model>
<include>
<name>UGV</name>
<pose>0 0 0 0 0 0</pose>
<uri>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/SOPHISTICATED_ENGINEERING_X2_SENSOR_CONFIG_1</uri>
</include>
</world>
</sdf>I merged in #770 locally since the included model has materials, and then ran the converter:
./usdConverter ugv.sdf ugv.usda
But, there is a box surrounding the model when I run usdview.usda:
Signed-off-by: ahcorde <ahcorde@gmail.com>


Signed-off-by: ahcorde ahcorde@gmail.com
🦟 Bug fix
Summary
Fixes camera orientation
Checklist
codecheckpassed (See contributing)Note to maintainers: Remember to use Squash-Merge