(sec-module-robotics.rosinterface)= # Module: robotics.rosInterface This interface collects interfaces and functionality for ROS comunication This library is under construction (2023-05); To make use of this libraries, you need to install ROS (ROS1 noetic) including rospy Please consider following workflow: make sure to have a working ROS1-NOETIC installation, ROS2 is not supported yet tested only with ROS1-NOETIC, ubuntu 20.04, and Python 3.8.10 you find all ROS1 installation steps on: http://wiki.ros.org/noetic/Installation/Ubuntu Step 1.4 we recommend to install: (sudo apt install ros-noetic-desktop) Check the installation of the turtlesim package (rosrun turtlesim turtlesim_node ) if not installed: sudo apt install ros-noetic-turtlesim use a catkin workspace and build a ROS1 Package Follow instructions on: http://wiki.ros.org/ROS/Tutorials (recommend go trough step 1 to 6) Minimal example to use: create catkin workspace: mkdir -p ~/catkin_ws/src cd ~/catkin_ws catkin_make source devel/setup.bash build ROS package: cd ~/catkin_ws/src catkin_create_pkg my_pkg_name rospy roscpp std_msgs geometry_msgs sensor_msgs build catkin workspace and sourcing setup file cd ~/catkin_ws cakin_make source ~/catkin_ws/devel/setup.bash for more functionality see also: ROSExampleMassPoint.py, ROSExampleBringup.launch, ROSExampleControlVelocity.py - **Author**: Martin Sereinig, Peter Manzl - **Date**: 2023-05-31 (created) (sec-module-robotics.rosinterface-class-rosinterface)= ## CLASS ROSInterface (in module robotics.rosInterface) **class description**: interface super class to establish a ROS Exudyn interface see specific class functions which can be used and extended by inheritance with class MyClass(ROSInterface) - **author**: Martin Sereinig, Peter Manzl - **notes**: some inspiration can be taken from (sec-rosinterface-rosinterface-initpublisher)= ### Class function: InitPublisher [`InitPublisher(self, pubTopicName = '', pubType = Empty, queueSize = 10)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/rosInterface.py#L117) - **class function description**: function to create a publisher - **input**: - `pubTopicName`: topic name to publish, actual topic will be /exudyn/pubTopicName - `pubType`: data type used in topic - `queSize`: length of queue to hold messages, should be as small as sending frequency (= simulation sample time) - **author**: Martin Sereinig - **notes**: find msgs types here http://docs.ros.org/en/melodic/api/std_msgs/html/index-msg.html *example*: ```python publisher for poses, pubType = PoseStamped, publisher for system data, pubType = Float64MultiArray, publisher for filtered force, pubType = WrenchStamped, publisher for velocities, pubType = Twist, ``` (sec-rosinterface-rosinterface-exucallbackgeneric)= ### Class function: ExuCallbackGeneric [`ExuCallbackGeneric(self, subTopicName, data)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/rosInterface.py#L140) - **class function description**: function to create a generic callback function for a subscriber - **input**: - `topic`: topic name generated by init Subscriber - `data`: data structure for regarding individual topic - **author**: Peter Manzl (sec-rosinterface-rosinterface-initsubscriber)= ### Class function: InitSubscriber [`InitSubscriber(self, subTopicNameSpace, subTopicName, subType)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/rosInterface.py#L151) - **class function description**: function to create a subscriber - **input**: - `subTopicNameSpace`: topic namespace: 'exudyn/' - `subTopicName`: topic name to subscribe - `subType`: data type for topic to subscribe - **author**: Peter Manzl - **notes**: callback function will be automatic generated for each subscriber, depending on subTopicName. Data will be found under self.subTopicName (sec-rosinterface-rosinterface-checkrosversion)= ### Class function: CheckROSversion [`CheckROSversion(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/rosInterface.py#L168) - **class function description**: check the current used ROS version - **author**: Martin Sereinig - **notes**: just supports ROS1, ROS2 support will be given in future releases (sec-rosinterface-rosinterface-publishposeupdate)= ### Class function: PublishPoseUpdate [`PublishPoseUpdate(self, mbs, tExu, getData = 'node')`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/rosInterface.py#L186) - **class function description**: Example method to be called once per frame/control cycle in Exudyn PreStepUserFunction - **input**: - `mbs`: mbs (exudyn.exudynCPP.MainSystem), multi-body simulation system from exudyn - `tExu`: tExu (float), elapsed time since simulation start - `getData`: getData (string), get pose information from 'node' or from 'sensor' - **author**: Martin Sereinig - **notes**: reads sensor values, creates message, publish and subscribe to ROS publishing each and every step is too much, this would slow down the connection thus: publish every few seconds, only furthermore, as vrInterface is only updating the graphics with f=60Hz, we don't have to update system state every 1ms, so with f=1000Hz. Instead f=60Hz equivalents to update every 1/60=17ms timing variable to know when to send new command to robot or when to publish new mbs system state update (sec-rosinterface-rosinterface-publishtwistupdate)= ### Class function: PublishTwistUpdate [`PublishTwistUpdate(self, mbs, tExu, getData = 'node')`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/rosInterface.py#L252) - **class function description**: Example method to be called once per frame/control cycle in Exudyn PreStepUserFunction - **input**: - `mbs`: mbs (exudyn.exudynCPP.MainSystem), multi-body simulation system from exudyn - `tExu`: tExu (float), elapsed time since simulation start - `getData`: getData (string), get pose information from 'node' or from 'sensor' - **author**: Martin Sereinig - **notes**: reads sensor values, creates message, publish and subscribe to ROS (sec-rosinterface-rosinterface-publishsystemstateupdate)= ### Class function: PublishSystemStateUpdate [`PublishSystemStateUpdate(self, mbs, tExu)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/rosInterface.py#L299) - **class function description**: method to be send system state data once per frame/control cycle in Exudyn PreStepUserFunction - **input**: - `mbs`: mbs (exudyn.exudynCPP.MainSystem), multi-body simulation system from exudyn - `tExu`: tExu (float), simulation time - `systemStateData`: systemStateData (list), full Exudyn SystemState - **author**: Martin Sereinig - **notes**: collects important exudyn system data and send it to ros-topic