Skip to content

Commit 0b642d6

Browse files
Merge branch 'main' of https://github.com/WATonomous/humanoid into gtranqui-interfacing
2 parents f58fc7e + 04a7d72 commit 0b642d6

File tree

16 files changed

+513
-0
lines changed

16 files changed

+513
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
project(common_msgs)
3+
4+
if(NOT CMAKE_CXX_STANDARD)
5+
set(CMAKE_CXX_STANDARD 17)
6+
endif()
7+
8+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
9+
add_compile_options(-Wall -Wextra -Wpedantic)
10+
endif()
11+
12+
find_package(ament_cmake REQUIRED)
13+
find_package(rosidl_default_generators REQUIRED)
14+
find_package(std_msgs REQUIRED)
15+
find_package(geometry_msgs REQUIRED)
16+
17+
set(msg_files
18+
msg/ArmPose.msg
19+
msg/HandPose.msg
20+
msg/JointState.msg
21+
)
22+
23+
rosidl_generate_interfaces(${PROJECT_NAME}
24+
${msg_files}
25+
DEPENDENCIES std_msgs geometry_msgs
26+
)
27+
28+
ament_export_dependencies(rosidl_default_runtime)
29+
ament_package()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
std_msgs/Header header
2+
3+
string name
4+
5+
common_msgs/JointState shoulder
6+
common_msgs/JointState elbow
7+
common_msgs/JointState wrist
8+
9+
# Optional Overall Hand Pose
10+
bool include_hand_pose
11+
common_msgs/HandPose hand_pose
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
std_msgs/Header header
2+
3+
string name
4+
5+
# Thumb
6+
common_msgs/JointState thumb_cmc
7+
common_msgs/JointState thumb_mcp
8+
common_msgs/JointState thumb_ip
9+
10+
# Index
11+
common_msgs/JointState index_mcp
12+
common_msgs/JointState index_pip
13+
common_msgs/JointState index_dip
14+
15+
# Middle
16+
common_msgs/JointState middle_mcp
17+
common_msgs/JointState middle_pip
18+
common_msgs/JointState middle_dip
19+
20+
# Ring
21+
common_msgs/JointState ring_mcp
22+
common_msgs/JointState ring_pip
23+
common_msgs/JointState ring_dip
24+
25+
# Pinky
26+
common_msgs/JointState pinky_mcp
27+
common_msgs/JointState pinky_pip
28+
common_msgs/JointState pinky_dip
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
std_msgs/Header header
2+
3+
string name
4+
5+
float64[] position
6+
float64[] velocity
7+
float64[] effort
8+
9+
geometry_msgs/Quaternion orientation
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0"?>
2+
<package format="3">
3+
<name>common_msgs</name>
4+
<version>0.0.0</version>
5+
<description>Common ROS2 message definitions for the WATO Humanoid project.</description>
6+
7+
<maintainer email="gavintranquilino@gmail.com">Gavin Tranquilino</maintainer>
8+
<license>Apache2.0</license>
9+
10+
<buildtool_depend>ament_cmake</buildtool_depend>
11+
<depend>std_msgs</depend>
12+
<depend>geometry_msgs</depend>
13+
14+
<build_depend>rosidl_default_generators</build_depend>
15+
<exec_depend>rosidl_default_runtime</exec_depend>
16+
<member_of_group>rosidl_interface_packages</member_of_group>
17+
18+
<export>
19+
<build_type>ament_cmake</build_type>
20+
</export>
21+
</package>

docs/Architecture_Map.odg

10.4 KB
Binary file not shown.

utils/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Utils
2+
3+
## `create-package.bash`
4+
5+
### Usage
6+
`create-package.bash $package_name $module_name [-p] [-h]`
7+
- $package_name -> required, str: name of package
8+
- $module_name -> required, str: name of parent module
9+
- -p -> optional, flag: build python package. Defaults to a cpp package.
10+
- -h -> optional, flag: help description.
11+
12+
- ⚠️ Double check for these before running the script:
13+
- The `module_name` directory must exist beforehand for the script to work properly.
14+
- The `modules/docker-compose.module_name.yaml` must exist for the script to run.
15+
16+
### Description
17+
- Creates a ros2 python or cpp `package_name` in the `module_name`
18+
- Creates missing boilerplate files
19+
- If CPP build, these are:
20+
- launch/`package_name`.launch.py
21+
- config/params.yaml
22+
- src/`package_name`_node.cpp
23+
- include/`package_name`_node.hpp
24+
- src/`package_name`_core.cpp
25+
- include/`package_name`_core.hpp
26+
- test/`package_name`_test.cpp
27+
- If Python build, these are:
28+
- launch/`package_name`.launch.py
29+
- config/params.yaml
30+
- `package_name`/`package_name`_node.py
31+
- `package_name`/`package_name`_core.py
32+
- Modifies module_name.interfacing.Dockerfile to copy in package code into container.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import os
2+
from ament_index_python.packages import get_package_share_directory
3+
from launch import LaunchDescription
4+
from launch.actions import DeclareLaunchArgument, OpaqueFunction
5+
from launch.substitutions import LaunchConfiguration
6+
from launch_ros.actions import Node
7+
8+
9+
def launch_setup(context, *args, **kwargs):
10+
"""
11+
Dynamically determine package name and configuration path.
12+
13+
This function is called by OpaqueFunction to resolve launch arguments
14+
and create the Node action.
15+
"""
16+
# These values are resolved from the DeclareLaunchArgument definitions below
17+
package_name = LaunchConfiguration('package_name').perform(context)
18+
executable_name = LaunchConfiguration('executable_name').perform(context)
19+
node_name = LaunchConfiguration('node_name').perform(context)
20+
21+
# Construct the path to the parameter file within the current package
22+
# This assumes your params.yaml is in a 'config' subdirectory within your package's share directory.
23+
param_file_path = os.path.join(
24+
get_package_share_directory(package_name),
25+
'config',
26+
'params.yaml' # <-- REPLACE if your parameter file has a different name
27+
)
28+
29+
# Check if the params.yaml file actually exists
30+
node_parameters = []
31+
if os.path.exists(param_file_path):
32+
node_parameters.append(param_file_path)
33+
print(f"INFO: Using parameter file for {node_name}: {param_file_path}")
34+
else:
35+
print(f"WARNING: No params.yaml found for {node_name} at {param_file_path}. Launching without parameters.")
36+
37+
38+
# Define the Node action
39+
node = Node(
40+
package=package_name,
41+
executable=executable_name,
42+
name=node_name,
43+
parameters=node_parameters,
44+
output='screen', # Optional: 'screen' or 'log'. 'screen' prints output to the console.
45+
emulate_tty=True, # Optional: Set to True for colored output in the console.
46+
)
47+
48+
return [node]
49+
50+
51+
def generate_launch_description():
52+
"""
53+
Generate the launch description for a generic ROS 2 package.
54+
55+
This template is designed to be placed in any ROS 2 package's
56+
launch directory. It expects the package to have a main executable
57+
and optionally a 'config/params.yaml' file.
58+
"""
59+
return LaunchDescription([
60+
# Declare the package name argument.
61+
# This argument specifies WHICH ROS 2 package this launch file should target.
62+
# When running, you will set this:
63+
# e.g., ros2 launch <path_to_this_launch_file> generic_package.launch.py package_name:=your_actual_package_name
64+
DeclareLaunchArgument(
65+
'package_name',
66+
description='Name of the ROS 2 package to launch.'
67+
),
68+
# Declare the executable name argument.
69+
# This argument specifies WHICH executable within the 'package_name' should be run.
70+
# When running, you will set this:
71+
# e.g., ros2 launch ... executable_name:=your_node_executable_name
72+
DeclareLaunchArgument(
73+
'executable_name',
74+
description='Name of the executable to run from the package.'
75+
),
76+
# Declare the node name argument (optional, defaults to executable_name)
77+
# This argument sets the ROS 2 node name. If not provided, it defaults to the executable name.
78+
# e.g., ros2 launch ... node_name:=my_custom_node_name
79+
DeclareLaunchArgument(
80+
'node_name',
81+
default_value=LaunchConfiguration('executable_name'), # Defaults to the executable name
82+
description='Name to assign to the ROS 2 node.'
83+
),
84+
# OpaqueFunction defers the creation of the Node action until launch arguments are resolved.
85+
# This is necessary because we need the actual string values of package_name, executable_name, etc.
86+
OpaqueFunction(function=launch_setup)
87+
])
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "foo_core.hpp"
2+
3+
FooCore::FooCore() {
4+
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef FOO_CORE_HPP_
2+
#define FOO_CORE_HPP_
3+
4+
#include "rclcpp/rclcpp.hpp"
5+
6+
class FooCore {
7+
public:
8+
/*
9+
* Foo core constructor.
10+
*/
11+
FooCore();
12+
13+
private:
14+
15+
};
16+
17+
#endif

0 commit comments

Comments
 (0)