If one node crashes, it will not make the other nodes crash.įirst, that’s great for debugging. As nodes only communicate through ROS, they are not directly linked. Nodes also provide a great fault tolerance.
#Robotek node code
Trust me, if you write everything in one block, you’ll soon spend more time fixing your code than actually developing new functionalities. If you correctly separate your application into packages and nodes, then it will be much easier for you to scale your application. What are the main benefits of nodes ? Why should you use nodes instead of just writing all your code in the same place ? Reduce code complexity If you want to run multiple instances of the same node, you’ll have to add a prefix or suffix to the name, or declare them as anonymous. Note that 2 nodes can’t have the same name. Nodes are combined into a graph and communicate with each other using ROS topics, services, actions, etc.
You will write many nodes and put them into packages. It is an executable program running inside your application. Let’s go back to the ROS node definition.Ī ROS node, according to ROS wiki, is basically a process that performs computation. Note that this architecture is really similar to what you can actually see in real life robots. Thus, the motion planning can be dynamically changed thanks to the hardware or camera data. The hardware state of the robot is published, and both the motion planning and path correction nodes are receiving it. The motion planning node from the motion planning package will send computed trajectories to the main control loop node, inside the hardware control package. This data is also published by a state publisher node.
And let’s say that the position data coming from the motor encoders is sent back to the control loop for more precise control.
#Robotek node drivers
The drivers are controlled from the main control loop node. In this package we’ll find some drivers to control the motors. That can be wheels, a robotic arm joints, or anything else. This package, as an independent unit, will control the hardware of the robot. Nodes for the hardware control packageĪnd we finish with our third package, which is the hardware control. This ROS node will then be able to notify the motion planning node. The image processing node will analyze frames coming from the camera and will send an analysis of the environment to the path correction node. Let’s link the image processing node to the path correction node. What we can do now, is to make 2 nodes inside different packages communicate together. Great! We have 2 packages filled with nodes. We can also add a path correction node, which role is to modify the motion planning due to external factors. In this package you can expect to have a motion planning node, which will compute motion planning for any given robot.
#Robotek node driver
But for this example, let’s just say that the image processing is specific to the camera we’re talking about, and both driver and image processing are using some common dependencies. We could add many other processing nodes, and this package would communicate with any other camera package which include drivers. For example, the image processing node could be part of another package which only handles image processing for any camera. Note that sometimes, it can be quite hard to know if you should put 2 nodes in the same package. The nodes will then communicate using ROS communication functionalities, for example topics, services and actions.Īll right, we have our camera package filled with all the nodes we need. First you will launch the driver, and then the image processing node. We could also add any other program related to the camera we are using.Īll those programs in blue are nodes. Then we also need a program that will take those frames and do some image processing work. The camera package will handle a camera as an independent unit.įirst, we need a driver for the camera, to be able to program it, and get frames from it. Let’s now fill in those packages with useful nodes which will be responsible for the execution of the program. Those packages are the 3 main parts of your application. Camera package: processes images and give useful info and commands to the robot.Motion planning package: monitors and controls the robot trajectory.Hardware control package: directly controls the hardware (wheels and other actuators).
The robot has 3 ROS packages (from low to high level):Ĭheck out ROS For Beginners and learn ROS step by step. Let’s start with a standard robotics application which involves a mobile robot and a camera.