Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create UWRT utils package #184

Open
wants to merge 13 commits into
base: uwrt-mars-rover-arm-dev
Choose a base branch
from
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

devel/
bin/
msg_gen/
Expand Down Expand Up @@ -59,3 +60,6 @@ COLCON_IGNORE
# uwrt_mars_rover_hw_bridge shouldnt be added as a git submodule
uwrt_mars_rover_utils/lib/uwrt_mars_rover_hw_bridge/

uwrt_mars_rover_arm/uwrt_mars_rover_arm_hw/compile_commands.json
uwrt_mars_rover_arm/uwrt_mars_rover_arm_hw/compile_commands.json
.gitignore
14 changes: 14 additions & 0 deletions uwrt_mars_rover_arm/uwrt_mars_rover_arm_hw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,22 @@ if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

# add_library(uwrt_mars_rover_utils SHARED IMPORTED)
# target_link_libraries(
# ${PROJECT_NAME}
# PUBLIC
# uwrt_mars_rover_utils::uwrt_mars_rover_utils
# )


# find dependencies
find_package(ament_cmake REQUIRED)
find_package(hardware_interface REQUIRED)
find_package(transmission_interface REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(uwrt_mars_rover_utils REQUIRED)

include_directories(include)

Expand All @@ -41,21 +50,26 @@ include_directories(include)
# include
#)


# add dynamic library & it's dependecies
add_library(
${PROJECT_NAME}
SHARED
src/${PROJECT_NAME}_actuator.cpp
src/${PROJECT_NAME}_differential.cpp
)

ament_target_dependencies(
${PROJECT_NAME}
hardware_interface
transmission_interface
pluginlib
rclcpp_lifecycle
rclcpp
uwrt_mars_rover_utils
)


target_compile_options(${PROJECT_NAME} PRIVATE -Wshadow -Werror) # add some extra flags for this target
target_compile_definitions(${PROJECT_NAME} PRIVATE "UWRT_MARS_ROVER_ARM_HW_DLL") # visibility header stuff regarding .so files
#TODO: fill in the above correct compile definition above
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,11 @@
#include <rclcpp_lifecycle/state.hpp>
#include <transmission_interface/simple_transmission.hpp>
#include <vector>

#include <uwrt_mars_rover_utils/data_utils.hpp>
#include "uwrt_mars_rover_arm_hw/visibility.hpp"

namespace uwrt_mars_rover_arm_hw
{
// namespaced structs to hold transmission data - state & command
namespace TransmissionData
{
namespace ActuatorData
{
using CommandData = struct CommandData
{
double velocity{};
};

using StateData = struct StateData
{
double velocity{};
double position{};
double iq_current{}; // not used for differential transmission
};

} // namespace ActuatorData
namespace JointData
{
using CommandData = struct CommandData
{
double velocity{};
};

using StateData = struct StateData
{
double velocity{};
double position{};
};

} // namespace JointData

} // namespace TransmissionData

class ArmActuatorInterface : public hardware_interface::ActuatorInterface
{
Expand Down Expand Up @@ -115,10 +81,10 @@ class ArmActuatorInterface : public hardware_interface::ActuatorInterface
inline static constexpr std::size_t NUM_COMMAND_INTERFACES{1};

// holds actuator reads/writes
TransmissionData::ActuatorData::CommandData actuator_commands{};
TransmissionData::ActuatorData::StateData actuator_states{};
TransmissionData::JointData::CommandData joint_commands{};
TransmissionData::JointData::StateData joint_states{};
DifferentialTransmissionData::ActuatorData::CommandData actuator_commands{};
DifferentialTransmissionData::ActuatorData::StateData actuator_states{};
DifferentialTransmissionData::JointData::CommandData joint_commands{};
DifferentialTransmissionData::JointData::StateData joint_states{};

// transmission for state & command transmission
std::shared_ptr<transmission_interface::SimpleTransmission> command_transmission{nullptr};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <rclcpp/macros.hpp>
#include <rclcpp_lifecycle/state.hpp>
#include <transmission_interface/differential_transmission.hpp>
#include <uwrt_mars_rover_utils/data_utils.hpp>
#include <vector>

#include "transmission_interface/handle.hpp"
Expand All @@ -23,40 +24,6 @@

namespace uwrt_mars_rover_arm_hw
{
namespace DifferentialTransmissionData
{
namespace ActuatorData
{
using CommandData = struct CommandData
{
double
velocity{}; //TODO: change this so that it can work with any interface type... add enum class that will hold the different command types
};

using StateData = struct StateData
{
double velocity{};
double position{};
double iq_current{}; // not used for differential transmission
};

} // namespace ActuatorData
namespace JointData
{
using CommandData = struct CommandData
{
double velocity{};
};

using StateData = struct StateData
{
double velocity{};
double position{};
};

} // namespace JointData

} // namespace DifferentialTransmissionData

class ArmDifferentialSystemInterface : public hardware_interface::SystemInterface
{
Expand Down
1 change: 1 addition & 0 deletions uwrt_mars_rover_arm/uwrt_mars_rover_arm_hw/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<depend>rclcpp</depend>
<depend>rclcpp_lifecycle</depend>
<depend>transmission_interface</depend>
<depend>uwrt_mars_rover_utils</depend>

<test_depend>ament_cmake_cppcheck</test_depend>
<test_depend>ament_clang_tidy</test_depend>
Expand Down
79 changes: 79 additions & 0 deletions uwrt_mars_rover_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
cmake_minimum_required(VERSION 3.8)
project(uwrt_mars_rover_utils)

# set C/C++ standard
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()


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)

add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(
${PROJECT_NAME}
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

ament_export_targets(${PROJECT_NAME}Targets HAS_LIBRARY_TARGET)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wmmc88 I'm not sure what the Modern CMake replacement is for this ament_export_targets line is but this line seems to be required for this to build.



install(
DIRECTORY include/
DESTINATION include
)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)




if(BUILD_TESTING)
# Force generation of compile_commands.json for clang-tidy
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")

# clang-format
find_package(ament_cmake_clang_format REQUIRED)
ament_clang_format(
CONFIG_FILE ${CMAKE_SOURCE_DIR}/../../.clang-format
)

# clang-tidy
find_package(ament_cmake_clang_tidy REQUIRED)
ament_clang_tidy(
${CMAKE_BINARY_DIR}
CONFIG_FILE ${CMAKE_SOURCE_DIR}/../../.clang-tidy
)

# cppcheck
find_package(ament_cmake_cppcheck REQUIRED)
ament_cppcheck()

# flake8
find_package(ament_cmake_flake8 REQUIRED)
ament_flake8(
CONFIG_FILE ${CMAKE_SOURCE_DIR}/../../.flake8
)

# xmllint
find_package(ament_cmake_xmllint REQUIRED)
ament_xmllint()
endif()

ament_package()
34 changes: 34 additions & 0 deletions uwrt_mars_rover_utils/include/uwrt_mars_rover_utils/data_utils.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once

namespace DifferentialTransmissionData {

namespace ActuatorData {

struct CommandData {
double velocity{}; // TODO: change this so that it can work with any interface type... add enum class that will hold
// the different command types
};

struct StateData {
double velocity{};
double position{};
double iq_current{}; // not used for differential transmission
};

} // namespace ActuatorData

// keeping this separate from ActuatorData despite the overlap for extensibility reasons
namespace JointData {

struct CommandData {
double velocity{};
};

struct StateData {
double velocity{};
double position{};
};

} // namespace JointData

} // namespace DifferentialTransmissionData
23 changes: 23 additions & 0 deletions uwrt_mars_rover_utils/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>uwrt_mars_rover_utils</name>
<version>0.0.0</version>
<description>UWRT Mars Rover utilities package for avoiding duplicate code.</description>
<maintainer email="[email protected]">keyonjerome</maintainer>
<license>MIT</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>ament_cmake_clang_format</test_depend>
<test_depend>ament_cmake_clang_tidy</test_depend>
<test_depend>ament_cmake_cppcheck</test_depend>
<test_depend>ament_cmake_flake8</test_depend>
<test_depend>ament_cmake_xmllint</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>