Skip to content
Open
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
build/
install/
log/

devel/
bin/
msg_gen/
Expand Down Expand Up @@ -59,3 +63,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
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
64 changes: 64 additions & 0 deletions uwrt_mars_rover_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
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)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

include_directories(include)

add_library(
${PROJECT_NAME} SHARED
src/data_utils.cpp
)

target_include_directories(
${PROJECT_NAME}
PUBLIC
$<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)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
#set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
35 changes: 35 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,35 @@
#ifndef DIFFERENTIAL_TRANSMISSION_DATA_GUARD
#define DIFFERENTIAL_TRANSMISSION_DATA_GUARD

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
#endif
18 changes: 18 additions & 0 deletions uwrt_mars_rover_utils/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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="keyonjerome@gmail.com">keyonjerome</maintainer>
<license>TODO: License declaration</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
1 change: 1 addition & 0 deletions uwrt_mars_rover_utils/src/data_utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <uwrt_mars_rover_utils/data_utils.hpp>