Skip to content

Commit

Permalink
improved example file and plugin
Browse files Browse the repository at this point in the history
Signed-off-by: frederik <[email protected]>
  • Loading branch information
frede791 committed Oct 30, 2023
1 parent 6e5d430 commit aa9f600
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 25 deletions.
18 changes: 9 additions & 9 deletions examples/worlds/advanced_lift_drag_system.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ gz topic -e -t /world/advanced_lift_drag/model/advanced_lift_drag_demo_model/joi
<geometry>
<mesh>
<scale>0.1 0.1 0.1</scale>
<uri>model://rc_cessna/meshes/body.dae</uri>
<uri>https://fuel.gazebosim.org/1.0/frede791/models/Advanced%20Plane/tip/files/meshes/body.dae</uri>
</mesh>
</geometry>
<material>
Expand Down Expand Up @@ -184,7 +184,7 @@ gz topic -e -t /world/advanced_lift_drag/model/advanced_lift_drag_demo_model/joi
<geometry>
<mesh>
<scale>1 1 1</scale>
<uri>model://rc_cessna/meshes/iris_prop_ccw.dae</uri>
<uri>https://fuel.gazebosim.org/1.0/frede791/models/Advanced%20Plane/tip/files/meshes/iris_prop_ccw.dae</uri>
</mesh>
</geometry>
<material>
Expand Down Expand Up @@ -232,7 +232,7 @@ gz topic -e -t /world/advanced_lift_drag/model/advanced_lift_drag_demo_model/joi
<geometry>
<mesh>
<scale>0.1 0.1 0.1</scale>
<uri>model://rc_cessna/meshes/left_aileron.dae</uri>
<uri>https://fuel.gazebosim.org/1.0/frede791/models/Advanced%20Plane/tip/files/meshes/left_aileron.dae</uri>
</mesh>
</geometry>
<material>
Expand Down Expand Up @@ -260,7 +260,7 @@ gz topic -e -t /world/advanced_lift_drag/model/advanced_lift_drag_demo_model/joi
<geometry>
<mesh>
<scale>0.1 0.1 0.1</scale>
<uri>model://rc_cessna/meshes/right_aileron.dae</uri>
<uri>https://fuel.gazebosim.org/1.0/frede791/models/Advanced%20Plane/tip/files/meshes/right_aileron.dae</uri>
</mesh>
</geometry>
<material>
Expand Down Expand Up @@ -288,7 +288,7 @@ gz topic -e -t /world/advanced_lift_drag/model/advanced_lift_drag_demo_model/joi
<geometry>
<mesh>
<scale>0.1 0.1 0.1</scale>
<uri>model://rc_cessna/meshes/left_flap.dae</uri>
<uri>https://fuel.gazebosim.org/1.0/frede791/models/Advanced%20Plane/tip/files/meshes/left_flap.dae</uri>
</mesh>
</geometry>
<material>
Expand Down Expand Up @@ -316,7 +316,7 @@ gz topic -e -t /world/advanced_lift_drag/model/advanced_lift_drag_demo_model/joi
<geometry>
<mesh>
<scale>0.1 0.1 0.1</scale>
<uri>model://rc_cessna/meshes/right_flap.dae</uri>
<uri>https://fuel.gazebosim.org/1.0/frede791/models/Advanced%20Plane/tip/files/meshes/right_flap.dae</uri>
</mesh>
</geometry>
<material>
Expand Down Expand Up @@ -344,7 +344,7 @@ gz topic -e -t /world/advanced_lift_drag/model/advanced_lift_drag_demo_model/joi
<geometry>
<mesh>
<scale>0.1 0.1 0.1</scale>
<uri>model://rc_cessna/meshes/elevators.dae</uri>
<uri>https://fuel.gazebosim.org/1.0/frede791/models/Advanced%20Plane/tip/files/meshes/elevators.dae</uri>
</mesh>
</geometry>
<material>
Expand Down Expand Up @@ -372,7 +372,7 @@ gz topic -e -t /world/advanced_lift_drag/model/advanced_lift_drag_demo_model/joi
<geometry>
<mesh>
<scale>0.1 0.1 0.1</scale>
<uri>model://rc_cessna/meshes/rudder.dae</uri>
<uri>https://fuel.gazebosim.org/1.0/frede791/models/Advanced%20Plane/tip/files/meshes/rudder.dae</uri>
</mesh>
</geometry>
<material>
Expand Down Expand Up @@ -678,4 +678,4 @@ gz topic -e -t /world/advanced_lift_drag/model/advanced_lift_drag_demo_model/joi
</plugin>
</model>
</world>
</sdf>
</sdf>
42 changes: 28 additions & 14 deletions src/systems/advanced_lift_drag/AdvancedLiftDrag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
* @author: Karthik Srivatsan, Frederik Markus
* @version: 1.1
*
Expand Down Expand Up @@ -346,7 +346,7 @@ void AdvancedLiftDragPrivate::Load(const EntityComponentManager &_ecm,
if (entities.empty())
{
gzerr << "Joint with name[" << ctrl_surface_name << "] not found. "
<< "The LiftDrag will not generate forces\n";
<< "The LiftDrag will not generate forces.\n";
this->validConfig = false;
return;
}
Expand All @@ -361,7 +361,8 @@ void AdvancedLiftDragPrivate::Load(const EntityComponentManager &_ecm,
components::Joint::typeId))
{
this->controlJointEntity = kNullEntity;
gzerr << "Entity with name[" << ctrl_surface_name << "] is not a joint\n";
gzerr << "Entity with name[" << ctrl_surface_name
<< "] is not a joint.\n";
this->validConfig = false;
return;
}
Expand Down Expand Up @@ -400,9 +401,17 @@ void AdvancedLiftDragPrivate::Load(const EntityComponentManager &_ecm,
this->area = _sdf->Get<double>("area", this->area).first;

// blade forward (-drag) direction in link frame
this->forward =
_sdf->Get<math::Vector3d>("forward", this->forward).first;
this->forward.Normalize();
if(this->forward.Length() != 0){
this->forward =
_sdf->Get<math::Vector3d>("forward", this->forward).first;
this->forward.Normalize();
}
else
{
gzerr << "Forward vector length is zero. This is not valid.\n";
this->validConfig = false;
return;
}

// blade upward (+lift) direction in link frame
this->upward = _sdf->Get<math::Vector3d>(
Expand All @@ -422,7 +431,7 @@ void AdvancedLiftDragPrivate::Load(const EntityComponentManager &_ecm,
if (entities.empty())
{
gzerr << "Link with name[" << linkName << "] not found. "
<< "The AdvancedLiftDrag will not generate forces\n";
<< "The AdvancedLiftDrag will not generate forces.\n";
this->validConfig = false;
return;
}
Expand All @@ -437,14 +446,14 @@ void AdvancedLiftDragPrivate::Load(const EntityComponentManager &_ecm,
components::Link::typeId))
{
this->linkEntity = kNullEntity;
gzerr << "Entity with name[" << linkName << "] is not a link\n";
gzerr << "Entity with name[" << linkName << "] is not a link.\n";
this->validConfig = false;
return;
}
}
else
{
gzerr << "The AdvancedLiftDrag system requires the 'link_name' parameter\n";
gzerr << "AdvancedLiftDrag system requires the 'link_name' parameter.\n";
this->validConfig = false;
return;
}
Expand Down Expand Up @@ -503,6 +512,11 @@ void AdvancedLiftDragPrivate::Update(EntityComponentManager &_ecm)
body_y_axis)*body_y_axis;

// Compute dynamic pressure
if(velInLDPlane.Length() == 0){
gzerr << "In-plane velocity of vehicle cannot be 0.\n";
this->validConfig = false;
return;
}
const double speedInLDPlane = velInLDPlane.Length();

// Define stability frame: X is in-plane velocity, Y is the same as body Y,
Expand Down Expand Up @@ -530,6 +544,11 @@ void AdvancedLiftDragPrivate::Update(EntityComponentManager &_ecm)
{
AngVel = _ecm.Component<components::AngularVelocity>(this->linkEntity);
}
if(AngVel == nullptr){
gzerr << "Angular Velocity cannot be null.\n";
this->validConfig = false;
return;
}

double rr = AngVel->Data()[0]; // Roll rate
double pr = -1*AngVel->Data()[1]; // Pitch rate
Expand Down Expand Up @@ -818,8 +837,3 @@ GZ_ADD_PLUGIN(AdvancedLiftDrag,
System,
AdvancedLiftDrag::ISystemConfigure,
AdvancedLiftDrag::ISystemPreUpdate)

GZ_ADD_PLUGIN_ALIAS(AdvancedLiftDrag, "gz::sim::systems::AdvancedLiftDrag")

// TODO(CH3): Deprecated, remove on version 8
GZ_ADD_PLUGIN_ALIAS(AdvancedLiftDrag, "ignition::systems::AdvancedLiftDrag")
3 changes: 1 addition & 2 deletions src/systems/advanced_lift_drag/AdvancedLiftDrag.hh
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,4 @@ namespace systems
}
}
}

#endif
#endif

0 comments on commit aa9f600

Please sign in to comment.