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

Add basic numpy conversions #18

Merged
merged 5 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Byte-compiled / optimized / DLL files
**/__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Linter cache
*.ruff_cache

# Colcon custom files
COLCON_IGNORE
AMENT_IGNORE

# VS Code
.vscode
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,28 @@ if(BUILD_TESTING)
ament_add_gtest(test_eigen_conversions tests/test_eigen_conversions.cpp
tests/gtest_main.cpp)
target_link_libraries(test_eigen_conversions ${PROJECT_NAME}_conversion)

find_package(ament_cmake_pytest REQUIRED)
set(_pytest_tests
tests/test_numpy_conversions.py
)
foreach(_test_path ${_pytest_tests})
get_filename_component(_test_name ${_test_path} NAME_WE)
ament_add_pytest_test(${_test_name} ${_test_path}
APPEND_ENV PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}
TIMEOUT 60
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endforeach()
endif()

#
# Install
#

# Install Python modules
ament_python_install_package(${PROJECT_NAME}_py)

install(
TARGETS ${PROJECT_NAME}_conversion
EXPORT export_${PROJECT_NAME}
Expand Down
Empty file.
54 changes: 54 additions & 0 deletions linear_feedback_controller_msgs_py/lfc_py_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from typing import Annotated, List, Literal
from dataclasses import dataclass
import numpy as np
import numpy.typing as npt

np_array6 = Annotated[npt.NDArray[np.float64], Literal[6]]
np_array7 = Annotated[npt.NDArray[np.float64], Literal[7]]


@dataclass
class JointState:
"""Structure containing JointState information similarly to ROS message
sensor_msgs.msg.JointState.
"""

name: List[str]
position: npt.NDArray[np.float64]
velocity: npt.NDArray[np.float64]
effort: npt.NDArray[np.float64]


@dataclass
class Contact:
"""Structure containing Contact information similarly to ROS message
linear_feedback_controller_msgs.msg.Contact.
"""

active: bool
name: str
wrench: np_array6
pose: np_array7


@dataclass
class Sensor:
"""Structure containing Sensor information similarly to ROS message
linear_feedback_controller_msgs.msg.Sensor.
"""

base_pose: np_array7
base_twist: np_array6
joint_state: JointState
contacts: List[Contact]


@dataclass
class Control:
"""Structure containing Control information similarly to ROS message
linear_feedback_controller_msgs.msg.Control.
"""

feedback_gain: npt.NDArray[np.float64]
feedforward: npt.NDArray[np.float64]
initial_state: Sensor
Loading