Updated documentation

This commit is contained in:
Pascal Serrarens 2024-01-02 11:52:14 +01:00
parent 2d94f61c83
commit fc246c8f1c
9 changed files with 72 additions and 56 deletions

View File

@ -7,28 +7,26 @@ namespace Passer {
namespace RoboidControl { namespace RoboidControl {
/// @brief Activation function for control /// @brief Activation function for control
/// @note This is mainly for future use :-)
class Activation { class Activation {
public: public:
static float HeavisideStep(float inputValue, float bias = 0); // Range: {0,1} static float HeavisideStep(float inputValue, float bias = 0); // Range: {0,1}
static float Tanh(float inputValue); // Range: (-1, 1) static float Tanh(float inputValue); // Range: (-1, 1)
static float Sigmoid(float inputValue); // Range: (0, 1) static float Sigmoid(float inputValue); // Range: (0, 1)
static float Linear(float inputValue, float bias = 0, float range = 0); static float Linear(float inputValue, float bias = 0, float range = 0);
static float Quadratic(float inputValue, static float Quadratic(float inputValue, float bias = 0,
float bias = 0, float range = 0); // minValue = bias
float range = 0); // minValue = bias
static float ParticleLife(float minValue, static float ParticleLife(float minValue, float maxValue, float attraction,
float maxValue, float inputValue); // minValue = bias
float attraction,
float inputValue); // minValue = bias
}; };
} // namespace RoboidControl } // namespace RoboidControl
} // namespace Passer } // namespace Passer
using namespace Passer::RoboidControl; using namespace Passer::RoboidControl;
#endif #endif

View File

@ -43,7 +43,7 @@ include_directories(
add_library(RoboidControl STATIC add_library(RoboidControl STATIC
"Roboid.cpp" "Roboid.cpp"
"Perception.cpp" "Perception.cpp"
"PerceivedObject.cpp" "TrackedObject.cpp"
"Propulsion.cpp" "Propulsion.cpp"
"Motor.cpp" "Motor.cpp"
"DifferentialDrive.cpp" "DifferentialDrive.cpp"
@ -52,6 +52,7 @@ add_library(RoboidControl STATIC
"Sensor.cpp" "Sensor.cpp"
"Switch.cpp" "Switch.cpp"
"Thing.cpp" "Thing.cpp"
"Quadcopter.cpp"
) )
enable_testing() enable_testing()

View File

@ -54,7 +54,22 @@ public:
/// forward, float yaw) function. /// forward, float yaw) function.
virtual void SetTwistSpeed(Vector3 linear, float yaw = 0.0F, virtual void SetTwistSpeed(Vector3 linear, float yaw = 0.0F,
float pitch = 0.0F, float roll = 0.0F); float pitch = 0.0F, float roll = 0.0F);
/// @brief Calculate the linear velocity of the roboid based on the wheel
/// velocities
/// @return The velocity of the roboid in local space
/// @details The actual values may not be accurate, depending on the available
/// information
/// @remark This will be more expanded/detailed in a future version of Roboid
/// Control
virtual Polar GetVelocity() override; virtual Polar GetVelocity() override;
/// @brief Calculate the angular velocity of the roboid based on the wheel
/// velocities
/// @return The angular speed of the roboid in local space
/// @details The actual value may not be accurate, depending on the available
/// information
/// @remark This will be more expanded/detailed in a future version of Roboid
/// Control
virtual float GetAngularVelocity() override; virtual float GetAngularVelocity() override;
}; };

View File

@ -8,7 +8,7 @@ namespace Passer {
namespace RoboidControl { namespace RoboidControl {
/// @brief A plament is used to specify where a Thing is placed on the Roboid. /// @brief A plament is used to specify where a Thing is placed on the Roboid.
/// /// @details
/// It is not always necessary to exactly specify the position and orientation /// It is not always necessary to exactly specify the position and orientation
/// of a Thing. You can use a simple constructor in that case: /// of a Thing. You can use a simple constructor in that case:
/// ///
@ -36,7 +36,7 @@ namespace RoboidControl {
/// Placement p = Placement(thing, Vector2(-0.04F, 0.06F)); /// Placement p = Placement(thing, Vector2(-0.04F, 0.06F));
/// \endcode /// \endcode
class Placement { class Placement {
public: public:
/// @brief Placement of a Thing on a Roboid /// @brief Placement of a Thing on a Roboid
/// @param thing The Thing which is placed /// @param thing The Thing which is placed
/// @param position The position of the Thing in carthesian coordinates /// @param position The position of the Thing in carthesian coordinates
@ -44,34 +44,31 @@ class Placement {
/// Negative angles are to the left. /// Negative angles are to the left.
/// @param verticalAngle The vertical direction angle of the Thing. Negative /// @param verticalAngle The vertical direction angle of the Thing. Negative
/// angles are downward. /// angles are downward.
Placement(Thing* thing, Placement(Thing *thing, Vector3 position = Vector3::zero,
Vector3 position = Vector3::zero, float horizontalDirection = 0.0F, float verticalAngle = 0.0F);
float horizontalDirection = 0.0F,
float verticalAngle = 0.0F);
/// @brief Placement of a Thing on a Roboid without position /// @brief Placement of a Thing on a Roboid without position
/// @param thing The Thing which is place /// @param thing The Thing which is place
/// @param horizontalDirection The horizontal direction angle of the Thing. /// @param horizontalDirection The horizontal direction angle of the Thing.
/// Negative angles are to the left. /// Negative angles are to the left.
/// @param verticalDirection The vertical direction angle of the Thing. /// @param verticalDirection The vertical direction angle of the Thing.
/// Negative angles are downward. /// Negative angles are downward.
Placement(Thing* thing, Placement(Thing *thing, float horizontalDirection,
float horizontalDirection,
float verticalDirection = 0.0F); float verticalDirection = 0.0F);
/// @brief Default constructor with a zero placement /// @brief Default constructor with a zero placement
Placement(); Placement();
/// @brief The parent placement in the Roboid hierarchy /// @brief The parent placement in the Roboid hierarchy
/// @remark Reserved for future use /// @remark Reserved for future use
Placement* parent = nullptr; Placement *parent = nullptr;
/// @brief An array of children of this placement in the Roboid hierarchy /// @brief An array of children of this placement in the Roboid hierarchy
/// @remark Reserved for future use /// @remark Reserved for future use
Placement** children = nullptr; Placement **children = nullptr;
/// @brief The number of children of this placemet in the Roboid hierarchy /// @brief The number of children of this placemet in the Roboid hierarchy
/// @remark Reserved for future use /// @remark Reserved for future use
unsigned int childCount = 0; unsigned int childCount = 0;
/// @brief The Thing which is placed /// @brief The Thing which is placed
Thing* thing; Thing *thing;
/// @brief The position of the Thing in carthesian coordinates /// @brief The position of the Thing in carthesian coordinates
Vector3 position; Vector3 position;
/// @brief The angle or direction of the Thing in the horizontal plane /// @brief The angle or direction of the Thing in the horizontal plane
@ -80,6 +77,6 @@ class Placement {
float verticalDirection; float verticalDirection;
}; };
} // namespace RoboidControl } // namespace RoboidControl
} // namespace Passer } // namespace Passer
using namespace Passer::RoboidControl; using namespace Passer::RoboidControl;

View File

@ -13,10 +13,9 @@ class Roboid;
/// @brief The Propulsion module for a Roboid is used to move the Roboid in /// @brief The Propulsion module for a Roboid is used to move the Roboid in
/// space /// space
/// /// @details Usually, a specific implementation of the propulsion module is used
/// Usually, a specific implementation of the propulsion module is used for a /// for a robot. This base class does not implement the functions to move the
/// robot. This base class does not implement the functions to move the Roboid /// Roboid around.
/// around.
class Propulsion { class Propulsion {
public: public:
/// @brief Default Constructor for Propulsion /// @brief Default Constructor for Propulsion
@ -40,8 +39,6 @@ public:
/// index could be found /// index could be found
Placement *GetMotorPlacement(unsigned int motorIx); Placement *GetMotorPlacement(unsigned int motorIx);
// Velocity control
/// @brief Sets the forward and rotation speed of a (grounded) Roboid /// @brief Sets the forward and rotation speed of a (grounded) Roboid
/// @param forward The target forward speed /// @param forward The target forward speed
/// @param yaw The target rotation speed around the vertical axis /// @param yaw The target rotation speed around the vertical axis
@ -72,6 +69,7 @@ public:
/// The actual unit of the angular velocity depend on the implementation /// The actual unit of the angular velocity depend on the implementation
virtual float GetAngularVelocity(); virtual float GetAngularVelocity();
/// @brief The roboid of this propulsion system
Roboid *roboid = nullptr; Roboid *roboid = nullptr;
protected: protected:

View File

@ -8,30 +8,29 @@ namespace Passer {
namespace RoboidControl { namespace RoboidControl {
/// @brief Support for Quadcopter as a propulsion method /// @brief Support for Quadcopter as a propulsion method
/// @note This is work in progress
class Quadcopter : public Propulsion { class Quadcopter : public Propulsion {
public: public:
/// @brief Default constuctor /// @brief Default constuctor
Quadcopter(); Quadcopter();
virtual void SetTwistSpeed(float forward, float yaw = 0.0F) override; virtual void SetTwistSpeed(float forward, float yaw = 0.0F) override;
virtual void SetTwistSpeed(Vector2 linear, float yaw = 0.0F) override; virtual void SetTwistSpeed(Vector2 linear, float yaw = 0.0F) override;
virtual void SetTwistSpeed(Vector3 linear, virtual void SetTwistSpeed(Vector3 linear, float yaw = 0.0F,
float yaw = 0.0F, float pitch = 0.0F, float roll = 0.0F) override;
float pitch = 0.0F,
float roll = 0.0F) override;
Vector3 GetTargetVelocity(); Vector3 GetTargetVelocity();
float GetYawSpeed(); float GetYawSpeed();
float GetPitchSpeed(); float GetPitchSpeed();
float GetRollSpeed(); float GetRollSpeed();
protected: protected:
Vector3 velocity = Vector3::zero; Vector3 velocity = Vector3::zero;
float pitchSpeed = 0.0F; float pitchSpeed = 0.0F;
float yawSpeed = 0.0F; float yawSpeed = 0.0F;
float rollSpeed = 0.0F; float rollSpeed = 0.0F;
}; };
} // namespace RoboidControl } // namespace RoboidControl
} // namespace Passer } // namespace Passer
using namespace Passer::RoboidControl; using namespace Passer::RoboidControl;

View File

@ -33,41 +33,42 @@ public:
/// @brief Retrieve the current position of the roboid /// @brief Retrieve the current position of the roboid
/// @return The position in carthesian coordinates in world space /// @return The position in carthesian coordinates in world space
/// The origin and units of the position depends on the position tracking /// @details The origin and units of the position depends on the position
/// system used. This value will be Vector3::zero unless a position is /// tracking system used. This value will be Vector3::zero unless a position
/// received through network synchronisation /// is received through network synchronisation
virtual Vector3 GetPosition(); virtual Vector3 GetPosition();
/// @brief Retrieve the current orientation of the roboid /// @brief Retrieve the current orientation of the roboid
/// @return The orientation quaternion in world space /// @return The orientation quaternion in world space
/// The origin orientation depends on the position tracking system used. This /// @details The origin orientation depends on the position tracking system
/// value will be Quaternion::identity unless an orientation is received /// used. This value will be Quaternion::identity unless an orientation is
/// though network synchronization /// received though network synchronization
virtual Quaternion GetOrientation(); virtual Quaternion GetOrientation();
/// @brief Update the current position of the roboid /// @brief Update the current position of the roboid
/// @param worldPosition The position of the roboid in carthesian coordinates /// @param worldPosition The position of the roboid in carthesian coordinates
/// in world space The use of this function will also update the positions and /// in world space
/// @details The use of this function will also update the positions and
/// orientations of the perceived objects by the roboid /// orientations of the perceived objects by the roboid
/// (roboid->perception->perceivedObjects), as these are local to the /// (roboid->perception->perceivedObjects), as these are local to the
/// roboid's position. /// roboid's position.
virtual void SetPosition(Vector3 worldPosition); virtual void SetPosition(Vector3 worldPosition);
/// @brief Update the current orientation of the roboid /// @brief Update the current orientation of the roboid
/// @param worldOrientation The orientation of the roboid in world space /// @param worldOrientation The orientation of the roboid in world space
/// The use of this function will also update the orientations of the /// @details The use of this function will also update the orientations of the
/// perceived objects by the roboid (roboid->perception->perceivedObjets), /// perceived objects by the roboid (roboid->perception->perceivedObjets),
/// as these are local to the roboid' orientation. /// as these are local to the roboid' orientation.
virtual void SetOrientation(Quaternion worldOrientation); virtual void SetOrientation(Quaternion worldOrientation);
private: private:
/// @brief The position of the roboid in carthesian coordinates in world space /// @brief The position of the roboid in carthesian coordinates in world space
/// This position may be set when NetworkSync is used to receive /// @details This position may be set when NetworkSync is used to receive
/// positions from an external tracking system. These values should not be set /// positions from an external tracking system. These values should not be set
/// directly, but SetPosition should be used instead. /// directly, but SetPosition should be used instead.
Vector3 worldPosition = Vector3::zero; Vector3 worldPosition = Vector3::zero;
/// @brief The orientation of the roboid in world space /// @brief The orientation of the roboid in world space
/// The position may be set when NetworkSync is used to receive orientations /// @details The position may be set when NetworkSync is used to receive
/// from an external tracking system. This value should not be set directly, /// orientations from an external tracking system. This value should not be
/// but SetOrientation should be used instead. /// set directly, but SetOrientation should be used instead.
Quaternion worldOrientation = Quaternion::identity; Quaternion worldOrientation = Quaternion::identity;
}; };

View File

@ -7,12 +7,14 @@ namespace RoboidControl {
/// @brief A digital switch input /// @brief A digital switch input
class Switch : public Sensor { class Switch : public Sensor {
public: public:
/// @brief Default constructor /// @brief Default constructor
Switch(); Switch();
/// @brief Test of the switch is on
/// @return true when the switch returns a HIGH value
virtual bool IsOn(); virtual bool IsOn();
}; };
} // namespace RoboidControl } // namespace RoboidControl
} // namespace Passer } // namespace Passer

View File

@ -12,10 +12,15 @@ public:
/// @brief The type of Thing /// @brief The type of Thing
unsigned int type; unsigned int type;
/// @brief The type of a switch sensor
static const unsigned int SwitchType; static const unsigned int SwitchType;
/// @brief The type of a distance sensor
static const unsigned int DistanceSensorType; static const unsigned int DistanceSensorType;
/// @brief The type of a controlled motor
static const unsigned int ControlledMotorType; static const unsigned int ControlledMotorType;
/// @brief The type of an uncontrolled motor
static const unsigned int UncontrolledMotorType; static const unsigned int UncontrolledMotorType;
/// @brief The type of an object received from the network
static const unsigned int ExternalType; static const unsigned int ExternalType;
/// @brief Check if the Thing is a Motor /// @brief Check if the Thing is a Motor