Skip to content

Commit 05cc32e

Browse files
committed
started trying to fix installation of the jni by changing the cmake to a less complex structure
1 parent 5ad8e14 commit 05cc32e

File tree

7 files changed

+72
-21
lines changed

7 files changed

+72
-21
lines changed

external-control/CMakeLists.txt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ set(CMAKE_CXX_STANDARD 17)
33

44
project(external-control CXX)
55

6-
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
7-
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
6+
#set(INSTALL_LIB_DIR "lib" CACHE PATH "Installation directory for libraries")
7+
#set(INSTALL_INC_DIR "include" CACHE PATH "Installation directory for headers")
88

9-
find_package(Catch2 2 REQUIRED)
109
find_package(Eigen3 REQUIRED)
1110
include_directories(${EIGEN3_INCLUDE_DIR})
1211

@@ -26,11 +25,8 @@ target_link_libraries(external-wrapper PUBLIC
2625
Eigen3::Eigen)
2726

2827
install(TARGETS external-wrapper
29-
EXPORT targets
30-
LIBRARY DESTINATION lib
31-
ARCHIVE DESTINATION lib
32-
RUNTIME DESTINATION bin)
33-
install(DIRECTORY
34-
src/main/cpp/
35-
DESTINATION "${INSTALL_INC_DIR}"
36-
FILES_MATCHING PATTERN "*.hpp")
28+
RUNTIME DESTINATION bin
29+
LIBRARY DESTINATION lib
30+
ARCHIVE DESTINATION lib
31+
INCLUDES DESTINATION include)
32+
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include FILES_MATCHING PATTERN "*.hpp")

external-control/src/main/cpp/controllers/constant-position-controller.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ namespace ihmc
77
ConstantPositionController::ConstantPositionController(const double default_stiffness, const double default_damping, const int number_of_joints)
88
{
99
number_of_joints_ = number_of_joints;
10-
desired_joint_velocities_ = Eigen::VectorXd(number_of_joints_);
11-
desired_joint_torques_ = Eigen::VectorXd(number_of_joints_);
12-
desired_joint_stiffnesses_ = Eigen::VectorXd(number_of_joints_);
13-
desired_joint_damping_ = Eigen::VectorXd(number_of_joints_);
10+
desired_joint_velocities_.resize(number_of_joints_);
11+
desired_joint_torques_.resize(number_of_joints_);
12+
desired_joint_stiffnesses_.resize(number_of_joints_);
13+
desired_joint_damping_.resize(number_of_joints_);
1414

1515
desired_joint_velocities_.setZero();
1616
desired_joint_torques_.setZero();

external-control/src/main/cpp/external-control.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ namespace ihmc
88
ExternalControlImpl::ExternalControlImpl(const double default_stiffness, const double default_damping, const int number_of_joints)
99
{
1010
constant_position_controller_ = ConstantPositionController(default_stiffness, default_damping, number_of_joints);
11-
desired_state_data_ = Eigen::VectorXd(13 + 2 * number_of_joints);
12-
desired_control_data_ = Eigen::VectorXd(number_of_joints);
13-
p_gains_ = Eigen::VectorXd(number_of_joints);
14-
d_gains_ = Eigen::VectorXd(number_of_joints);
11+
desired_state_data_.resize(13 + 2 * number_of_joints);
12+
desired_control_data_.resize(number_of_joints);
13+
p_gains_.resize(number_of_joints);
14+
d_gains_.resize(number_of_joints);
1515
number_of_joints_ = number_of_joints;
1616
}
1717

external-control/src/main/java/us/ihmc/externalControl/ExternalControllerState.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public ExternalControllerState(String namePrefix,
5353

5454
blendRatioCurrentValue = new YoDouble(namePrefix + "BlendRatioCurrentValue", registry);
5555

56+
ExternalWrapperNativeLibrary.load();
57+
5658
externalControl = new ExternalControl(controllerToolbox.getFullRobotModel().getRootBody(), controlledJoints, 100.0, 25.0);
5759

5860
lowLevelOneDoFJointDesiredDataHolder.registerJointsWithEmptyData(controlledJoints);
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package us.ihmc.externalControl;
2+
3+
import us.ihmc.log.LogTools;
4+
import us.ihmc.tools.nativelibraries.NativeLibraryDescription;
5+
import us.ihmc.tools.nativelibraries.NativeLibraryLoader;
6+
import us.ihmc.tools.nativelibraries.NativeLibraryWithDependencies;
7+
8+
public class ExternalWrapperNativeLibrary implements NativeLibraryDescription
9+
{
10+
@Override
11+
public String getPackage(OperatingSystem operatingSystem, Architecture architecture)
12+
{
13+
String architecturePackage = "";
14+
if (architecture == Architecture.x64)
15+
{
16+
architecturePackage = switch (operatingSystem)
17+
{
18+
case LINUX64 -> "linux-x86_64";
19+
default -> "unknown";
20+
};
21+
}
22+
23+
return "externalWrapper." + architecturePackage;
24+
}
25+
26+
@Override
27+
public NativeLibraryWithDependencies getLibraryWithDependencies(OperatingSystem operatingSystem, Architecture architecture)
28+
{
29+
switch (operatingSystem)
30+
{
31+
case LINUX64:
32+
return NativeLibraryWithDependencies.fromFilename("jniExternalWrapper.so",
33+
"libexternal-wrapper.so");
34+
default:
35+
break;
36+
}
37+
38+
LogTools.warn("Unsupported platform: " + operatingSystem.name() + "-" + architecture.name());
39+
return null;
40+
}
41+
42+
private static boolean loaded = false;
43+
44+
public static boolean load()
45+
{
46+
if (!loaded)
47+
{
48+
ExternalWrapperNativeLibrary nativeLibrary = new ExternalWrapperNativeLibrary();
49+
loaded = NativeLibraryLoader.loadLibrary(nativeLibrary);
50+
}
51+
return loaded;
52+
}
53+
}

external-control/src/main/java/us/ihmc/externalControl/presets/ExternalControlInfoMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
include = {"external-control.hpp"},
1414
linkpath = "../lib",
1515
link = "external-wrapper",
16-
preload = {"external-wrapper", "jniExternalWrapper"}
16+
preload = {"external-wrapper", "jniExternalControlWrapper"}
1717
),
1818
target = "us.ihmc.externalControl.ExternalControlWrapper"
1919
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:bb201f02da858f8f08c4a417f0270b5e781bb8c9f5bd1806bda3e91565e96528
2+
oid sha256:c9207884c09a6dc6fbbe436d975afea627862dff67f98e57c622a57322d1ad91
33
size 61088

0 commit comments

Comments
 (0)