Skip to content

Commit

Permalink
Added KinematicsHelper module
Browse files Browse the repository at this point in the history
  • Loading branch information
ncguilbeault committed May 23, 2024
1 parent 4b51df3 commit 732ef3a
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Collections.Generic;
using System.Reflection;

namespace Bonsai.ML.LinearDynamicalSystems.Kinematics
{
/// <summary>
/// Helper class to get the names of the state components and kinematic components using reflection
/// </summary>
public static class KinematicsHelper
{
/// <summary>
/// Gets the names of the state components defined in the kinematic component class
/// </summary>
public static List<string> GetStateComponents()
{
List<string> stateComponents = new List<string>();

foreach (PropertyInfo property in typeof(KinematicComponent).GetProperties())
{
if (property.PropertyType == typeof(StateComponent))
{
stateComponents.Add(property.Name);
}
}
return stateComponents;
}

/// <summary>
/// Gets the names of the kinematic components defined in the kinematic state class
/// </summary>
public static List<string> GetKinematicComponents()
{
List<string> kinematicComponents = new List<string>();

foreach (PropertyInfo property in typeof(KinematicState).GetProperties())
{
if (property.PropertyType == typeof(KinematicComponent))
{
kinematicComponents.Add(property.Name);
}
}
return kinematicComponents;
}
}
}

0 comments on commit 732ef3a

Please sign in to comment.