-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
- Loading branch information
1 parent
591b8b5
commit 719d3b5
Showing
9 changed files
with
166 additions
and
7 deletions.
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
43 changes: 43 additions & 0 deletions
43
ros_gz_bridge/include/ros_gz_bridge/convert/actuator_msgs.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,43 @@ | ||
// Copyright 2023 Rudis Laboratories LLC | ||
// | ||
// 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 ROS_GZ_BRIDGE__CONVERT__ACTUATOR_MSGS_HPP_ | ||
#define ROS_GZ_BRIDGE__CONVERT__ACTUATOR_MSGS_HPP_ | ||
|
||
// Gazebo Msgs | ||
#include <ignition/msgs/actuators.pb.h> | ||
|
||
// ROS 2 messages | ||
#include <actuator_msgs/msg/actuators.hpp> | ||
|
||
#include <ros_gz_bridge/convert_decl.hpp> | ||
|
||
namespace ros_gz_bridge | ||
{ | ||
// actuator_msgs | ||
template<> | ||
void | ||
convert_ros_to_gz( | ||
const actuator_msgs::msg::Actuators & ros_msg, | ||
ignition::msgs::Actuators & gz_msg); | ||
|
||
template<> | ||
void | ||
convert_gz_to_ros( | ||
const ignition::msgs::Actuators & gz_msg, | ||
actuator_msgs::msg::Actuators & ros_msg); | ||
|
||
} // namespace ros_gz_bridge | ||
|
||
#endif // ROS_GZ_BRIDGE__CONVERT__ACTUATOR_MSGS_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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright 2023 Rudis Laboratories LLC | ||
// | ||
// 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 "convert/utils.hpp" | ||
#include "ros_gz_bridge/convert/actuator_msgs.hpp" | ||
|
||
namespace ros_gz_bridge | ||
{ | ||
|
||
template<> | ||
void | ||
convert_ros_to_gz( | ||
const actuator_msgs::msg::Actuators & ros_msg, | ||
ignition::msgs::Actuators & gz_msg) | ||
{ | ||
convert_ros_to_gz(ros_msg.header, (*gz_msg.mutable_header())); | ||
|
||
for (auto i = 0u; i < ros_msg.position.size(); ++i) { | ||
gz_msg.add_position(ros_msg.position[i]); | ||
} | ||
|
||
for (auto i = 0u; i < ros_msg.velocity.size(); ++i) { | ||
gz_msg.add_velocity(ros_msg.velocity[i]); | ||
} | ||
for (auto i = 0u; i < ros_msg.normalized.size(); ++i) { | ||
gz_msg.add_normalized(ros_msg.normalized[i]); | ||
} | ||
} | ||
|
||
template<> | ||
void | ||
convert_gz_to_ros( | ||
const ignition::msgs::Actuators & gz_msg, | ||
actuator_msgs::msg::Actuators & ros_msg) | ||
{ | ||
convert_gz_to_ros(gz_msg.header(), ros_msg.header); | ||
|
||
for (auto i = 0; i < gz_msg.position_size(); ++i) { | ||
ros_msg.position.push_back(gz_msg.position(i)); | ||
} | ||
|
||
for (auto i = 0; i < gz_msg.velocity_size(); ++i) { | ||
ros_msg.velocity.push_back(gz_msg.velocity(i)); | ||
} | ||
|
||
for (auto i = 0; i < gz_msg.normalized_size(); ++i) { | ||
ros_msg.normalized.push_back(gz_msg.normalized(i)); | ||
} | ||
} | ||
|
||
} // namespace ros_gz_bridge |
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