jrl-umi3218 / mc_rtc

mc_rtc is an interface for simulated and real robotic systems suitable for real-time control
BSD 2-Clause "Simplified" License
122 stars 37 forks source link

Define new frames in the controller yaml file #341

Closed mmurooka closed 1 year ago

mmurooka commented 1 year ago

I'd like to use the frame with offset added to the LeftGripper (defined in the file jvrc_description/rsdf) of the JVRC1 robot for TransformTask. Adding the following to the controller's configuration yaml file and running mc_rtc_ticker will result in a "Segmentation fault". Is the way configuration is specified incorrect? Or is it a bug?

robots:
  jvrc1:
    frames:
      - name: LeftGripperCenter
        parent: LeftGripper
        X_p_f:
          translation: [0.0, 0.0, -0.1]
mmurooka commented 1 year ago

The backtrace is as follows. After adding the init_pos entry, the segmentation fault is resolved.

(gdb) bt
#0  __memcmp_avx2_movbe () at ../sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S:248
#1  0x00007f4ddfb50514 in rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::CrtAllocator>::StringEqual<rapidjson::CrtAllocator>(rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::CrtAllocator> const&) const (rhs=..., this=0x7ffcb4eb17a0)
    at /home/mmurooka/workspace/src/mc_rtc/3rd-party/RapidJSON/rapidjson/document.h:1876
#2  rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::CrtAllocator>::FindMember<rapidjson::CrtAllocator>(rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::CrtAllocator> const&) (name=..., this=<optimized out>) at /home/mmurooka/workspace/src/mc_rtc/3rd-party/RapidJSON/rapidjson/document.h:1158
#3  rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::CrtAllocator>::FindMember<rapidjson::CrtAllocator>(rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::CrtAllocator> const&) const (name=..., this=<optimized out>) at /home/mmurooka/workspace/src/mc_rtc/3rd-party/RapidJSON/rapidjson/document.h:1162
#4  rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::CrtAllocator>::FindMember(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const (name=<error reading variable: Cannot access memory at address 0x1d>, this=<optimized out>)
    at /home/mmurooka/workspace/src/mc_rtc/3rd-party/RapidJSON/rapidjson/document.h:1173
#5  rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::CrtAllocator>::HasMember(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const (name=<error reading variable: Cannot access memory at address 0x1d>, this=<optimized out>)
    at /home/mmurooka/workspace/src/mc_rtc/3rd-party/RapidJSON/rapidjson/document.h:1105
#6  mc_rtc::Configuration::has(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const
    (this=this@entry=0x55d1163783c0, key="init_pos") at /home/mmurooka/workspace/src/mc_rtc/src/mc_rtc/Configuration.cpp:205
#7  0x00007f4ddfeac436 in mc_control::MCController::<lambda(const string&, const mc_rtc::Configuration&)>::operator()(const std::string &, const mc_rtc::Configuration &) (robotName="ground", config=..., __closure=<optimized out>) at /usr/include/c++/9/bits/basic_string.h:267
#8  0x00007f4ddfebfa3e in mc_control::MCController::MCController(std::vector<std::shared_ptr<mc_rbdyn::RobotModule>, std::allocator<std::shared_ptr<mc_rbdyn::RobotModule> > > const&, double, mc_rtc::Configuration const&, mc_control::ControllerParameters)
    (this=0x55d115db97d0, robots_modules=..., dt=<optimized out>, config=..., params=...) at /home/mmurooka/workspace/src/mc_rtc/src/mc_control/MCController.cpp:292
#9  0x00007f4dcbe9ff0d in mc_control::fsm::Controller::Controller(std::shared_ptr<mc_rbdyn::RobotModule>, double, mc_rtc::Configuration const&, mc_control::ControllerParameters) (this=0x55d115db97d0, rm=..., dt=0.0050000000000000001, config=..., params=...) at /usr/include/c++/9/bits/stl_uninitialized.h:82
#10 0x00007f4dcbdf084d in MCC::MultiContactController::MultiContactController(std::shared_ptr<mc_rbdyn::RobotModule>, double, mc_rtc::Configuration const&)
    (this=0x55d115db97d0, rm=std::shared_ptr<mc_rbdyn::RobotModule> (use count 7, weak count 0) = {...}, dt=0.0050000000000000001, _config=...)
    at /usr/include/c++/9/ext/atomicity.h:96
#11 0x00007f4dd801e800 in create(std::string const&, mc_rbdyn::RobotModulePtr const&, double const&, mc_control::Configuration const&)
    (robot=..., dt=@0x7ffcb4eb2228: 0.0050000000000000001, conf=...) at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:170
#12 0x00007f4ddfef1ae2 in mc_rtc::ObjectLoader<mc_control::MCController>::create_from_handles<std::shared_ptr<mc_rbdyn::RobotModule>, double, mc_rtc::Configuration>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<mc_rbdyn::RobotModule>, double, mc_rtc::Configuration)
    (this=this@entry=0x55d115d8c8d0, name="MultiContactController") at /usr/include/c++/9/string_view:129
#13 0x00007f4ddfef2885 in mc_rtc::ObjectLoader<mc_control::MCController>::create<std::shared_ptr<mc_rbdyn::RobotModule>, double, mc_rtc::Configuration>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<mc_rbdyn::RobotModule>, double, mc_rtc::Configuration)
    (this=this@entry=0x55d115d8c8d0, name="MultiContactController") at /home/mmurooka/workspace/src/mc_rtc/include/mc_rtc/Configuration.h:116
#14 0x00007f4ddfee5c85 in mc_rtc::ObjectLoader<mc_control::MCController>::create_object<std::shared_ptr<mc_rbdyn::RobotModule>, double, mc_rtc::Configuration>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<mc_rbdyn::RobotModule>, double, mc_rtc::Configuration)
    (name="MultiContactController", this=0x55d115d8c8d0) at /usr/include/c++/9/bits/shared_ptr_base.h:756
#15 mc_control::MCGlobalController::AddController(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
    (this=0x7ffcb4eb2d60, name="MultiContactController") at /home/mmurooka/workspace/src/mc_rtc/src/mc_control/mc_global_controller.cpp:990
#16 0x00007f4ddfee6f56 in mc_control::MCGlobalController::MCGlobalController(mc_control::MCGlobalController::GlobalConfiguration const&)
    (this=0x7ffcb4eb2d60, conf=...) at /home/mmurooka/workspace/src/mc_rtc/src/mc_control/mc_global_controller.cpp:86
#17 0x00007f4ddfee7613 in mc_control::MCGlobalController::MCGlobalController(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std--Type <RET> for more, q to quit, c to continue without paging--
::shared_ptr<mc_rbdyn::RobotModule>) (this=0x7ffcb4eb2d60, conf=..., rm=...) at /usr/include/c++/9/ext/atomicity.h:96
#18 0x000055d114faee2c in main() () at /usr/include/c++/9/bits/shared_ptr_base.h:616
mmurooka commented 1 year ago

However, I got the following error: Can't I use the surface defined in the rsdf file as a parent frame?

[error] 1 frames could not be loaded from their description (parent missing or cycles)
[warning] - LeftGripperCenter (parent: LeftGripper)
mmurooka commented 1 year ago

After making the changes described in https://github.com/jrl-umi3218/mc_rtc/issues/342#issue-1575235233, all of the above problems have been resolved. Even without the init_pos entry, there is no segmentation fault, and the new frame with the surface defined in rsdf as parent is correctly added. However, I still do not understand how the above changes could have such an effect.

Keep track of this problem at https://github.com/jrl-umi3218/mc_rtc/issues/342 and close this Issue.