{"id":19623141,"url":"https://github.com/robostack/xtensor-ros","last_synced_at":"2025-10-28T19:17:46.276Z","repository":{"id":48624854,"uuid":"111378939","full_name":"RoboStack/xtensor-ros","owner":"RoboStack","description":"ROS (Robot Operating System) bindings for xtensor, the multidimensional linear algebra library","archived":false,"fork":false,"pushed_at":"2021-07-17T05:38:27.000Z","size":18,"stargazers_count":19,"open_issues_count":3,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-22T21:21:43.882Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RoboStack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-20T07:55:26.000Z","updated_at":"2024-02-14T05:48:41.000Z","dependencies_parsed_at":"2022-09-16T00:40:33.153Z","dependency_job_id":null,"html_url":"https://github.com/RoboStack/xtensor-ros","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RoboStack%2Fxtensor-ros","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RoboStack%2Fxtensor-ros/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RoboStack%2Fxtensor-ros/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RoboStack%2Fxtensor-ros/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RoboStack","download_url":"https://codeload.github.com/RoboStack/xtensor-ros/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240919628,"owners_count":19878644,"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-11T11:31:56.159Z","updated_at":"2025-10-28T19:17:41.241Z","avatar_url":"https://github.com/RoboStack.png","language":"CMake","readme":"![xtensor ros](http://quantstack.net/assets/images/xtensor-ros.svg)\n\n## xtensor for ROS, the Robot Operating System\n\nThis repository contains bindings for xtensor to the ROS Robotics Operating System.\nIt offers helper functions to easily send and receive xtensor and xarray datastructures\nas ROS messages. This allows easy embedding of multidimensional arrays in ROS C++\nprograms. We are planning to develop an accompanying Python library which would parse\nthe messages into NumPy datastructures for full interoperability.\n\n### About [xtensor](https://github.com/QuantStack/xtensor)\n\nxtensor is a C++ library meant for numerical calculations with multi-dimensional array expressions.\n\nxtensor provides\n\n- an extensible expression system enabling lazy broadcasting.\n- an API following the idioms of the C++ standard library.\n- tools to manipulate array expressions and build upon xtensor.\n\nMore documentation: https://xtensor.readthedocs.io/en/latest\n\nNumpy to xtensor cheatsheet: https://xtensor.readthedocs.io/en/latest/numpy.html\n\n### Example\n\nA publisher:\n\n```cpp\n#include \"ros/ros.h\"\n#include \u003ciostream\u003e\n#include \u003cxtensor/xrandom.hpp\u003e\n#include \u003cxtensor/xio.hpp\u003e\n\n#include \"conversions.hpp\"\n\nint main(int argc, char **argv)\n{\n    ros::init(argc, argv, \"talker\");\n\n    ros::NodeHandle n;\n\n    ros::Publisher chatter_pub = n.advertise\u003cxt::xarray\u003cdouble\u003e\u003e(\"chatter\", 1000);\n\n    ros::Rate loop_rate(10);\n\n    int count = 0;\n\n    // fill an xarray with ones\n    xt::xarray\u003cdouble\u003e a = xt::ones\u003cunsigned char\u003e({3, 3});\n\n    while (ros::ok())\n    {\n        chatter_pub.publish(a);\n        ros::spinOnce();\n        loop_rate.sleep();\n\n        // add 1 to all elements in xarray\n        a += 1;\n    }\n    return 0;\n}\n```\n\nand a subscriber to multidimensional arrays:\n\n```cpp\n#include \"ros/ros.h\"\n\n#include \u003cxtensor/xio.hpp\u003e\n\n#include \"conversions.hpp\"\n\nvoid chatterCallback(const xt::xarray\u003cdouble\u003e\u0026 msg_arr)\n{\n    ROS_INFO(\"I heard: something\");\n    std::cout \u003c\u003c msg_arr \u003c\u003c std::endl;\n}\n\nint main(int argc, char **argv)\n{\n    ros::init(argc, argv, \"listener\");\n\n    ros::NodeHandle n;\n    ros::Subscriber sub = n.subscribe(\"chatter\", 1000, chatterCallback);\n\n    ros::spin();\n\n    return 0;\n}\n```\n\nIf you have messages which include more than one field, conversion is unfortunately slightly trickier, due\nto constraints of the message generation of ROS. Internally, xtensor_ros has a message for each type: f64, f32, \nu8, u16, u32, u64, i8, i16, i32, i64. These can be used in your message definition, for example:\n\n```\nuint8 id\nxtensor_ros/f64 arr\n```\n\nThis will add an xtensor message field to your custom message. Automatic conversion is unfortunately not yet possible,\nbut we have the following syntax:\n\n```cpp\n// consider a message with an ID field, and a xtensor_ros/f64 array field\nmsg.id = 123;\nmsg.array = as_msg(a);\n// and then, to go from the internal xtensor_ros/f64 message to an xarray of the \n// correct type (on the subscriber side)\nauto arr = from_msg(msg.arr);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobostack%2Fxtensor-ros","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobostack%2Fxtensor-ros","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobostack%2Fxtensor-ros/lists"}