-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: Vincent Rousseau <[email protected]> Signed-off-by: Alejandro Hernández Cordero <[email protected]> Co-authored-by: Rousseau Vincent <[email protected]>
- Loading branch information
1 parent
c3e7939
commit d87d63d
Showing
11 changed files
with
218 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
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,41 @@ | ||
// Copyright 2022 Open Source Robotics Foundation, Inc. | ||
// | ||
// 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__GPS_MSGS_HPP_ | ||
#define ROS_GZ_BRIDGE__CONVERT__GPS_MSGS_HPP_ | ||
|
||
// Gazebo Msgs | ||
#include <gz/msgs/navsat.pb.h> | ||
|
||
// ROS 2 messages | ||
#include <gps_msgs/msg/gps_fix.hpp> | ||
|
||
#include <ros_gz_bridge/convert_decl.hpp> | ||
|
||
namespace ros_gz_bridge | ||
{ | ||
template<> | ||
void | ||
convert_ros_to_gz( | ||
const gps_msgs::msg::GPSFix & ros_msg, | ||
gz::msgs::NavSat & gz_msg); | ||
|
||
template<> | ||
void | ||
convert_gz_to_ros( | ||
const gz::msgs::NavSat & gz_msg, | ||
gps_msgs::msg::GPSFix & ros_msg); | ||
} // namespace ros_gz_bridge | ||
|
||
#endif // ROS_GZ_BRIDGE__CONVERT__GPS_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,63 @@ | ||
// Copyright 2022 Open Source Robotics Foundation, Inc. | ||
// | ||
// 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 <cmath> | ||
|
||
#include "convert/utils.hpp" | ||
#include "ros_gz_bridge/convert/gps_msgs.hpp" | ||
|
||
namespace ros_gz_bridge | ||
{ | ||
|
||
template<> | ||
void | ||
convert_ros_to_gz( | ||
const gps_msgs::msg::GPSFix & ros_msg, | ||
gz::msgs::NavSat & gz_msg) | ||
{ | ||
convert_ros_to_gz(ros_msg.header, (*gz_msg.mutable_header())); | ||
gz_msg.set_latitude_deg(ros_msg.latitude); | ||
gz_msg.set_longitude_deg(ros_msg.longitude); | ||
gz_msg.set_altitude(ros_msg.altitude); | ||
gz_msg.set_frame_id(ros_msg.header.frame_id); | ||
|
||
gz_msg.set_velocity_east(cos(ros_msg.track) * ros_msg.speed); | ||
gz_msg.set_velocity_north(sin(ros_msg.track) * ros_msg.speed); | ||
gz_msg.set_velocity_up(ros_msg.climb); | ||
} | ||
|
||
template<> | ||
void | ||
convert_gz_to_ros( | ||
const gz::msgs::NavSat & gz_msg, | ||
gps_msgs::msg::GPSFix & ros_msg) | ||
{ | ||
convert_gz_to_ros(gz_msg.header(), ros_msg.header); | ||
ros_msg.header.frame_id = frame_id_gz_to_ros(gz_msg.frame_id()); | ||
ros_msg.latitude = gz_msg.latitude_deg(); | ||
ros_msg.longitude = gz_msg.longitude_deg(); | ||
ros_msg.altitude = gz_msg.altitude(); | ||
|
||
ros_msg.speed = sqrt( | ||
gz_msg.velocity_east() * gz_msg.velocity_east() + | ||
gz_msg.velocity_north() * gz_msg.velocity_north()); | ||
ros_msg.track = atan2(gz_msg.velocity_north(), gz_msg.velocity_east()); | ||
ros_msg.climb = gz_msg.velocity_up(); | ||
|
||
// position_covariance is not supported in gz::msgs::NavSat. | ||
ros_msg.position_covariance_type = gps_msgs::msg::GPSFix::COVARIANCE_TYPE_UNKNOWN; | ||
ros_msg.status.status = gps_msgs::msg::GPSStatus::STATUS_GBAS_FIX; | ||
} | ||
|
||
} // 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
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,63 @@ | ||
# Copyright 2022 Open Source Robotics Foundation, Inc. | ||
# | ||
# 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. | ||
|
||
import os | ||
|
||
from ament_index_python.packages import get_package_share_directory | ||
|
||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument | ||
from launch.actions import IncludeLaunchDescription | ||
from launch.conditions import IfCondition | ||
from launch.launch_description_sources import PythonLaunchDescriptionSource | ||
from launch.substitutions import LaunchConfiguration | ||
|
||
from launch_ros.actions import Node | ||
|
||
|
||
def generate_launch_description(): | ||
|
||
pkg_ros_gz_sim = get_package_share_directory('ros_gz_sim') | ||
|
||
gz_sim = IncludeLaunchDescription( | ||
PythonLaunchDescriptionSource( | ||
os.path.join(pkg_ros_gz_sim, 'launch', 'gz_sim.launch.py')), | ||
launch_arguments={ | ||
'gz_args': '-v 4 -r spherical_coordinates.sdf' | ||
}.items(), | ||
) | ||
|
||
# RQt | ||
rqt = Node( | ||
package='rqt_topic', | ||
executable='rqt_topic', | ||
arguments=['-t'], | ||
condition=IfCondition(LaunchConfiguration('rqt')) | ||
) | ||
|
||
# Bridge | ||
bridge = Node( | ||
package='ros_gz_bridge', | ||
executable='parameter_bridge', | ||
arguments=['/navsat@gps_msgs/msg/[email protected]'], | ||
output='screen' | ||
) | ||
|
||
return LaunchDescription([ | ||
gz_sim, | ||
DeclareLaunchArgument('rqt', default_value='true', | ||
description='Open RQt.'), | ||
bridge, | ||
rqt | ||
]) |