Menu

Code Overview

Ardeshir20

Code Overview

This project creates a ROS node that connects ROS topics to USARSim. Eventually, it will support full auto-discovery of USARSim robots and configure the ROS system to control them. Currently, two ros nodes exist; usarsim_node and usarsim_urdf. Information on how to build this node may be found at [USARSimROS].

USARSim_Node

The usarsim node is contained in the file usarsim.cpp. This is a multi-threaded application that has a USARSim and ROS thread. UsarsimInf located in the file usarsimInf.cpp is the main class that handles the USARSim socket reading and writing. This class is spawned as the first thread of the node. ServoInf located in the file servoInf.cpp is the main class that handles the ROS interface. This class is spawned as the second thread of the node. Both of these classes inherit from the GenericInf class located in the file genericInf.cpp.

UsarsimInf

This class is based on the original simware code from the sourceforge MOAST project. The file started as entirely commented out, and as messages are ported over, the comments are removed. The class strives to auto-discover all robots and sensors in USARSim. It does this by sending out GetGet and GetConf messages and parsing the returns. As new sensors and systems are discovered, appropriate messages are sent to the ROS side of the interface which then creates the required ROS topics.

Messages are read from the USARSim socket and composed into a single buffer in the msgIn routine. This in turn calls the handleMsg class which is the main message parser. Messages are parsed and sent to the appropriate routine for data extraction.

Data is extracted and placed into a sw_struct (located in simware.hh) structure that is a union of all possible messages. This message is then sent to the ROS thread via the msgout method that calls the ROS thread's peerMsg method.

Data into the USARSim system is received from the ROS thread via UsarsimInf's peerMsg method. Data comes in as a sw_struct and is parsed into an ASCII string which is sent over the USARSim socket.

ServoInf

This class is contained in the file src/servoInf.cpp.

This class creates callbacks for any ROS topics that it should subscribe to. The main USARSim_Node creates a thread based on this class and calls its msgIn method. The msgIn method creates the appropriate callback subscriptions. Each callback method parses the ROS topic and places the data into a sw_struct which is then sent to the USARSim thread via the peerMsg method. The USARSim thread must then manipulate the data to be in an appropriate form for USARSim. This data is then written over the USARSim socket.

USARSim _URDF

This is a work in progress. The idea is that this node will read the USARSim getGeo and getConf messages and automatically compose an URDF file. This URDF file will then be able to be used by the arm control wizard and rviz to provide control and visualization of the robotic arm (running in USARSim).


Related

Wiki: Home
Wiki: USARSimROS