Difference between revisions of "ROS"
(→Starting ROS and roscore) |
(→rosserial_arduino) |
||
Line 24: | Line 24: | ||
(how do I interact with nodes? how do I start a new node? how do I shut down a node? all nodes?) | (how do I interact with nodes? how do I start a new node? how do I shut down a node? all nodes?) | ||
=== rosserial_arduino === | === rosserial_arduino === | ||
− | + | rosserial is a protocol for wrapping ROS services over a device like a serial port or network socket. In particular, we use rosserial_arduino because it allows us to easily get ROS nodes running on Arduino. | |
== Topics == | == Topics == |
Revision as of 01:01, 11 May 2019
We use ROS to send messages between the Pi and the Due. As of April 2019, we use the Indigo Igloo version, released in 2014, on the Pi.
Starting ROS and roscore
What is roscore? roscore is a collection of nodes and programs that are prerequisites of a ROS-based system. You must have a roscore running in order for ROS nodes to communicate. For more information on ROS nodes, see below.
Nodes
A node is a process that performs computation. Each node is an independent part of your application, and they can be combined together into a graph. A robot control system will usually comprise many nodes.
Nodes can communicate with other nodes through ROS communication tools (topics, services, and actions).
Nodes provide several benefits. For one, there is fault tolerance - crashes are isolated to individual nodes. Code complexity is also reduced compared to monolithic systems. Finally, implementation details are well hidden as the nodes expose a minimal API to the rest of the graph.
How do I start a new node?
There are two levels of initialization for a roscpp Node.
First, you can initialize a node through a call to one of the ros::init()
functions.
Second, the node is started through the creation of a ros::NodeHandle
.
How do I shut down a node?
At any time, you can call the ros::shutdown()
function to shut down your node. This function will shut down all open subscriptions, publications, service calls, and service servers. You can also check the various states of shut down using ros::ok
which returns false once the node has finished shutting down, or ros::isShuttingDown()
which returns true as soon as ros::shutdown()
is called.
How do I shut down all nodes?
Typing rosnode kill -a
in the terminal will terminate all your nodes. However, this will only work if your roscore
is still running. Otherwise, it will not be able to find the running nodes.
(how do I interact with nodes? how do I start a new node? how do I shut down a node? all nodes?)
rosserial_arduino
rosserial is a protocol for wrapping ROS services over a device like a serial port or network socket. In particular, we use rosserial_arduino because it allows us to easily get ROS nodes running on Arduino.
Topics
A topic is a name that is used to identify the contents of a message. Messages are routed using a publish/subscribe model. A node sends out messages by publishing it to a given topic, and a node that is interested in the specific kind of data will subscribe to the appropriate topic.
(what's a topic?)
(how can I interact with topics from the command line using the rostopic tool?)
(how can I interact with topics using nodes?)
Messages
(what's a message (aka a data type for a topic, service, etc)?)
(what are the most helpful available message types?)
(how do I work with Float32MultiArrays in Python and C++, since that's the most frequently used message?)
(how do I create my own message?)