dymoesco.dynamics.dynamic_models.DiffDrive¶
-
class
dymoesco.dynamics.dynamic_models.DiffDrive(radius=1, u_std=0, y_std=0, max_radar_range=1, beacons=[], name=None)¶ Bases:
dymoesco.dynamics.dynamic_models.ContinuousDynamicModel,dymoesco.dynamics.statespace_models.SE2Differential drive wheeled robot, using velocity inputs (kinematics model).
DiffDrive is an implementation of a differential drive wheeled robot happening on the SE(2) state-space with variables \((x,y,\theta)\):
\[\begin{split}\dot{x} &= v \cos\theta \\ \dot{y} &= v \sin\theta \\ \dot{\theta} &= w / \text{radius}\end{split}\]DiffDrive also has a range and bearing sensor, which has a max range of max_radar_range and the bearing sensor works irrespective of the position of the beacon (360deg coverage).
- Parameters
radius (float) – radius of the wheels
u_std (float or list of 3 floats) – control noise standard deviation. Can also give different standard deviations for each state (x,y theta).
y_std (float or list of 2 floats) – sensor noise standard deviation. Can also give a different standard deviations for range and bearing.
max_radar_range (float) – maximum range for which the range sensor will return an observation
beacons (list of tuples) – list of beacon (x,y)-positions, one for each beacon. Beacons are sensed by the range-bearing sensor (_g/g methods)
-
__init__(radius=1, u_std=0, y_std=0, max_radar_range=1, beacons=[], name=None)¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__([radius, u_std, y_std, …])Initialize self.
animate(traj[, ax])discretize(dt)f(x, u)General dynamics function which is called in code.
g(z)Observation function for beacons-based range/bearing sensor.
gui(key_to_u_map, x0[, ekf, show_pred, …])plot(traj[, attr, ax])traj needs to be a Trajectory object (or a dictionary with t and the requested attribute (x,y or u)).
plotu(traj[, ax])plotx(traj[, ax])ploty(traj[, ax])simulate(u, t_span, x0[, t_eval])simulate calls solve_ivp and returns a Trajectory object.
-
f(x, u)¶ General dynamics function which is called in code.
f adds some boiletplate around
_f(), such as adding the noise to make the dynamical system stochastic: \(\dot{x} = f(x,u) = _f(x,u) + \epsilon\). In most cases only f will not need to be overridden.
-
g(z)¶ Observation function for beacons-based range/bearing sensor.
Note how we overrode
dymoesco.dynamics.dynamic_models.ContinuousDynamicModel.g()to get the desired behavior.
-
plot(traj, attr='x', ax=None)¶ traj needs to be a Trajectory object (or a dictionary with t and the requested attribute (x,y or u)).
-
simulate(u, t_span, x0, t_eval=None)¶ simulate calls solve_ivp and returns a Trajectory object. u in the returned trajectory is the underlying noiseless trajectory. TODO: find a way to return the noisy trajectory? (get the u_noisy out of f).