Skip to content

Commit

Permalink
Moved msgs to sub-package to make them work
Browse files Browse the repository at this point in the history
  • Loading branch information
MatjazBostic committed Aug 26, 2024
1 parent 9b77691 commit d486667
Show file tree
Hide file tree
Showing 9 changed files with 1,201 additions and 16 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ find_package(std_msgs REQUIRED)
find_package(hardware_interface REQUIRED)
find_package(ros2_control REQUIRED)
find_package(diagnostic_updater REQUIRED)
find_package(ubiquity_motor_ros2_msgs REQUIRED)
# find_package(zenohc REQUIRED)

# add_compile_definitions(ZENOHCXX_ZENOHC) # Tells zenoh-cpp to use zenoh-c
Expand All @@ -33,6 +34,9 @@ find_package(diagnostic_updater REQUIRED)
# DEPENDENCIES std_msgs # Add this line
# )

# Ensure the generated code is built before anything else that uses it
# ament_export_dependencies(rosidl_default_runtime)


set(serial_SRCS
serial/src/serial.cc
Expand All @@ -43,6 +47,8 @@ set(serial_SRCS
list(APPEND serial_SRCS serial/src/impl/unix.cc)
list(APPEND serial_SRCS serial/src/impl/list_ports/list_ports_linux.cc)
add_library(ur_serial SHARED ${serial_SRCS})
# target_link_libraries(ur_serial /usr/local/lib/libpython3.8.so)

# Link libraries (add any additional libraries if needed)
target_link_libraries(ur_serial rt pthread)
##H HACK to contain all serial stuff in here
Expand Down Expand Up @@ -119,8 +125,9 @@ ament_target_dependencies(${PROJECT_NAME}_lib
"hardware_interface"
"ros2_control"
"diagnostic_updater"
# "rosidl_default_runtime"
"ubiquity_motor_ros2_msgs"
# "${PROJECT_NAME}" # This adds a dependency on the generated messages in the same package

)

# # Add executable
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Ubiquity motor ROS 2

## Build the motor node
colcon build --packages-select ubiquity_motor_ros2 --cmake-args -DCMAKE_PREFIX_PATH=/home/ubuntu/ros2_ws/install/zenohc --symlink-install --event-handlers console_direct+

## Build the examples
colcon build --packages-select zenohcxx --cmake-args -DCMAKE_PREFIX_PATH=/home/ubuntu/ros2_ws/install/zenohc --cmake-target examples --symlink-install --event-handlers console_direct+
## Build the motor node and its msgs
colcon build --base-paths src/ubiquity_motor_ros2 src/ubiquity_motor_ros2/ubiquity_motor_ros2_msgs --cmake-args --event-handlers console_direct+
3 changes: 2 additions & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
<depend>hardware_interface</depend>

<build_depend>std_msgs</build_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>std_msgs</exec_depend>

<depend>ubiquity_motor_ros2_msgs</depend>


<export>
Expand Down
1,132 changes: 1,124 additions & 8 deletions src/motor_hardware.cc

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/motor_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ MotorNode::MotorNode()

RCLCPP_INFO(get_logger(), "Motor node is starting.");

run();
}


Expand Down Expand Up @@ -334,6 +333,10 @@ void MotorNode::run() {
f = boost::bind(&PID_update_callback, _1, _2);
server.setCallback(f);





robot->setParams(g_firmware_params);
robot->requestFirmwareVersion();

Expand Down Expand Up @@ -594,6 +597,8 @@ int main(int argc, char* argv[]) {
rclcpp::init(argc, argv);

auto node = std::make_shared<MotorNode>();
node->run();

rclcpp::spin(node);
rclcpp::shutdown();

Expand Down
35 changes: 35 additions & 0 deletions ubiquity_motor_ros2_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.5)

project(ubiquity_motor_ros2_msgs)

# Default to C99
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_package(ament_cmake REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(std_msgs REQUIRED)

set(msg_files
"msg/MotorState.msg"
"msg/Leds.msg"
)

rosidl_generate_interfaces(${PROJECT_NAME}
${msg_files}
DEPENDENCIES std_msgs
ADD_LINTER_TESTS
)

ament_export_dependencies(rosidl_default_runtime)

ament_package()
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions ubiquity_motor_ros2_msgs/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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>ubiquity_motor_ros2_msgs</name>
<version>1.0.0</version>
<description>Custom msgs for ubiquity_motor_ros2</description>
<maintainer email="mb@ubiquityrobotics.com">Matjaz Bostic</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>rosidl_default_generators</buildtool_depend>

<depend>std_msgs</depend>

<exec_depend>rosidl_default_runtime</exec_depend>

<test_depend>ament_lint_common</test_depend>

<member_of_group>rosidl_interface_packages</member_of_group>

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

0 comments on commit d486667

Please sign in to comment.