Comments (4)
UPDATE: the number of joints seems randomic, like the parsing fails to initialize the variables.
Here is a M(N)WE:
robot.urdf:
<?xml version="1.0" ?>
<robot name="robot" xmlns:xacro="http://ros.org/wiki/xacro">
<joint name="floating_base" type="floating">
<parent link="base_link"/>
<child link="trunk"/>
</joint>
<!-- Links -->
<!-- Footprint link -->
<link name="base_link">
</link>
<!-- Trunk link -->
<link name="trunk">
<inertial>
<origin xyz="0.02707 0.0 0.0329"/>
<mass value="71.758"/>
<inertia ixx="1.61053" ixy="-0.0288" ixz="0.34161" iyy="8.53505" iyz="0.0038" izz="9.19102"/>
</inertial>
</link>
</robot>
main.cpp:
#include <iostream>
#include <urdf/model.h>
#include <urdf_parser/urdf_parser.h>
using namespace std;
int main() {
urdf::ModelInterfaceSharedPtr model = urdf::parseURDFFile("robot.urdf");
std::vector<boost::shared_ptr<urdf::Link> > links;
model->getLinks(links);
std::cout << "Number of links: " << links.size() << std::endl;
for (int i = 0; i < links.size(); i++) {
std::cout << "Joint children per link " << i << ": ";
std::cout << links[i]->child_joints.size() << std::endl;
}
return 0;
}
CMakelists.txt:
cmake_minimum_required(VERSION 2.8)
project(urdf-test)
find_package(PkgConfig)
pkg_check_modules(URDF urdf)
add_definitions(${URDF_DEFINITIONS})
include_directories(${URDF_INCLUDE_DIRS})
pkg_check_modules(URDFDOM urdfdom)
include_directories(${URDFDOM_INCLUDE_DIRS})
find_package(Boost REQUIRED COMPONENTS thread chrono system date_time atomic)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES} ${URDFDOM_LIBRARIES})
output:
Number of links: 2
Joint children per link 0: 18446744073708883089
Joint children per link 1: 18446744073708883069
The expected output is: 1 child for link 0 and 0 children for link 1
ldd output:
linux-vdso.so.1 => (0x00007ffc215e0000)
liburdfdom_model.so.0.4 => /usr/lib/x86_64-linux-gnu/liburdfdom_model.so.0.4 (0x00007f48f3277000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f48f2ef4000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f48f2cde000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f48f2914000)
libtinyxml.so.2.6.2 => /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2 (0x00007f48f26fd000)
libconsole_bridge.so.0.2 => /usr/lib/x86_64-linux-gnu/libconsole_bridge.so.0.2 (0x00007f48f24f8000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f48f21ef000)
/lib64/ld-linux-x86-64.so.2 (0x00005609ee689000)
from urdfdom.
Hi @mcamurri, thanks for the ticket.
When you say the library does not give the child joint, do you mean the joint isn't included in child_joints
? In the second example, is the joint in child_joints
on base_link
or trunk
?
from urdfdom.
In the second example I'm iterating over all the links. Link 0 is "base_link" and Link 1 is "trunk".
I expected Link 0 to have 1 child (and not 18446744073708883089 children).
Actually, I solved by reinstalling all the libraries.
With current ldd:
linux-vdso.so.1 => (0x00007ffc24df7000)
liburdfdom_model.so.0.4 => /usr/lib/x86_64-linux-gnu/liburdfdom_model.so.0.4 (0x00007f3fb4bd3000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f3fb4850000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f3fb463a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3fb4270000)
libtinyxml.so.2.6.2 => /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2 (0x00007f3fb4059000)
libconsole_bridge.so.0.2 => /usr/lib/x86_64-linux-gnu/libconsole_bridge.so.0.2 (0x00007f3fb3e54000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3fb3b4b000)
/lib64/ld-linux-x86-64.so.2 (0x000055ffc5149000)
I have the correct output:
Number of links: 2
Joint children per link 0: 1
Joint children per link 1: 0
from urdfdom.
@mcamurri It looks like you solved the problem, so I'm going to close this out. Feel free to reopen if you still are having trouble.
from urdfdom.
Related Issues (20)
- Question: check_urdf does not take into account transmission tag, wrong behaviour ? HOT 1
- Invalid path in urdfdom_INCLUDE_DIRS on Windows installation using vcpkg
- Using wrong headers HOT 2
- Deprecation warning on urdfdom_parser with Clang HOT 2
- check_urdf: no loop detection
- Branch urdfdom for Galactic HOT 5
- Usage of `version` attribute in `robot` xml-node HOT 2
- [cmake] urdf_LIBRARIES is still wrong HOT 2
- Feature request: check_urdf should be able to read from std_in HOT 2
- parseJointLimits() does not parse acceleration limits
- Joint limits (vel, effort) are checked even when the joint is continuous type.
- Build Status link in README.md is broken HOT 2
- Use tinyxml2 instead of tinyxml HOT 3
- Remove tinyxml2 from public API HOT 2
- Cannot parse capsule error HOT 1
- Fixed joints parse limits but not axis
- Add support for quaternion in URDF HOT 3
- Removing console_bridge for Logging HOT 4
- support export URDF HOT 1
- Don't use (outdated) self-provided gtest version (especially if another version is installed already) HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from urdfdom.