forked from Field-Robotics-Lab/dave
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from IOES-Lab/usbl-plugins
[GSOC-67] Migration of USBL plugins
- Loading branch information
Showing
15 changed files
with
1,469 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(dave_interfaces) | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
endif() | ||
|
||
# find dependencies | ||
find_package(ament_cmake REQUIRED) | ||
find_package(rclcpp REQUIRED) | ||
find_package(std_msgs REQUIRED) | ||
find_package(rosidl_default_generators REQUIRED) | ||
|
||
rosidl_generate_interfaces(${PROJECT_NAME} | ||
"msg/UsblCommand.msg" | ||
"msg/UsblResponse.msg" | ||
"msg/Location.msg" | ||
) | ||
|
||
# Install message package.xml | ||
install(FILES | ||
package.xml | ||
DESTINATION share/${PROJECT_NAME} | ||
) | ||
|
||
ament_export_dependencies(rosidl_default_runtime) | ||
# Install CMake package configuration | ||
ament_export_include_directories(include) | ||
|
||
ament_package() |
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,4 @@ | ||
int32 transponder_id | ||
float64 x | ||
float64 y | ||
float64 z |
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,3 @@ | ||
int32 transponder_id | ||
int32 command_id | ||
string data |
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,3 @@ | ||
int32 transceiver_id | ||
int32 response_id | ||
string data |
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,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?><package format="3"> | ||
<name>dave_interfaces</name> | ||
<version>0.0.0</version> | ||
<description>TODO: Package description</description> | ||
<maintainer email="[email protected]">lena</maintainer> | ||
<license>TODO: License declaration</license> | ||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
<depend>rclcpp</depend> | ||
<depend>std_msgs</depend> | ||
<build_depend>rosidl_default_generators</build_depend> | ||
<exec_depend>rosidl_default_runtime</exec_depend> | ||
<member_of_group>rosidl_interface_packages</member_of_group> | ||
<test_depend>ament_lint_auto</test_depend> | ||
<test_depend>ament_lint_common</test_depend> | ||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
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,71 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
|
||
# Define the project name | ||
project(dave_gz_sensor_plugins) | ||
|
||
# Find required packages | ||
find_package(ament_cmake REQUIRED) | ||
find_package(gz-cmake3 REQUIRED) | ||
find_package(gz-plugin2 REQUIRED COMPONENTS register) | ||
find_package(rclcpp REQUIRED) | ||
find_package(std_msgs REQUIRED) | ||
find_package(gz-common5 REQUIRED COMPONENTS profiler) | ||
find_package(gz-sim8 REQUIRED) | ||
find_package(geometry_msgs REQUIRED) | ||
find_package(dave_interfaces REQUIRED) | ||
|
||
# Set version variables | ||
set(GZ_PLUGIN_VER ${gz-plugin2_VERSION_MAJOR}) | ||
set(GZ_COMMON_VER ${gz-common5_VERSION_MAJOR}) | ||
set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR}) | ||
|
||
message(STATUS "Compiling against Gazebo Harmonic") | ||
|
||
add_library(UsblTransceiver SHARED src/UsblTransceiver.cc) | ||
add_library(UsblTransponder SHARED src/UsblTransponder.cc) | ||
|
||
target_include_directories(UsblTransceiver PRIVATE include) | ||
target_include_directories(UsblTransponder PRIVATE include) | ||
|
||
target_link_libraries(UsblTransceiver | ||
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}) | ||
|
||
target_link_libraries(UsblTransponder | ||
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}) | ||
|
||
|
||
# Specify dependencies for FullSystem using ament_target_dependencies | ||
ament_target_dependencies(UsblTransceiver | ||
dave_interfaces | ||
rclcpp | ||
geometry_msgs | ||
std_msgs | ||
) | ||
|
||
ament_target_dependencies(UsblTransponder | ||
dave_interfaces | ||
rclcpp | ||
std_msgs | ||
) | ||
|
||
# Install targets | ||
install(TARGETS UsblTransceiver UsblTransponder | ||
DESTINATION lib/${PROJECT_NAME} | ||
) | ||
|
||
# Install headers | ||
install(DIRECTORY include/ | ||
DESTINATION include/ | ||
) | ||
|
||
# Environment hooks | ||
ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/hooks/${PROJECT_NAME}.dsv.in") | ||
|
||
# Testing setup | ||
if(BUILD_TESTING) | ||
find_package(ament_lint_auto REQUIRED) | ||
ament_lint_auto_find_test_dependencies() | ||
endif() | ||
|
||
# Configure ament | ||
ament_package() |
1 change: 1 addition & 0 deletions
1
gazebo/dave_gz_sensor_plugins/hooks/dave_gz_sensor_plugins.dsv.in
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 @@ | ||
prepend-non-duplicate;GZ_SIM_SYSTEM_PLUGIN_PATH;lib/@PROJECT_NAME@/ |
73 changes: 73 additions & 0 deletions
73
gazebo/dave_gz_sensor_plugins/include/dave_gz_sensor_plugins/UsblTransceiver.hh
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,73 @@ | ||
/* | ||
* Copyright (C) 2022 Open Source Robotics Foundation | ||
* | ||
* 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 DAVE_GZ_SENSOR_PLUGINS__USBLTRANSCEIVER_HH_ | ||
#define DAVE_GZ_SENSOR_PLUGINS__USBLTRANSCEIVER_HH_ | ||
|
||
#include <gz/msgs/vector3d.pb.h> | ||
#include <math.h> | ||
#include <memory> | ||
#include <string> | ||
|
||
#include <gz/sim/System.hh> | ||
#include <rclcpp/rclcpp.hpp> | ||
#include <std_msgs/msg/float64.hpp> | ||
#include <std_msgs/msg/string.hpp> | ||
#include "dave_interfaces/msg/location.hpp" | ||
#include "dave_interfaces/msg/usbl_command.hpp" | ||
#include "dave_interfaces/msg/usbl_response.hpp" | ||
|
||
namespace dave_gz_sensor_plugins | ||
|
||
{ | ||
class UsblTransceiver : public gz::sim::System, | ||
public gz::sim::ISystemConfigure, | ||
public gz::sim::ISystemPostUpdate | ||
{ | ||
public: | ||
UsblTransceiver(); | ||
~UsblTransceiver() override = default; | ||
|
||
void Configure( | ||
const gz::sim::Entity & entity, const std::shared_ptr<const sdf::Element> & sdf, | ||
gz::sim::EntityComponentManager & ecm, gz::sim::EventManager & eventMgr) override; | ||
|
||
void PostUpdate( | ||
const gz::sim::UpdateInfo & info, const gz::sim::EntityComponentManager & ecm) override; | ||
|
||
void receiveGazeboCallback( | ||
const std::string & transponder, const gz::msgs::Vector3d & transponder_position); | ||
void temperatureRosCallback(const std_msgs::msg::Float64::SharedPtr msg); | ||
void interrogationModeRosCallback(const std_msgs::msg::String::SharedPtr msg); | ||
void commandingResponseCallback(const dave_interfaces::msg::UsblResponse msg); | ||
void channelSwitchCallback(const std_msgs::msg::String::SharedPtr msg); | ||
void commandingResponseTestCallback(const std_msgs::msg::String::SharedPtr msg); | ||
void sendCommand(int command_id, std::string & transponder_id); | ||
void sendPing(); | ||
void calculateRelativePose( | ||
gz::math::Vector3<double> position, double & bearing, double & range, double & elevation); | ||
void publishPosition(int & transponder_id, double & bearing, double & range, double & elevation); | ||
|
||
private: | ||
std::shared_ptr<rclcpp::Node> ros_node_; | ||
|
||
struct PrivateData; | ||
std::unique_ptr<PrivateData> dataPtr; | ||
}; | ||
} // namespace dave_gz_sensor_plugins | ||
|
||
#endif // DAVE_GZ_SENSOR_PLUGINS__USBLTRANSCEIVER_HH_ |
66 changes: 66 additions & 0 deletions
66
gazebo/dave_gz_sensor_plugins/include/dave_gz_sensor_plugins/UsblTransponder.hh
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,66 @@ | ||
/* | ||
* Copyright (C) 2022 Open Source Robotics Foundation | ||
* | ||
* 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 DAVE_GZ_SENSOR_PLUGINS__USBLTRANSPONDER_HH_ | ||
#define DAVE_GZ_SENSOR_PLUGINS__USBLTRANSPONDER_HH_ | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include <gz/sim/System.hh> | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
#include <std_msgs/msg/float64.hpp> | ||
#include <std_msgs/msg/string.hpp> | ||
#include "dave_interfaces/msg/usbl_command.hpp" | ||
#include "dave_interfaces/msg/usbl_response.hpp" | ||
|
||
namespace dave_gz_sensor_plugins | ||
|
||
{ | ||
class UsblTransponder : public gz::sim::System, | ||
public gz::sim::ISystemConfigure, | ||
public gz::sim::ISystemPostUpdate | ||
{ | ||
public: | ||
UsblTransponder(); | ||
~UsblTransponder() override = default; | ||
|
||
void Configure( | ||
const gz::sim::Entity & entity, const std::shared_ptr<const sdf::Element> & sdf, | ||
gz::sim::EntityComponentManager & ecm, gz::sim::EventManager & eventMgr) override; | ||
|
||
void PostUpdate( | ||
const gz::sim::UpdateInfo & info, const gz::sim::EntityComponentManager & ecm) override; | ||
|
||
void sendLocation(); | ||
void iisRosCallback(const std_msgs::msg::String::SharedPtr msg); | ||
void temperatureRosCallback(const std_msgs::msg::Float64::SharedPtr msg); | ||
void cisRosCallback(const std_msgs::msg::String::SharedPtr msg); | ||
void commandRosCallback(const dave_interfaces::msg::UsblCommand msg); | ||
void sendPing(); | ||
void interrogationModeCallback(const std_msgs::msg::String::SharedPtr msg); | ||
|
||
private: | ||
std::shared_ptr<rclcpp::Node> ros_node_; | ||
|
||
struct PrivateData; | ||
std::unique_ptr<PrivateData> dataPtr; | ||
}; | ||
} // namespace dave_gz_sensor_plugins | ||
|
||
#endif // DAVE_GZ_SENSOR_PLUGINS__USBLTRANSPONDER_HH_ |
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,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?><package format="3"> | ||
<name>dave_gz_sensor_plugins</name> | ||
<version>0.0.0</version> | ||
<description>DAVE sensor plugins</description> | ||
<maintainer email="[email protected]">Helena Moyen</maintainer> | ||
<license>Apache 2.0</license> | ||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
<test_depend>ament_lint_auto</test_depend> | ||
<build_depend>dave_interfaces</build_depend> | ||
<exec_depend>dave_interfaces</exec_depend> | ||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
Oops, something went wrong.