dymoesco.dynamics package¶
Submodules¶
dymoesco.dynamics.diffdrive module¶
-
class
dymoesco.dynamics.diffdrive.DiffDrive(radius=1, u_std=0, y_std=0, max_radar_range=1, beacons=[], name=None)¶ Bases:
dymoesco.dynamics.dynamic_model.ContinuousDynamicModel,dymoesco.dynamics.statespace_model.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)
-
discretize(dt)¶
-
g(z)¶ Observation function for beacons-based range/bearing sensor.
Note how we overrode
dymoesco.dynamics.dynamic_model.ContinuousDynamicModel.g()to get the desired behavior.
dymoesco.dynamics.doubleintegrator module¶
-
class
dymoesco.dynamics.doubleintegrator.DoubleIntegrator(dim=1)¶ Bases:
dymoesco.dynamics.dynamic_model.ContinuousDynamicModel,dymoesco.dynamics.statespace_model.Rn
dymoesco.dynamics.dynamic_model module¶
-
class
dymoesco.dynamics.dynamic_model.ContinuousDynamicModel(u_std=0, y_std=0)¶ Bases:
abc.ABCThe main abstract class in dymoesco which all models need to subclass.
ContinuousDynamicModeldefines the main API through which all models implemented in dymoesco will interface. Estimation and Control algorithms will most likely only work on objects whose class inherits from ContinuousDynamicModel. The subclasses need to implement_f(), the dynamics function which implements a system \(\dot{x} = _f(x,u) + \epsilon\). They can also overwrite_g(), the observation function \(y = _g(x) + \epsilon\), which by default is the identity function. Note that _f and _g should be deterministic functions. Noise is added inf()andg(), which will be called by the object instances. The main method available to ContinuousDynamicModel instances is thensimulate()which calls scipy’s solve_ivp and returns adymoesco.types.Trajectoryobject.- Parameters
u_std (float or list of floats) – Standard deviation of dynamics noise.
y_std (float or list of floats) – Standard deviation of observation noise.
Notes
We have decided to use a time-invariant API, since most systems of interest to robotics are time-invariant. Users that need to implement a time-varying system will need to write their own class, which will be similar to this class.
-
discretize(dt)¶
-
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(x)¶ General observation 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. In some special cases an observation model implementation might be complicated enough to warranty overriding g. Seedymoesco.dynamics.diffdrive.DiffDrive.g()for an example.
-
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)).
-
plotu(traj, ax=None)¶
-
plotx(traj, ax=None)¶
-
ploty(traj, ax=None)¶
-
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).
-
class
dymoesco.dynamics.dynamic_model.DiscreteDynamicModel(dt, u_std=0, y_std=0)¶ Bases:
abc.ABC-
f(x, u)¶
-
g(x)¶
-
make_EKF(Q, R)¶ This creates an EKF using the model’s _f and _g functions. Sometimes we might need the EKF to have a slightly different _g function than the model (for eg. the diffdrive range/bearing obs). In that case, use EKF direction.
-
dymoesco.dynamics.singleintegrator module¶
-
class
dymoesco.dynamics.singleintegrator.SingleIntegrator(dim=1)¶ Bases:
dymoesco.dynamics.dynamic_model.ContinuousDynamicModel,dymoesco.dynamics.statespace_model.Rn
dymoesco.dynamics.statespace_model module¶
-
class
dymoesco.dynamics.statespace_model.Rn¶ Bases:
dymoesco.dynamics.statespace_model.StateSpace-
animate(traj, dim1=0, dim2=1, tail_len=3, ax=None)¶
-
gui(key_to_u_map, x0, dim1=0, dim2=1)¶ gui for Rn statespace models.
Starts an interactive gui for the dynamic_model in self, which is controlled using the arrows (which binding defined by key_to_u_map).
- Parameters
key_to_u_map (dict) – key_to_u_map binds ‘up’, ‘down’, ‘right’, ‘left’ to controls.
Examples
key_to_u_map = {'up': [0,1], 'down': [0,-1], 'right': [1,0], 'left': [-1,0]}
Notes
self needs to be a DiscreteDynamicModel.
-
plot_phase(traj, dim1=0, dim2=1, ax=None, color=None, **kwargs)¶
-
-
class
dymoesco.dynamics.statespace_model.SE2¶ Bases:
dymoesco.dynamics.statespace_model.StateSpace-
animate(traj, ax=None)¶
-
gui(key_to_u_map, x0, ekf=None, show_pred=False, update_every_n_pred=10)¶
-
-
class
dymoesco.dynamics.statespace_model.StateSpace¶ Bases:
abc.ABCDynamics can happen on different state spaces. Each state space will have its own class to hold methods for its own peculiarities, such as plotting, printing information, etc.