-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port four bar linkage transmission loader from ROS1
- Loading branch information
VX792
authored and
VX792
committed
Mar 1, 2022
1 parent
bb131f8
commit 9a9dcd9
Showing
7 changed files
with
620 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...mission_interface/include/transmission_interface/four_bar_linkage_transmission_loader.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// Copyright (C) 2022, PAL Robotics S.L. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// * Redistributions of source code must retain the above copyright notice, | ||
// this list of conditions and the following disclaimer. | ||
// * Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// * Neither the name of PAL Robotics S.L. nor the names of its | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
// POSSIBILITY OF SUCH DAMAGE. | ||
////////////////////////////////////////////////////////////////////////////// | ||
|
||
#ifndef TRANSMISSION_INTERFACE__FOUR_BAR_LINKAGE_TRANSMISSION_LOADER_HPP_ | ||
#define TRANSMISSION_INTERFACE__FOUR_BAR_LINKAGE_TRANSMISSION_LOADER_HPP_ | ||
|
||
#include <memory> | ||
|
||
#include "transmission_interface/transmission.hpp" | ||
#include "transmission_interface/transmission_loader.hpp" | ||
|
||
namespace transmission_interface | ||
{ | ||
/** | ||
* \brief Class for loading a four-bar linkage transmission instance from configuration data. | ||
*/ | ||
class FourBarLinkageTransmissionLoader : public TransmissionLoader | ||
{ | ||
public: | ||
std::shared_ptr<Transmission> load( | ||
const hardware_interface::TransmissionInfo & transmission_info) override; | ||
}; | ||
|
||
} // namespace transmission_interface | ||
|
||
#endif // TRANSMISSION_INTERFACE__FOUR_BAR_LINKAGE_TRANSMISSION_LOADER_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
transmission_interface/src/four_bar_linkage_transmission_loader.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2022 PAL Robotics S.L. | ||
// | ||
// 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. | ||
|
||
#include "transmission_interface/four_bar_linkage_transmission_loader.hpp" | ||
|
||
#include <memory> | ||
|
||
#include "hardware_interface/component_parser.hpp" | ||
#include "hardware_interface/hardware_info.hpp" | ||
#include "hardware_interface/types/hardware_interface_type_values.hpp" | ||
#include "pluginlib/class_list_macros.hpp" | ||
#include "rclcpp/logging.hpp" | ||
#include "rclcpp/rclcpp.hpp" | ||
#include "transmission_interface/four_bar_linkage_transmission.hpp" | ||
|
||
namespace transmission_interface | ||
{ | ||
std::shared_ptr<Transmission> FourBarLinkageTransmissionLoader::load( | ||
const hardware_interface::TransmissionInfo & transmission_info) | ||
{ | ||
try | ||
{ | ||
const auto act_reduction1 = transmission_info.actuators.at(0).mechanical_reduction; | ||
const auto act_reduction2 = transmission_info.actuators.at(1).mechanical_reduction; | ||
|
||
const auto jnt_reduction1 = transmission_info.joints.at(0).mechanical_reduction; | ||
const auto jnt_reduction2 = transmission_info.joints.at(1).mechanical_reduction; | ||
|
||
const auto jnt_offset1 = transmission_info.joints.at(0).offset; | ||
const auto jnt_offset2 = transmission_info.joints.at(1).offset; | ||
|
||
std::shared_ptr<Transmission> transmission(new FourBarLinkageTransmission( | ||
{act_reduction1, act_reduction2}, {jnt_reduction1, jnt_reduction2}, | ||
{jnt_offset1, jnt_offset2})); | ||
return transmission; | ||
} | ||
catch (const Exception & ex) | ||
{ | ||
RCLCPP_ERROR( | ||
rclcpp::get_logger("four_bar_linkage_transmission_loader"), | ||
"Failed to construct transmission '%s'", ex.what()); | ||
return std::shared_ptr<Transmission>(); | ||
} | ||
} | ||
|
||
} // namespace transmission_interface | ||
|
||
PLUGINLIB_EXPORT_CLASS( | ||
transmission_interface::FourBarLinkageTransmissionLoader, | ||
transmission_interface::TransmissionLoader) |
Oops, something went wrong.