Skip to content

Commit a5a8de4

Browse files
Noëlie Ramuzatolivier-stasse
Noëlie Ramuzat
authored andcommitted
[tools] Moved common-py.cpp to robot-utils-py.cpp
Added robot-utils-py.cpp in sot-core from common-py.cpp of sot-torque-control Complete the moving of "common" to "robot_utils" by moving the python wrapper Changing the CMakeLists accordingly.
1 parent fbe6ba4 commit a5a8de4

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ IF(BUILD_PYTHON_INTERFACE)
5353
STRING(REGEX REPLACE "-" "_" PY_NAME ${PROJECT_NAME})
5454
SET(${PY_NAME}_INSTALL_DIR ${PYTHON_SITELIB}/${PY_NAME})
5555
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
56+
SET(PYTHON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}/dynamic_graph/sot/core)
5657
ADD_REQUIRED_DEPENDENCY("dynamic-graph-python >= 3.0.0")
58+
5759
ENDIF(BUILD_PYTHON_INTERFACE)
5860
ADD_COMPILE_DEPENDENCY ("pinocchio >= 2.0.0")
5961

@@ -64,4 +66,16 @@ ADD_SUBDIRECTORY(src)
6466
ADD_SUBDIRECTORY(unitTesting)
6567
ADD_SUBDIRECTORY(doc)
6668

69+
# **********************************
70+
# Robot_utils_sot_py PYTHON module *
71+
# **********************************
72+
IF(BUILD_PYTHON_INTERFACE)
73+
PYTHON_ADD_MODULE(robot_utils_sot_py src/tools/robot-utils-py.cpp)
74+
PKG_CONFIG_USE_DEPENDENCY(robot_utils_sot_py dynamic-graph)
75+
TARGET_LINK_LIBRARIES(robot_utils_sot_py ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${LIBRARY_NAME})
76+
TARGET_LINK_BOOST_PYTHON(robot_utils_sot_py)
77+
INSTALL(TARGETS robot_utils_sot_py DESTINATION ${PYTHON_INSTALL_DIR})
78+
79+
ENDIF(BUILD_PYTHON_INTERFACE)
80+
6781
SETUP_PROJECT_FINALIZE()

src/tools/robot-utils-py.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright 2017, A. Del Prete, T. Flayols, O. Stasse, LAAS-CNRS
3+
*
4+
* This file is part of sot-core.
5+
* See license file.
6+
*/
7+
8+
#include <sot/core/robot-utils.hh>
9+
#include <boost/python.hpp>
10+
#include <boost/python/suite/indexing/map_indexing_suite.hpp>
11+
using namespace boost::python;
12+
using namespace dynamicgraph::sot;
13+
14+
15+
BOOST_PYTHON_MODULE(robot_utils_sot_py)
16+
{
17+
class_<JointLimits>
18+
("JointLimits",init<double,double>())
19+
.def_readwrite("upper",&JointLimits::upper)
20+
.def_readwrite("lower",&JointLimits::lower)
21+
;
22+
23+
class_<ForceLimits>("ForceLimits",init<const Eigen::VectorXd &,const Eigen::VectorXd &>())
24+
.def("display",&ForceLimits::display)
25+
.def_readwrite("upper",&ForceLimits::upper)
26+
.def_readwrite("lower",&ForceLimits::lower)
27+
;
28+
29+
class_<ForceUtil>("ForceUtil")
30+
.def("set_name_to_force_id", &ForceUtil::set_name_to_force_id)
31+
.def("set_force_id_to_limits", &ForceUtil::set_force_id_to_limits)
32+
.def("create_force_id_to_name_map",&ForceUtil::create_force_id_to_name_map)
33+
.def("get_id_from_name", &ForceUtil::get_id_from_name)
34+
.def("get_name_from_id", &ForceUtil::cp_get_name_from_id)
35+
.def("get_limits_from_id", &ForceUtil::cp_get_limits_from_id)
36+
.def("get_force_id_left_hand", &ForceUtil::get_force_id_left_hand)
37+
.def("set_force_id_left_hand", &ForceUtil::set_force_id_left_hand)
38+
.def("get_force_id_right_hand", &ForceUtil::get_force_id_right_hand)
39+
.def("set_force_id_right_hand", &ForceUtil::set_force_id_right_hand)
40+
.def("get_force_id_left_foot", &ForceUtil::get_force_id_left_foot)
41+
.def("set_force_id_left_foot", &ForceUtil::set_force_id_left_foot)
42+
.def("get_force_id_right_foot", &ForceUtil::get_force_id_right_foot)
43+
.def("set_force_id_right_foot", &ForceUtil::set_force_id_right_foot)
44+
.def("display", &ForceUtil::display)
45+
;
46+
47+
class_<RobotUtil>("RobotUtil")
48+
.def_readwrite("m_force_util",&RobotUtil::m_force_util)
49+
.def_readwrite("m_foot_util",&RobotUtil::m_foot_util)
50+
.def_readwrite("m_urdf_to_sot",&RobotUtil::m_urdf_to_sot)
51+
.def_readonly("m_nbJoints",&RobotUtil::m_nbJoints)
52+
.def_readwrite("m_name_to_id",&RobotUtil::m_name_to_id)
53+
.def_readwrite("m_id_to_name",&RobotUtil::m_id_to_name)
54+
.def("set_joint_limits_for_id",&RobotUtil::set_joint_limits_for_id)
55+
.def("get_joint_limits_from_id",&RobotUtil::cp_get_joint_limits_from_id)
56+
//.def("set_joint_limits_for_id",&RobotUtil::set_joint_limits_for_id)
57+
//.def("set_name_to_id", &RobotUtil::set_name_to_id)
58+
//.def("create_id_to_name_map",&RobotUtil::create_id_to_name_map)
59+
//.def("get_id_from_name",&RobotUtil::get_id_from_name)
60+
;
61+
62+
63+
class_<std::map<Index,ForceLimits> >("IndexForceLimits")
64+
.def(map_indexing_suite<std::map<Index,ForceLimits> > ());
65+
66+
class_<std::map<std::string,Index> >("stringIndex")
67+
.def(map_indexing_suite<std::map<std::string,Index> > ());
68+
69+
class_<std::map<Index,std::string> >("Indexstring")
70+
.def(map_indexing_suite<std::map<Index,std::string> > ());
71+
72+
}

0 commit comments

Comments
 (0)