Skip to content

Commit ea36469

Browse files
committed
Introduce MimicJointSystem plugin.
1 parent 01e6f68 commit ea36469

File tree

5 files changed

+559
-156
lines changed

5 files changed

+559
-156
lines changed

ign_ros2_control/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,31 @@ elseif("$ENV{IGNITION_VERSION}" STREQUAL "fortress")
4444
set(IGN_GAZEBO_VER ${ignition-gazebo6_VERSION_MAJOR})
4545
message(STATUS "Compiling against Ignition Fortress")
4646

47+
find_package(ignition-cmake2 REQUIRED)
48+
find_package(ignition-plugin1 REQUIRED COMPONENTS register)
49+
set(IGN_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR})
50+
add_library(mimic-joint-system SHARED src/MimicJointSystem.cc)
51+
target_link_libraries(mimic-joint-system
52+
PRIVATE ignition-plugin${IGN_PLUGIN_VER}::ignition-plugin${IGN_PLUGIN_VER}
53+
PRIVATE ignition-gazebo6::ignition-gazebo6)
54+
install(TARGETS mimic-joint-system
55+
DESTINATION lib)
56+
4757
else()
4858
find_package(ignition-gazebo6 REQUIRED)
4959
set(IGN_GAZEBO_VER ${ignition-gazebo6_VERSION_MAJOR})
5060
message(STATUS "Compiling against Ignition Fortress")
61+
62+
find_package(ignition-cmake2 REQUIRED)
63+
find_package(ignition-plugin1 REQUIRED COMPONENTS register)
64+
set(IGN_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR})
65+
add_library(mimic-joint-system SHARED src/MimicJointSystem.cc)
66+
target_link_libraries(mimic-joint-system
67+
ignition-gazebo${IGN_GAZEBO_VER}::core
68+
ignition-plugin${IGN_PLUGIN_VER}::register
69+
)
70+
install(TARGETS mimic-joint-system
71+
DESTINATION lib)
5172
endif()
5273

5374
find_package(ignition-plugin1 REQUIRED)
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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

Comments
 (0)