Bicycle#

#include "navground/core/kinematics.h"
class BicycleKinematics : public virtual navground::core::Kinematics#

Bicycle kinematics.

Given linear and angular desired speeds \((v_{\mathrm{des}}, \omega_{\mathrm{des}})\), it computes linear and angular speeds that respect the upper bounds of the steering angle ( \(|\alpha| \le \alpha_{\max}\)) so that \(\omega = v \frac{\tan \alpha}{l}\).

When \((v_{\mathrm{des}}, \omega_{\mathrm{des}})\) lie outside of the feasible set, i.e. \(|\omega_{\mathrm{des}}| > |v_{\mathrm{des}}| \frac{\tan \alpha_{\max}}{l}\), there are two simple ways to compute a feasible pair:

  1. reduce \(|\omega_{\mathrm{des}}|\), while keeping the same sign for \(\omega_{\mathrm{des}}\) and the same value for \(v_{\mathrm{des}}\),

  2. reduce \(|v_{\mathrm{des}}|\), while keeping the same sign for \(v_{\mathrm{des}}\) and the same value for \(\omega_{\mathrm{des}}\).

Parameter get_k control the computation:

  • k==0: uses #1,

  • k==1: uses #2,

  • 0 < k < 1: interpolates between the two methods.

Moreover, parameter get_use_velocity_norm can be used to ignore the direction of the desired velocity but just consider its norm as desired linear speed.

Registered properties:

Note

This is not a subclass of WheeledKinematics. Although it has wheels, it also has a steering, therefore it is not completely determined by wheel speeds.

Public Functions

inline explicit BicycleKinematics(ng_float_t max_speed = Kinematics::inf, ng_float_t max_backward_speed = Kinematics::inf, ng_float_t axis = 1, ng_float_t max_steering_angle = 1, ng_float_t k = 0, bool use_velocity_norm = false)#

Constructs a new instance.

Parameters:
  • max_speed[in] The maximal forwards speed

  • max_backward_speed[in] The maximal backward speed

  • axis[in] The distance between front and back wheels.

  • max_steering_angle[in] Maximal steering angle.

  • k[in] k.

  • use_velocity_norm[in] Wheter to use the velocity norm instead of the projection on the x-axis.

inline ng_float_t get_axis() const#

Gets distance between front and back wheels.

Returns:

The axis.

inline void set_axis(ng_float_t value)#

Sets distance between front and back wheels.

Parameters:

value[in] A positive value

inline ng_float_t get_max_backward_speed() const#

Gets the maximal backward speed.

Returns:

The axis.

inline void set_max_backward_speed(ng_float_t value)#

Sets the maximal backward speed.

Parameters:

value[in] A positive value

inline ng_float_t get_max_steering_angle() const#

Gets the maximal steering angle.

Returns:

The angle in radians.

inline void set_max_steering_angle(ng_float_t value)#

Sets the maximal steering angle.

Parameters:

value[in] A positive value in radians

inline ng_float_t get_k() const#

Gets k.

Returns:

k.

inline bool get_use_velocity_norm() const#

Gets whether to use the velocity norm instead of the projection on the x-axis.

Returns:

True if is uses the velocity norm, False if it uses the projection.

inline void set_use_velocity_norm(bool value)#

Sets whether to use the velocity norm instead of the projection on the x-axis.

Parameters:

value[in] The desired value

inline void set_k(ng_float_t value)#

Sets k.

Parameters:

value[in] A value in [0, 1]

inline virtual unsigned dof() const override#

Returns the degrees of freedom.

Returns:

2

ng_float_t feasible_steering_angle(const Twist2 &twist) const#

Returns the nearest feasible steering angle.

Parameters:

twist[in] The twist

Returns:

The angle in radians.

ng_float_t get_min_steering_radius() const#

Gets the minimal steering radius.

Returns:

The minimal steering radius.

Twist2 twist_from_steering(ng_float_t linear_speed, ng_float_t steering_angle) const#

Computes a twist from linear speed and steering angle.

Linear speed and steering angle are clipped in the feasible range.

Parameters:
  • linear_speed[in] The linear speed

  • steering_angle[in] The steering angle

Returns:

The twist in relative frame.