Skip to content

Commit

Permalink
Remove direct dependency to tinyxml
Browse files Browse the repository at this point in the history
  • Loading branch information
dmronga committed Dec 3, 2024
1 parent c72bfa4 commit a6b18be
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/build_and_test_ubuntu24.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Ubuntu 24.04

on:
push:
branches: [ master, ubuntu24.04 ]
branches: [ master]
pull_request:
branches: [ master, ubuntu24.04 ]
branches: [ master]

jobs:
build_and_test_24_04:
Expand All @@ -13,8 +13,6 @@ jobs:
steps:
# Check out repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v2
with:
ref: ubuntu24.04
# Build and install
- name: install
run: sh scripts/full_install.sh
Expand Down
2 changes: 1 addition & 1 deletion patches/rbdl.patch
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
+Name: @PACKAGE_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @PACKAGE_VERSION@
+requires: @PKGCONFIG_REQUIRES@ tinyxml urdfdom urdfdom_headers
+requires: @PKGCONFIG_REQUIRES@ urdfdom urdfdom_headers
+Libs: -L${libdir} @PKGCONFIG_LIBS@ -lrbdl_urdfreader
+Cflags: -I${includedir} @PKGCONFIG_CFLAGS@

8 changes: 2 additions & 6 deletions src/robot_models/rbdl/RobotModelRBDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ void RobotModelRBDL::clear(){
rbdl_model = std::make_shared<Model>();
}

void RobotModelRBDL::updateFloatingBase(const base::samples::RigidBodyStateSE3& floating_base_state_in){

}

bool RobotModelRBDL::configure(const RobotModelConfig& cfg){

clear();
Expand All @@ -49,9 +45,9 @@ bool RobotModelRBDL::configure(const RobotModelConfig& cfg){
if(l.second->inertial)
l.second->inertial->origin.rotation.setFromRPY(0,0,0);
}
TiXmlDocument *doc = urdf::exportURDF(robot_urdf);
auto *doc = urdf::exportURDF(robot_urdf);
std::string robot_urdf_file = "/tmp/robot.urdf";
doc->SaveFile(robot_urdf_file);
doc->SaveFile(robot_urdf_file.c_str());

if(!Addons::URDFReadFromFile(robot_urdf_file.c_str(), rbdl_model.get(), cfg.floating_base)){
LOG_ERROR_S << "Unable to parse urdf from file " << robot_urdf_file << std::endl;
Expand Down
1 change: 0 additions & 1 deletion src/robot_models/rbdl/RobotModelRBDL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class RobotModelRBDL : public RobotModel{
RigidBodyDynamics::Math::MatrixNd J, H_q;

std::vector<std::string> jointNamesInRBDLOrder(const std::string &urdf_file);
void updateFloatingBase(const base::samples::RigidBodyStateSE3& floating_base_state_in);
void clear();

public:
Expand Down
3 changes: 0 additions & 3 deletions src/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ file(GLOB SOURCES RELATIVE ${PROJECT_SOURCE_DIR}/src/types "*.cpp")
pkg_search_module(base-types REQUIRED IMPORTED_TARGET base-types)
pkg_search_module(base-logging REQUIRED IMPORTED_TARGET base-logging)
pkg_search_module(urdfdom REQUIRED IMPORTED_TARGET urdfdom)
pkg_search_module(tinyxml REQUIRED IMPORTED_TARGET tinyxml)
pkg_search_module(eigen3 REQUIRED IMPORTED_TARGET eigen3)

list(APPEND PKGCONFIG_REQUIRES base-types)
list(APPEND PKGCONFIG_REQUIRES base-logging)
list(APPEND PKGCONFIG_REQUIRES urdfdom)
list(APPEND PKGCONFIG_REQUIRES tinyxml)
list(APPEND PKGCONFIG_REQUIRES eigen3)
string (REPLACE ";" " " PKGCONFIG_REQUIRES "${PKGCONFIG_REQUIRES}")

Expand All @@ -26,7 +24,6 @@ target_link_libraries(${TARGET_NAME} PUBLIC
PkgConfig::base-types
PkgConfig::base-logging
PkgConfig::urdfdom
PkgConfig::tinyxml
PkgConfig::eigen3)

set_target_properties(${TARGET_NAME} PROPERTIES
Expand Down
15 changes: 11 additions & 4 deletions src/tools/URDFTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <base-logging/Logging.hpp>
#include <urdf_model/link.h>
#include <stack>
#include <fstream>

namespace wbc {

Expand Down Expand Up @@ -123,10 +124,16 @@ std::vector<std::string> URDFTools::addFloatingBaseToURDF(urdf::ModelInterfaceSh

std::vector<std::string> floating_base_names = {"floating_base_trans_x", "floating_base_trans_y", "floating_base_trans_z",
"floating_base_rot_x", "floating_base_rot_y", "floating_base_rot_z"};
TiXmlDocument *doc = urdf::exportURDF(robot_urdf);
TiXmlPrinter printer;
doc->Accept(&printer);
std::string robot_xml_string = printer.CStr();
auto *doc = urdf::exportURDF(robot_urdf);
std::string filename = "/tmp/robot_urdf";
doc->SaveFile(filename.c_str());
std::ifstream file;
file.open(filename);
if(!file){
std::cout << "Could not open " << filename << std::endl;
exit(0);
}
std::string robot_xml_string( (std::istreambuf_iterator<char>(file) ),(std::istreambuf_iterator<char>()) );
robot_xml_string.erase(robot_xml_string.find("</robot>"), std::string("</robot>").length());
std::string floating_base = std::string(" <link name='" + world_frame_id + "'>\n") +
" <inertial>" +
Expand Down

0 comments on commit a6b18be

Please sign in to comment.