Skip to content

Commit

Permalink
code review: rename methods; remove obsolete
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Hanca <[email protected]>
  • Loading branch information
jhanca-robotecai committed Dec 20, 2023
1 parent 8d43da0 commit 88bfa9c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace ROS2::SDFormat
{
namespace Parser
{
VehicleDynamics::VehicleConfiguration GetConfiguration(
VehicleDynamics::VehicleConfiguration CreateVehicleConfiguration(
const sdf::ElementPtr element, const sdf::Model& sdfModel, const CreatedEntitiesMap& createdEntities)
{
VehicleDynamics::VehicleConfiguration configuration;
Expand All @@ -47,7 +47,7 @@ namespace ROS2::SDFormat
else
{
AZ_Warning(
"ROS2SkidSteeringModelPluginHook",
"CreateVehicleConfiguration",
false,
"Cannot find entity ID for one of the joints: %s or %s",
jointNameLeft.c_str(),
Expand Down Expand Up @@ -113,7 +113,7 @@ namespace ROS2::SDFormat
{
constexpr float epsilon = 0.001f;
AZ_Warning(
"ROS2SkidSteeringModelPluginHook",
"CreateVehicleConfiguration",
fabsf(configuration.m_wheelbase - wheelSeparation->Get<float>()) < epsilon,
"Different wheel separation distances in one model are not supported.");
}
Expand All @@ -130,22 +130,20 @@ namespace ROS2::SDFormat
wheelDiameter = wheelDiameter->GetNextElement("wheel_diameter");
}
AZ_Warning(
"ROS2SkidSteeringModelPluginHook",
"CreateVehicleConfiguration",
wheelPairs == configuration.m_axles.size(),
"VehicleConfiguration parsing might be incorrect: expected %d axles, found %d.",
wheelPairs,
configuration.m_axles.size());
}

AZ_Warning(
"ROS2SkidSteeringModelPluginHook",
!configuration.m_axles.empty(),
"VehicleConfiguration parsing error: cannot find any axles.");
"CreateVehicleConfiguration", !configuration.m_axles.empty(), "VehicleConfiguration parsing error: cannot find any axles.");

return configuration;
}

VehicleDynamics::SkidSteeringModelLimits GetModelLimits(const sdf::ElementPtr element)
VehicleDynamics::SkidSteeringModelLimits CreateModelLimits(const sdf::ElementPtr element)
{
VehicleDynamics::SkidSteeringModelLimits modelLimits;
if (element->HasElement("wheelAcceleration"))
Expand All @@ -158,7 +156,7 @@ namespace ROS2::SDFormat
}
else
{
AZ_Warning("ROS2SkidSteeringModelPluginHook", false, "VehicleConfiguration parsing error: cannot determine model limits.");
AZ_Warning("CreateModelLimits", false, "VehicleConfiguration parsing error: cannot determine model limits.");
}

return modelLimits;
Expand All @@ -177,8 +175,9 @@ namespace ROS2::SDFormat
{
// Parse parameters
const sdf::ElementPtr element = sdfPlugin.Element();
VehicleDynamics::VehicleConfiguration vehicleConfiguration = Parser::GetConfiguration(element, sdfModel, createdEntities);
VehicleDynamics::SkidSteeringModelLimits modelLimits = Parser::GetModelLimits(element);
VehicleDynamics::VehicleConfiguration vehicleConfiguration =
Parser::CreateVehicleConfiguration(element, sdfModel, createdEntities);
VehicleDynamics::SkidSteeringModelLimits modelLimits = Parser::CreateModelLimits(element);

// Create required components
HooksUtils::CreateComponent<ROS2FrameComponent>(entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ namespace ROS2::VehicleDynamics
}
}

SkidSteeringModelLimits::SkidSteeringModelLimits(
const float linearLimit, const float angularLimit, const float linearAcceleration, const float angularAcceleration)
{
m_linearLimit = AZStd::clamp(linearLimit, 0.0f, 100.0f);
m_angularLimit = AZStd::clamp(angularLimit, 0.0f, 10.0f);
m_linearAcceleration = AZStd::clamp(linearAcceleration, 0.0f, 100.0f);
m_angularAcceleration = AZStd::clamp(angularAcceleration, 0.0f, 100.0f);
}

VehicleInputs SkidSteeringModelLimits::LimitState(const VehicleInputs& inputState) const
{
VehicleInputs ret = inputState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ namespace ROS2::VehicleDynamics
public:
AZ_RTTI(SkidSteeringModelLimits, "{23420EFB-BB62-48C7-AD37-E50580A53C39}", VehicleModelLimits);
SkidSteeringModelLimits() = default;
SkidSteeringModelLimits(
const float linearLimit, const float angularLimit, const float linearAcceleration, const float angularAcceleration);

static void Reflect(AZ::ReflectContext* context);

Expand Down

0 comments on commit 88bfa9c

Please sign in to comment.