63 lines
2.8 KiB
C++
63 lines
2.8 KiB
C++
#pragma once
|
|
|
|
#include "Propulsion.h"
|
|
|
|
namespace Passer {
|
|
namespace RoboidControl {
|
|
|
|
/// @brief A two-wheeled Propulsion method
|
|
///
|
|
/// The wheels are put at either side of the roboid with the following behaviour
|
|
/// * When both wheels spin forward, the Roboid moves forward
|
|
/// * When both wheels spin backward, the Roboid moves backward
|
|
/// * When both wheels are spinning in opposite directions, the Roboid rotates
|
|
/// wihout moving forward or backward
|
|
/// * When just one wheel is spinning, the Roboid turnes while moving forward or
|
|
/// backward.
|
|
class DifferentialDrive : public Propulsion {
|
|
public:
|
|
/// @brief Default constructor
|
|
DifferentialDrive();
|
|
/// @brief Setup of the DifferentialDrive with the Placement of the motors
|
|
/// @param leftMotorPlacement Placement of the left Motor
|
|
/// @param rightMotorPlacement Placement of the right Motor
|
|
/// In this setup, the left motor Direction will be CounterClockWise when
|
|
/// driving forward, while the right motor will turn Clockwise.
|
|
/// @note When not using controlled motors, the placement of the motors is
|
|
/// irrelevant.
|
|
DifferentialDrive(Placement leftMotorPlacement,
|
|
Placement rightMotorPlacement);
|
|
|
|
/// @brief Set the target speeds of the motors directly
|
|
/// @param leftSpeed The target speed of the left Motor
|
|
/// @param rightSpeed The target speed of the right Motor
|
|
void SetTargetSpeeds(float leftSpeed, float rightSpeed);
|
|
|
|
/// @brief Controls the motors through forward and rotation speeds
|
|
/// @param forward The target forward speed of the Roboid
|
|
/// @param yaw The target rotation speed of the Roboid
|
|
virtual void SetTwistSpeed(float forward, float yaw) override;
|
|
/// @brief Controls the motors through forward and rotation speeds
|
|
/// @param linear The target linear speed of the Roboid
|
|
/// @param yaw The target rotation speed of the Roboid
|
|
/// @note As a DifferentialDrive cannot move sideward, this function has the
|
|
/// same effect as using the void SetTwistSpeed(float forward, float yaw)
|
|
/// function.
|
|
virtual void SetTwistSpeed(Vector2 linear, float yaw = 0.0F);
|
|
/// @brief Controls the motors through forward and rotation speeds
|
|
/// @param linear The target linear speed
|
|
/// @param yaw The target rotation speed around the vertical axis
|
|
/// @param pitch Pitch is not supported and is ignored
|
|
/// @param roll Roll is not supported and is ignores
|
|
/// @note As a DifferentialDrive cannot move sideward or vertical, this
|
|
/// function has the same effect as using the void SetTwistSpeed(float
|
|
/// forward, float yaw) function.
|
|
virtual void SetTwistSpeed(Vector3 linear,
|
|
float yaw = 0.0F,
|
|
float pitch = 0.0F,
|
|
float roll = 0.0F);
|
|
};
|
|
|
|
} // namespace RoboidControl
|
|
} // namespace Passer
|
|
using namespace Passer::RoboidControl; |