RobotLocomotion / drake

Model-based design and verification for robotics.
https://drake.mit.edu
Other
3.35k stars 1.27k forks source link

Error in Building a floating base model #15897

Closed dhruvthanki closed 3 years ago

dhruvthanki commented 3 years ago
#include "drake/geometry/scene_graph.h"
#include "drake/multibody/parsing/parser.h"
#include "drake/common/find_resource.h"

int main(void) {
// Building a floating-base plant
    drake::multibody::MultibodyPlant<double> plant_{0.0};
    drake::geometry::SceneGraph<double> scene_graph;
    std::string full_name = drake::FindResourceOrThrow(
        "model/model.urdf");
    drake::multibody::Parser parser(&plant_, &scene_graph);
    parser.AddModelFromFile(full_name);
    plant_.Finalize();
    return 1;
}

The above code give me the following error:

terminate called after throwing an instance of 'std::runtime_error'
  what():  Drake resource_path 'model/model.urdf' does not start with drake/.
Aborted (core dumped)

My Directory layout is:

my src CmakeLists.txt is:

cmake_minimum_required(VERSION 3.16.3)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
message("CMAKE Directory : " ${PROJECT_SOURCE_DIR})

project(IK VERSION 1.0)

# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

find_package (Eigen3 3.3 REQUIRED NO_MODULE)
find_package(drake CONFIG REQUIRED)

# specify the main source file
set(SOURCE main.cpp)
add_executable(${PROJECT_NAME} ${SOURCE})

target_link_libraries("${PROJECT_NAME}" 
    Eigen3::Eigen
    drake::drake}

Essentially, my objective is to use a custom urdf and build a model and use it for the inverse kinematics class.

SeanCurtis-TRI commented 3 years ago

Could you please post this in stackoverflow with the drake tag? This kind of usage question is ideally addressed there -- then other users can learn from your question. I'd recommend the question topic to be something like:

Error locating urdf file.

(After all, the error is not the fact that you're building a floating model, per se, but that model/model.urdf can't be found.)

Go ahead and move the question and we'll put the answer there.