Fix clippy and enable clippy on CI
This commit is contained in:
committed by
Sébastien Crozet
parent
aef873f20e
commit
da92e5c283
@@ -84,9 +84,9 @@ impl FixedJoint {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<GenericJoint> for FixedJoint {
|
||||
fn into(self) -> GenericJoint {
|
||||
self.data
|
||||
impl From<FixedJoint> for GenericJoint {
|
||||
fn from(val: FixedJoint) -> GenericJoint {
|
||||
val.data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,8 +143,8 @@ impl FixedJointBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<GenericJoint> for FixedJointBuilder {
|
||||
fn into(self) -> GenericJoint {
|
||||
self.0.into()
|
||||
impl From<FixedJointBuilder> for GenericJoint {
|
||||
fn from(val: FixedJointBuilder) -> GenericJoint {
|
||||
val.0.into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(clippy::bad_bit_mask)] // Clippy will complain about the bitmasks due to JointAxesMask::FREE_FIXED_AXES being 0.
|
||||
|
||||
use crate::dynamics::solver::MotorParameters;
|
||||
use crate::dynamics::{FixedJoint, MotorModel, PrismaticJoint, RevoluteJoint, RopeJoint};
|
||||
use crate::math::{Isometry, Point, Real, Rotation, UnitVector, Vector, SPATIAL_DIM};
|
||||
@@ -704,8 +706,8 @@ impl GenericJointBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<GenericJoint> for GenericJointBuilder {
|
||||
fn into(self) -> GenericJoint {
|
||||
self.0
|
||||
impl From<GenericJointBuilder> for GenericJoint {
|
||||
fn from(val: GenericJointBuilder) -> GenericJoint {
|
||||
val.0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ impl ImpulseJointSet {
|
||||
}
|
||||
|
||||
/// Iterates through all the impulse joints attached to the given rigid-body.
|
||||
pub fn map_attached_joints_mut<'a>(
|
||||
&'a mut self,
|
||||
pub fn map_attached_joints_mut(
|
||||
&mut self,
|
||||
body: RigidBodyHandle,
|
||||
mut f: impl FnMut(RigidBodyHandle, RigidBodyHandle, ImpulseJointHandle, &mut ImpulseJoint),
|
||||
) {
|
||||
@@ -282,7 +282,7 @@ impl ImpulseJointSet {
|
||||
&self,
|
||||
islands: &IslandManager,
|
||||
bodies: &RigidBodySet,
|
||||
out: &mut Vec<Vec<JointIndex>>,
|
||||
out: &mut [Vec<JointIndex>],
|
||||
) {
|
||||
for out_island in &mut out[..islands.num_islands()] {
|
||||
out_island.clear();
|
||||
|
||||
@@ -1,23 +1,18 @@
|
||||
use crate::math::Real;
|
||||
|
||||
/// The spring-like model used for constraints resolution.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(Default, Copy, Clone, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||
pub enum MotorModel {
|
||||
/// The solved spring-like equation is:
|
||||
/// `acceleration = stiffness * (pos - target_pos) + damping * (vel - target_vel)`
|
||||
#[default]
|
||||
AccelerationBased,
|
||||
/// The solved spring-like equation is:
|
||||
/// `force = stiffness * (pos - target_pos) + damping * (vel - target_vel)`
|
||||
ForceBased,
|
||||
}
|
||||
|
||||
impl Default for MotorModel {
|
||||
fn default() -> Self {
|
||||
MotorModel::AccelerationBased
|
||||
}
|
||||
}
|
||||
|
||||
impl MotorModel {
|
||||
/// Combines the coefficients used for solving the spring equation.
|
||||
///
|
||||
|
||||
@@ -127,8 +127,9 @@ impl Multibody {
|
||||
let mut link_id2new_id = vec![usize::MAX; self.links.len()];
|
||||
|
||||
for (i, mut link) in self.links.0.into_iter().enumerate() {
|
||||
let is_new_root = (!joint_only && (i == 0 || link.parent_internal_id == to_remove))
|
||||
|| (joint_only && (i == 0 || i == to_remove));
|
||||
let is_new_root = i == 0
|
||||
|| !joint_only && link.parent_internal_id == to_remove
|
||||
|| joint_only && i == to_remove;
|
||||
|
||||
if !joint_only && i == to_remove {
|
||||
continue;
|
||||
@@ -492,7 +493,7 @@ impl Multibody {
|
||||
parent_to_world = parent_link.local_to_world;
|
||||
|
||||
let (link_j, parent_j) = self.body_jacobians.index_mut_const(i, parent_id);
|
||||
link_j.copy_from(&parent_j);
|
||||
link_j.copy_from(parent_j);
|
||||
|
||||
{
|
||||
let mut link_j_v = link_j.fixed_rows_mut::<DIM>(0);
|
||||
@@ -602,12 +603,12 @@ impl Multibody {
|
||||
let (coriolis_v, parent_coriolis_v) = self.coriolis_v.index_mut2(i, parent_id);
|
||||
let (coriolis_w, parent_coriolis_w) = self.coriolis_w.index_mut2(i, parent_id);
|
||||
|
||||
coriolis_v.copy_from(&parent_coriolis_v);
|
||||
coriolis_w.copy_from(&parent_coriolis_w);
|
||||
coriolis_v.copy_from(parent_coriolis_v);
|
||||
coriolis_w.copy_from(parent_coriolis_w);
|
||||
|
||||
// [c1 - c0].gcross() * (JDot + JDot/u * qdot)"
|
||||
let shift_cross_tr = link.shift02.gcross_matrix_tr();
|
||||
coriolis_v.gemm(1.0, &shift_cross_tr, &parent_coriolis_w, 1.0);
|
||||
coriolis_v.gemm(1.0, &shift_cross_tr, parent_coriolis_w, 1.0);
|
||||
|
||||
// JDot (but the 2.0 originates from the sum of two identical terms in JDot and JDot/u * gdot)
|
||||
let dvel_cross = (rb.vels.angvel.gcross(link.shift02)
|
||||
@@ -663,7 +664,7 @@ impl Multibody {
|
||||
{
|
||||
// [c3 - c2].gcross() * (JDot + JDot/u * qdot)
|
||||
let shift_cross_tr = link.shift23.gcross_matrix_tr();
|
||||
coriolis_v.gemm(1.0, &shift_cross_tr, &coriolis_w, 1.0);
|
||||
coriolis_v.gemm(1.0, &shift_cross_tr, coriolis_w, 1.0);
|
||||
|
||||
// JDot
|
||||
let dvel_cross = rb.vels.angvel.gcross(link.shift23).gcross_matrix_tr();
|
||||
@@ -696,16 +697,16 @@ impl Multibody {
|
||||
{
|
||||
let mut i_coriolis_dt_w = self.i_coriolis_dt.fixed_rows_mut::<ANG_DIM>(DIM);
|
||||
// NOTE: this is just an axpy, but on row columns.
|
||||
i_coriolis_dt_w.zip_apply(&coriolis_w, |o, x| *o = x * dt * rb_inertia);
|
||||
i_coriolis_dt_w.zip_apply(coriolis_w, |o, x| *o = x * dt * rb_inertia);
|
||||
}
|
||||
#[cfg(feature = "dim3")]
|
||||
{
|
||||
let mut i_coriolis_dt_w = self.i_coriolis_dt.fixed_rows_mut::<ANG_DIM>(DIM);
|
||||
i_coriolis_dt_w.gemm(dt, &rb_inertia, &coriolis_w, 0.0);
|
||||
i_coriolis_dt_w.gemm(dt, &rb_inertia, coriolis_w, 0.0);
|
||||
}
|
||||
|
||||
self.acc_augmented_mass
|
||||
.gemm_tr(1.0, &rb_j, &self.i_coriolis_dt, 1.0);
|
||||
.gemm_tr(1.0, rb_j, &self.i_coriolis_dt, 1.0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -393,10 +393,10 @@ impl MultibodyJointSet {
|
||||
|
||||
/// Iterate through the handles of all the rigid-bodies attached to this rigid-body
|
||||
/// by a multibody_joint.
|
||||
pub fn attached_bodies<'a>(
|
||||
&'a self,
|
||||
pub fn attached_bodies(
|
||||
&self,
|
||||
body: RigidBodyHandle,
|
||||
) -> impl Iterator<Item = RigidBodyHandle> + 'a {
|
||||
) -> impl Iterator<Item = RigidBodyHandle> + '_ {
|
||||
self.rb2mb
|
||||
.get(body.0)
|
||||
.into_iter()
|
||||
@@ -406,10 +406,10 @@ impl MultibodyJointSet {
|
||||
|
||||
/// Iterate through the handles of all the rigid-bodies attached to this rigid-body
|
||||
/// by an enabled multibody_joint.
|
||||
pub fn bodies_attached_with_enabled_joint<'a>(
|
||||
&'a self,
|
||||
pub fn bodies_attached_with_enabled_joint(
|
||||
&self,
|
||||
body: RigidBodyHandle,
|
||||
) -> impl Iterator<Item = RigidBodyHandle> + 'a {
|
||||
) -> impl Iterator<Item = RigidBodyHandle> + '_ {
|
||||
self.attached_bodies(body).filter(move |other| {
|
||||
if let Some((_, _, link)) = self.joint_between(body, *other) {
|
||||
link.joint.data.is_enabled()
|
||||
|
||||
@@ -152,9 +152,9 @@ impl PrismaticJoint {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<GenericJoint> for PrismaticJoint {
|
||||
fn into(self) -> GenericJoint {
|
||||
self.data
|
||||
impl From<PrismaticJoint> for GenericJoint {
|
||||
fn from(val: PrismaticJoint) -> GenericJoint {
|
||||
val.data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,8 +263,8 @@ impl PrismaticJointBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<GenericJoint> for PrismaticJointBuilder {
|
||||
fn into(self) -> GenericJoint {
|
||||
self.0.into()
|
||||
impl From<PrismaticJointBuilder> for GenericJoint {
|
||||
fn from(val: PrismaticJointBuilder) -> GenericJoint {
|
||||
val.0.into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ pub struct RevoluteJoint {
|
||||
impl RevoluteJoint {
|
||||
/// Creates a new revolute joint allowing only relative rotations.
|
||||
#[cfg(feature = "dim2")]
|
||||
#[allow(clippy::new_without_default)] // For symmetry with 3D which can’t have a Default impl.
|
||||
pub fn new() -> Self {
|
||||
let data = GenericJointBuilder::new(JointAxesMask::LOCKED_REVOLUTE_AXES);
|
||||
Self { data: data.build() }
|
||||
@@ -137,9 +138,9 @@ impl RevoluteJoint {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<GenericJoint> for RevoluteJoint {
|
||||
fn into(self) -> GenericJoint {
|
||||
self.data
|
||||
impl From<RevoluteJoint> for GenericJoint {
|
||||
fn from(val: RevoluteJoint) -> GenericJoint {
|
||||
val.data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +154,7 @@ pub struct RevoluteJointBuilder(pub RevoluteJoint);
|
||||
impl RevoluteJointBuilder {
|
||||
/// Creates a new revolute joint builder.
|
||||
#[cfg(feature = "dim2")]
|
||||
#[allow(clippy::new_without_default)] // For symmetry with 3D which can’t have a Default impl.
|
||||
pub fn new() -> Self {
|
||||
Self(RevoluteJoint::new())
|
||||
}
|
||||
@@ -241,8 +243,8 @@ impl RevoluteJointBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<GenericJoint> for RevoluteJointBuilder {
|
||||
fn into(self) -> GenericJoint {
|
||||
self.0.into()
|
||||
impl From<RevoluteJointBuilder> for GenericJoint {
|
||||
fn from(val: RevoluteJointBuilder) -> GenericJoint {
|
||||
val.0.into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,9 +134,9 @@ impl RopeJoint {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<GenericJoint> for RopeJoint {
|
||||
fn into(self) -> GenericJoint {
|
||||
self.data
|
||||
impl From<RopeJoint> for GenericJoint {
|
||||
fn from(val: RopeJoint) -> GenericJoint {
|
||||
val.data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,8 +231,8 @@ impl RopeJointBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<GenericJoint> for RopeJointBuilder {
|
||||
fn into(self) -> GenericJoint {
|
||||
self.0.into()
|
||||
impl From<RopeJointBuilder> for GenericJoint {
|
||||
fn from(val: RopeJointBuilder) -> GenericJoint {
|
||||
val.0.into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,9 +164,9 @@ impl SphericalJoint {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<GenericJoint> for SphericalJoint {
|
||||
fn into(self) -> GenericJoint {
|
||||
self.data
|
||||
impl From<SphericalJoint> for GenericJoint {
|
||||
fn from(val: SphericalJoint) -> GenericJoint {
|
||||
val.data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,8 +288,8 @@ impl SphericalJointBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<GenericJoint> for SphericalJointBuilder {
|
||||
fn into(self) -> GenericJoint {
|
||||
self.0.into()
|
||||
impl From<SphericalJointBuilder> for GenericJoint {
|
||||
fn from(val: SphericalJointBuilder) -> GenericJoint {
|
||||
val.0.into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,9 +94,9 @@ impl SpringJoint {
|
||||
// }
|
||||
}
|
||||
|
||||
impl Into<GenericJoint> for SpringJoint {
|
||||
fn into(self) -> GenericJoint {
|
||||
self.data
|
||||
impl From<SpringJoint> for GenericJoint {
|
||||
fn from(val: SpringJoint) -> GenericJoint {
|
||||
val.data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,8 +165,8 @@ impl SpringJointBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<GenericJoint> for SpringJointBuilder {
|
||||
fn into(self) -> GenericJoint {
|
||||
self.0.into()
|
||||
impl From<SpringJointBuilder> for GenericJoint {
|
||||
fn from(val: SpringJointBuilder) -> GenericJoint {
|
||||
val.0.into()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user