Skip to content

Commit

Permalink
Updating c++ code with dynamixel motor support
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanDuPont committed Jul 10, 2024
1 parent 05d5343 commit 24733e8
Show file tree
Hide file tree
Showing 21 changed files with 1,100 additions and 174 deletions.
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ bazel_dep(name = "aspect_rules_js", version = "1.41.2")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "eigen", version = "3.4.0")
bazel_dep(name = "gazelle", version = "0.35.0")
bazel_dep(name = "googletest", version = "1.14.0")
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
module_name = "hedron_compile_commands",
Expand Down
7 changes: 5 additions & 2 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/math/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cc_library(
name = "math_lib",
hdrs = [
"pid.h",
],
visibility = ["//visibility:public"],
)

cc_library(
name = "vector_lib",
hdrs = [
"vector_math.h",
],
visibility = ["//visibility:public"],
deps = [
"@eigen",
],
)
5 changes: 5 additions & 0 deletions src/math/pid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
struct PIDGain {
float kP;
float kI;
float kD;
};
6 changes: 6 additions & 0 deletions src/math/vector_math.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <Eigen/Eigen>

struct Location {
Eigen::Vector2d position;
Eigen::Rotation2Df rotation;
};
25 changes: 24 additions & 1 deletion src/robot/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,36 @@ py_library(
],
)

cc_library(
name = "robot_lib",
srcs = [
"robot.cpp",
],
hdrs = [
"motor.h",
"robot.h",
],
deps = ["@eigen"],
)

cc_binary(
name = "robot",
srcs = [
"robot.cpp",
"robot.h",
],
deps = [
"robot_lib",
"@eigen",
],
)

cc_binary(
name = "main",
srcs = [
"main.cpp",
],
deps = [
"robot_lib",
"@eigen",
],
)
67 changes: 67 additions & 0 deletions src/robot/actuator/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
cc_library(
name = "generic_motor_lib",
hdrs = [
"motor.h",
],
deps = [
"//src/math:math_lib",
"//src/math:vector_lib",
"@eigen",
],
)

cc_library(
name = "dynamixel_motor_lib",
srcs = [
"dynamixel_motor.cpp",
],
hdrs = [
"dynamixel_motor.h",
],
deps = [
":generic_motor_lib",
"//src/math:math_lib",
"@eigen",
],
)

cc_test(
name = "dynamixel_motor_test",
size = "small",
srcs = [
"dynamixel_motor_test.cpp",
],
deps = [
":dynamixel_motor_lib",
"@eigen",
"@googletest//:gtest_main",
],
)

cc_library(
name = "mock_motor_lib",
srcs = [
"mock_motor.cpp",
],
hdrs = [
"mock_motor.h",
],
deps = [
":generic_motor_lib",
"//src/math:math_lib",
"@eigen",
],
)

cc_test(
name = "mock_motor_test",
size = "small",
srcs = [
"mock_motor_test.cpp",
],
deps = [
":mock_motor_lib",
"@eigen",
"@googletest//:gtest_main",
],
)
Loading

0 comments on commit 24733e8

Please sign in to comment.