Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
markaren committed Jun 24, 2024
1 parent 2b619f8 commit 26a2dd8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
15 changes: 12 additions & 3 deletions examples/loaders/urdf_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

using namespace threepp;

int main() {
int main(int argc, char** argv) {

if (argc != 2) return 1;

std::string urdfPath = argv[1];

Canvas canvas{"URDF loader", {{"aa", 4}}};
GLRenderer renderer(canvas.size());
Expand All @@ -26,7 +30,7 @@ int main() {

URDFLoader loader;
AssimpLoader assimpLoader;
auto model = loader.load(assimpLoader, "C:\\Users\\Lars Ivar Hatledal\\OneDrive - NTNU\\Teaching\\AIS1003\\2023\\Mappe\\Sensur\\10031\\testfiler\\abb-kinetic-devel\\abb_irb2400_support\\urdf\\irb2400.urdf");
auto model = loader.load(assimpLoader, urdfPath);
scene->add(model);

Box3 bb;
Expand All @@ -47,7 +51,12 @@ int main() {
canvas.animate([&]() {
const auto dt = clock.getDelta();

model->getObjectByName("joint_1")->rotation.y += dt * 1;
model->getObjectByName("joint_1")->rotation.y += dt * 0.1;
model->getObjectByName("joint_2")->rotation.z += dt * 0.1;
model->getObjectByName("joint_3")->rotation.z += dt * 0.1;
model->getObjectByName("joint_4")->rotation.x += dt * 0.1;
// model->getObjectByName("joint_5")->rotation.y += dt * 0.1;
// model->getObjectByName("joint_6")->rotation.y += dt * 0.1;

model->updateMatrixWorld();

Expand Down
20 changes: 4 additions & 16 deletions src/threepp/loaders/URDFLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ struct URDFLoader::Impl {
auto linkObject = std::make_shared<Object3D>();
linkObject->name = link.attribute("name").value();

if (linkObject->name == "base_link") {
object->add(linkObject);
}
// if (linkObject->name == "base_link") {
// object->add(linkObject);
// }

for (auto visual : link.children("visual")) {

Expand Down Expand Up @@ -143,21 +143,9 @@ struct URDFLoader::Impl {

for (const auto& l : links) {

// if (!l->parent) object->add(l);
if (!l->parent) object->add(l);
}

// auto o = object->getObjectByName("joint_1");
// o->rotation.z = -std::numbers::phi / 2;

// object->traverse([&](auto& o) {
// if (o.name.find("joint_") != std::string::npos) {
// std::cout << o.name << std::endl;
// // std::cout << o.parent->name << std::endl;
// std::cout << std::endl;
// o.rotation.y = std::numbers::phi/6;
// }
// });

return object;
}
};
Expand Down

0 comments on commit 26a2dd8

Please sign in to comment.