{"id":19963296,"url":"https://github.com/advrhumanoids/xbot2_interface","last_synced_at":"2025-05-03T22:31:58.141Z","repository":{"id":220965546,"uuid":"741999954","full_name":"ADVRHumanoids/xbot2_interface","owner":"ADVRHumanoids","description":"Next-gen robot and model interfaces for XBot2","archived":false,"fork":false,"pushed_at":"2024-08-01T07:55:42.000Z","size":585,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-08-01T15:59:13.832Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ADVRHumanoids.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-11T14:55:40.000Z","updated_at":"2024-08-01T07:55:45.000Z","dependencies_parsed_at":"2024-04-30T16:48:21.729Z","dependency_job_id":"f6b70700-08ea-4329-95c1-fc256b19ca30","html_url":"https://github.com/ADVRHumanoids/xbot2_interface","commit_stats":null,"previous_names":["advrhumanoids/xbot2_interface"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADVRHumanoids%2Fxbot2_interface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADVRHumanoids%2Fxbot2_interface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADVRHumanoids%2Fxbot2_interface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADVRHumanoids%2Fxbot2_interface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ADVRHumanoids","download_url":"https://codeload.github.com/ADVRHumanoids/xbot2_interface/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224374650,"owners_count":17300691,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T02:15:31.782Z","updated_at":"2024-11-13T02:15:32.441Z","avatar_url":"https://github.com/ADVRHumanoids.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xbot2_interface\n\nThis package replaces the good ole' [XBotInterface](https://github.com/advrhumanoids/xbotinterface) \npackage by HHCM.\nWe try to keep the API as close as possible to the old one. \nThis is not always possible since this package supports non-Euclidean joints, \nand therefore the number of joints is \nin general different than the number of element in the `q` vector, \nwhich is also different than the number of elements in the `v` vector.\n\n\n\n## Quick guide\n\n### Build the library\n\nAfter installing the required dependencies (TBD)\n\n```c++\nmkdir build \u0026\u0026 cd build\ncmake ..\nmake\nmake install\n```\n\n### Use the library in your project\n```cmake\nfind_package(xbot2_interface REQUIRED)\ntarget_link_libraries(mytarget xbot2_interface::xbot2_interface)\n```\n\n### Model object construction\n```c++\nstd::string urdf;  // read urdf file into this string somehow\nauto model = ModelInterface::getModel(urdf, \"pin\");\n```\nMore constructors are available which take the SRDF file, too.\n\n### Vector dimensions\nAs we support non-Euclidean joints, care must be taken when manipulating configurations \nand motion vectors.\n```c++\n\n// the neutral (i.e., zero) configuration \n// note: this is in general different than Eigen::VectorXd::Zero(model-\u003egetNq()) !!\nEigen::VectorXd qn = model-\u003egetNeutralQ();\n\n// its size is model-\u003egetNq()\nassert(qn.size() == model-\u003egetNq());\n\n// a random configuration complying with joint limits\nEigen::VectorXd qrand = model-\u003egenerateRandomQ();\n\n// the velocity vector that brings qn to qrand in unit time\n// note: you cannot compute the vector difference of qn and qrand,\n// since these are NOT vectors in the linear-algebraic sense!\nEigen::VectorXd vrand = model-\u003edifference(qrand, qn);\n\n// its size is model-\u003egetNv()\nassert(vrand.size() == model-\u003egetNv());\n\n// the configuration obtained by applying a velocity vector to \n// a given initial configuration\n// note: this will be the same configuration as qrand\n// note: you can sum two motions, but you cannot sum a motion with\n// a configuration\nEigen::VectorXd q1 = model-\u003esum(qn, vrand);  \n\n// the list of joint names\nauto jnames = model-\u003egetJointNames();\n\n// its length is model-\u003egetJointNum()\nassert(jnames.size() == model-\u003egetJointNum());\n\n// the i-th joint can have nq and/or nv greater than one;\n// its index inside a configuration or motion is therefore != id\nint id = jnames.size()/2;\n\n// this data structure contains indexing information\nauto jinfo = model-\u003egetJointInfo(i);\n\nstd::cout \u003c\u003c  \"id = \" \u003c\u003c jinfo.id \u003c\u003c\n             \" iq = \" \u003c\u003c jinfo.iq \u003c\u003c\n             \" iv = \" \u003c\u003c jinfo.iv \u003c\u003c\n             \" nq = \" \u003c\u003c jinfo.nq \u003c\u003c\n             \" nv = \" \u003c\u003c jinfo.nv \u003c\u003c std::endl;\n             \n// this is how you index a configuration or motion\nauto qj = qrand.segment(jinfo.iq, jinfo.nq);\nauto vj = vrand.segment(jinfo.iv, jinfo.nv);\n\n// you can use the joint interface (same result);\nJoint::Ptr joint = model-\u003egetJoint(i);\nauto qj_1 = joint-\u003egetJointPosition(); // same as qj\nauto vj_1 = joint-\u003egetJointVelocity(); // same as vj\n\n// similar for effort, acceleration, ...\n\n```\n\n\n### Using the model to perform computations\n```c++\n// every time you change the model state, \n// call update() to apply the new configuration\nmodel-\u003esetJointPosition(qrand);\nmodel-\u003esetJointVelocity(vrand);\nmodel-\u003eupdate();\n\n// forward kinematics\nEigen::Affine3d T_1 = model-\u003egetPose(\"my_link\");\nEigen::Affine3d T_12 = model-\u003egetPose(\"my_link\", \"my_base_link\");\nEigen::Vector6d v_1 = model-\u003egetVelocityTwist(\"my_link\");\nEigen::Vector6d v_12 = model-\u003egetRelativeVelocityTwist(\"my_link\", \"my_base_link\");\n\n// similar for acceleration...\n\n// jacobians\nEigen::MatrixXd J;\n\nif(!model-\u003egetJacobian(\"my_link\", J))\n{\n    std::cerr \u003c\u003c \"error: bad link name \\n\";\n}\n```\n\n\n### Examples\nCheck [this small collection](examples) of commented examples\n\n### Porting from XBotInterface v1\nCheck [the cheatsheet](cheatsheet.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadvrhumanoids%2Fxbot2_interface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadvrhumanoids%2Fxbot2_interface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadvrhumanoids%2Fxbot2_interface/lists"}