Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wheel slip system #134

Merged
merged 31 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6e3d2a5
initial version of wheel_slip system copied from apply_joint_force
scpeters Aug 2, 2019
310c874
Port essential parts of WheelSlipPlugin
azeey Aug 5, 2019
5c9f099
Merge branch 'ign-gazebo2' into wheel_slip_system
May 13, 2020
2621219
Add test init and resolve comments
May 14, 2020
b747497
updated tests
May 16, 2020
96c3df7
add tricycle uphill test
May 19, 2020
8a5765b
Add partial tire drum test
May 20, 2020
5437795
Add triball drift sdf
May 26, 2020
9441bda
Sdf changes
May 26, 2020
b411ea0
initial version of wheel_slip system copied from apply_joint_force
scpeters Aug 2, 2019
c67d44c
Port essential parts of WheelSlipPlugin
azeey Aug 5, 2019
420002e
Add test init and resolve comments
May 14, 2020
6da8157
updated tests
May 16, 2020
9777693
add tricycle uphill test
May 19, 2020
9a94f53
Add partial tire drum test
May 20, 2020
b8c8bf5
Add triball drift sdf
May 26, 2020
8ebdb83
Sdf changes
May 26, 2020
8f73337
merge conflict
May 26, 2020
0c36c68
Merge branch 'ign-gazebo2' into wheel_slip_system
Jul 15, 2020
823e69c
Merge branch 'ign-gazebo2' into wheel_slip_system
Jul 15, 2020
6d2a393
Merge branch 'wheel_slip_system' of https://github.com/ignitionroboti…
Jul 15, 2020
a1b6d99
requested fixes
Jul 16, 2020
7cb3709
Merge branch 'ign-gazebo2' into wheel_slip_system
Jul 28, 2020
139020c
Add suggestions, make codecheck happy
Jul 31, 2020
5a92b81
Add test fixes
Aug 6, 2020
e99a38d
Requested fixes
Aug 25, 2020
de8bb1e
Add suggested fixes
Aug 25, 2020
314a5f2
Merge branch 'ign-gazebo2' into wheel_slip_system
Aug 25, 2020
a91c63c
Merge branch 'ign-gazebo2' into wheel_slip_system
Aug 28, 2020
07f151e
Update src/systems/wheel_slip/WheelSlip.cc
nkoenig Sep 17, 2020
58b63a8
Merge branch 'ign-gazebo2' into wheel_slip_system
Sep 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
936 changes: 936 additions & 0 deletions examples/worlds/trisphere_cycle_wheel_slip.sdf

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions include/ignition/gazebo/components/SlipComplianceCmd.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2020 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#ifndef IGNITION_GAZEBO_COMPONENTS_SLIPCOMPLIANCECMD_HH_
#define IGNITION_GAZEBO_COMPONENTS_SLIPCOMPLIANCECMD_HH_

#include <vector>

#include <ignition/gazebo/config.hh>
#include <ignition/gazebo/Export.hh>

#include <ignition/gazebo/components/Factory.hh>
#include "ignition/gazebo/components/Component.hh"

namespace ignition
{
namespace gazebo
{
// Inline bracket to help doxygen filtering.
inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
namespace components
{
/// \brief A component type that contains the slip compliance parameters to be
/// set on a collision. The 0 and 1 index values correspond to the slip
/// compliance parameters in friction direction 1 (fdir1) and friction
/// direction 2 (fdir2) respectively.
using SlipComplianceCmd =
Component<std::vector<double>, class SlipComplianceCmdTag>;
IGN_GAZEBO_REGISTER_COMPONENT("ign_gazebo_components.SlipComplianceCmd ",
SlipComplianceCmd)
}
}
}
}
#endif
1 change: 1 addition & 0 deletions src/systems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,5 @@ add_subdirectory(sensors)
add_subdirectory(touch_plugin)
add_subdirectory(triggered_publisher)
add_subdirectory(user_commands)
add_subdirectory(wheel_slip)
add_subdirectory(wind_effects)
67 changes: 67 additions & 0 deletions src/systems/physics/Physics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
#include "ignition/gazebo/components/Pose.hh"
#include "ignition/gazebo/components/PoseCmd.hh"
#include "ignition/gazebo/components/SelfCollide.hh"
#include "ignition/gazebo/components/SlipComplianceCmd.hh"
#include "ignition/gazebo/components/Static.hh"
#include "ignition/gazebo/components/ThreadPitch.hh"
#include "ignition/gazebo/components/World.hh"
Expand All @@ -125,6 +126,8 @@ class ignition::gazebo::systems::PhysicsPrivate
/// New features can't be added to this list in minor / patch releases, in
/// order to maintain backwards compatibility with downstream physics plugins.
public: using MinimumFeatureList = ignition::physics::FeatureList<
// FreeGroup

ignition::physics::FindFreeGroupFeature,
ignition::physics::SetFreeGroupWorldPose,
ignition::physics::FreeGroupFrameSemantics,
Expand Down Expand Up @@ -271,6 +274,27 @@ class ignition::gazebo::systems::PhysicsPrivate
/// \brief Environment variable which holds paths to look for engine plugins
public: std::string pluginPathEnv = "IGN_GAZEBO_PHYSICS_ENGINE_PATH";

//////////////////////////////////////////////////
// Slip Compliance

/// \brief Feature list to process `FrictionPyramidSlipCompliance` components.
public: using FrictionPyramidSlipComplianceFeatureList = physics::FeatureList<
MinimumFeatureList,
ignition::physics::GetShapeFrictionPyramidSlipCompliance,
ignition::physics::SetShapeFrictionPyramidSlipCompliance>;

/// \brief Shape type with slip compliance features.
public: using ShapeSlipParamPtrType = physics::ShapePtr<
physics::FeaturePolicy3d, FrictionPyramidSlipComplianceFeatureList>;

/// \brief A map between shape entity ids in the ECM to Shape Entities in
/// ign-physics
/// All shapes on this map are also in `entityCollisionMap`. The difference
/// is that here they've been casted for
/// `FrictionPyramidSlipComplianceFeatureList`.
public: std::unordered_map<Entity, ShapeSlipParamPtrType>
entityShapeSlipParamMap;

//////////////////////////////////////////////////
// Detachable joints

Expand Down Expand Up @@ -1169,6 +1193,42 @@ void PhysicsPrivate::UpdatePhysics(EntityComponentManager &_ecm)
return true;
});

// Slip compliance on Collisions
_ecm.Each<components::SlipComplianceCmd>(
[&](const Entity &_entity,
const components::SlipComplianceCmd *_slipCmdComp)
{
auto shapeIt = this->entityCollisionMap.find(_entity);
if (shapeIt == this->entityCollisionMap.end())
{
ignwarn << "Failed to find shape [" << _entity << "]." << std::endl;
return true;
}

auto slipComplianceShape = entityCast(_entity, shapeIt->second,
this->entityShapeSlipParamMap);

if (!slipComplianceShape)
{
ignwarn << "Can't process Wheel Slip component, physics engine "
<< "missing SetShapeFrictionPyramidSlipCompliance"
<< std::endl;

// Break Each call since no SlipCompliances can be processed
return false;
}

if (_slipCmdComp->Data().size() == 2)
{
slipComplianceShape->SetPrimarySlipCompliance(
_slipCmdComp->Data()[0]);
slipComplianceShape->SetSecondarySlipCompliance(
_slipCmdComp->Data()[1]);
}

return true;
});

// Clear pending commands
// Note: Removing components from inside an Each call can be dangerous.
// Instead, we collect all the entities that have the desired components and
Expand Down Expand Up @@ -1597,6 +1657,13 @@ void PhysicsPrivate::UpdateSim(EntityComponentManager &_ecm) const
return true;
});

_ecm.Each<components::SlipComplianceCmd>(
[&](const Entity &, components::SlipComplianceCmd *_slip) -> bool
{
std::fill(_slip->Data().begin(), _slip->Data().end(), 0.0);
return true;
});

// Update joint positions
_ecm.Each<components::Joint, components::JointPosition>(
[&](const Entity &_entity, components::Joint *,
Expand Down
6 changes: 6 additions & 0 deletions src/systems/wheel_slip/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gz_add_system(wheel-slip
SOURCES
WheelSlip.cc
PUBLIC_LINK_LIBS
ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
)
Loading