|
| 1 | +/* |
| 2 | + * Copyright 2023 Open Source Robotics Foundation, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | +*/ |
| 17 | + |
| 18 | +//---------------------------------------------------------------------- |
| 19 | +/*!\file |
| 20 | + * |
| 21 | + * \author Lovro Ivanov [email protected] |
| 22 | + * \date 2023-03-15 |
| 23 | + * |
| 24 | + */ |
| 25 | +//---------------------------------------------------------------------- |
| 26 | + |
| 27 | +#ifndef IGNITION_GAZEBO_SYSTEMS_MIMICJOINTSYSTEM_HH_ |
| 28 | +#define IGNITION_GAZEBO_SYSTEMS_MIMICJOINTSYSTEM_HH_ |
| 29 | + |
| 30 | +//! [header] |
| 31 | +#include <memory> |
| 32 | + |
| 33 | +#include <ignition/gazebo/System.hh> |
| 34 | + |
| 35 | +//! <plugin filename="mimic-joint-system" name="ign_ros2_control::MimicJointSystem"> |
| 36 | +//! <joint_name>joint_name</joint_name> |
| 37 | +//! <mimic_joint_name>mimic_joint_name</mimic_joint_name> |
| 38 | +//! <multiplier>1.0</multiplier> |
| 39 | +//! <offset>0.0</offset> |
| 40 | +//! <joint_index>0</joint_index> |
| 41 | +//! <mimic_joint_index>0</mimic_joint_index> |
| 42 | +//! <p_gain>100.0</p_gain> |
| 43 | +//! <i_gain>0.1</i_gain> |
| 44 | +//! <d_gain>0.0</d_gain> |
| 45 | +//! <i_max>5.0</i_max> |
| 46 | +//! <i_min>-5.0</i_min> |
| 47 | +//! <cmd_max>500.0</cmd_max> |
| 48 | +//! <cmd_min>-500.0</cmd_min> |
| 49 | +//! <cmd_offset>0.0</cmd_offset> |
| 50 | +//! <dead_zone>0.001</dead_zone> |
| 51 | +//! <use_velocity_commands>false</use_velocity_commands> |
| 52 | +//! </plugin> |
| 53 | + |
| 54 | +namespace ign_ros2_control |
| 55 | +{ |
| 56 | + class MimicJointSystemPrivate; |
| 57 | + |
| 58 | + class MimicJointSystem: |
| 59 | + // This class is a system. |
| 60 | + public ignition::gazebo::System, |
| 61 | + public ignition::gazebo::ISystemConfigure, |
| 62 | + // This class also implements the ISystemPreUpdate, ISystemUpdate, |
| 63 | + // and ISystemPostUpdate interfaces. |
| 64 | + public ignition::gazebo::ISystemPreUpdate, |
| 65 | + public ignition::gazebo::ISystemUpdate, |
| 66 | + public ignition::gazebo::ISystemPostUpdate |
| 67 | + { |
| 68 | + public: MimicJointSystem(); |
| 69 | + |
| 70 | + public: ~MimicJointSystem() override=default; |
| 71 | + |
| 72 | + // Documentation inherited |
| 73 | + public: void Configure(const ignition::gazebo::Entity &_entity, |
| 74 | + const std::shared_ptr<const sdf::Element> &_sdf, |
| 75 | + ignition::gazebo::EntityComponentManager &_ecm, |
| 76 | + ignition::gazebo::EventManager &_eventMgr) override; |
| 77 | + |
| 78 | + public: void PreUpdate(const ignition::gazebo::UpdateInfo &_info, |
| 79 | + ignition::gazebo::EntityComponentManager &_ecm) override; |
| 80 | + |
| 81 | + public: void Update(const ignition::gazebo::UpdateInfo &_info, |
| 82 | + ignition::gazebo::EntityComponentManager &_ecm) override; |
| 83 | + |
| 84 | + public: void PostUpdate(const ignition::gazebo::UpdateInfo &_info, |
| 85 | + const ignition::gazebo::EntityComponentManager &_ecm) override; |
| 86 | + |
| 87 | + private: |
| 88 | + /// \brief Private data pointer |
| 89 | + private: std::unique_ptr<MimicJointSystemPrivate> dataPtr; |
| 90 | + }; |
| 91 | +} |
| 92 | +//! [header] |
| 93 | + |
| 94 | +#endif |
0 commit comments