2.4 Why Rosserial?
While it's possible to control hardware via Arduino and ROS without using the rosserial library, it's important to understand the trade-offs. Here's a breakdown of why and when you might want to use rosserial, and the implications of not including it.
Why Use rosserial?
rosserial?Native ROS Communication:
rosserialallows the Arduino to directly publish and subscribe to ROS topics, effectively making the Arduino a node within your ROS environment. This enables seamless integration with other ROS nodes, allowing for more complex interactions, like subscribing to sensor data, publishing actuator commands, and making use of services and actions.ROS-like API: It gives you a high-level API to work with that closely follows the ROS communication paradigm (topics, messages, and services), making it easier to integrate the Arduino with the broader ROS ecosystem.
Convenient for Complex Systems: For larger, more complex systems involving multiple devices or robots,
rosserialhelps by reducing the overhead of handling communication protocols manually.
Why Skip rosserial?
rosserial?Simplicity: By not using
rosserial, you can directly control the Arduino via serial communication. This may be simpler if you're just sending basic commands (like turning on LEDs or controlling a motor), as you avoid the overhead of configuringrosserial.Lighter on Resources:
rosserialadds additional overhead on the Arduino and requires some memory for the ROS communication protocols. If your project is very resource-constrained, it may be easier to use basic serial communication instead.Custom Protocols: In some cases, you may want to define your own communication protocol between ROS and Arduino (as we did in the previous tutorial). This allows more fine-tuned control, but also requires you to handle error-checking, data parsing, and other aspects that
rosserialhandles for you.
Is It Okay to Not Include rosserial?
rosserial?Yes, it's completely fine not to use rosserial, especially for simpler applications like controlling LEDs, motors, or reading basic sensors where you only need to send a few commands or data points. Many people skip rosserial when:
They are dealing with simple hardware interactions.
They prefer to control the Arduino through a custom serial protocol.
They want a lightweight setup without adding complexity.
In this tutorial, we bypassed rosserial and used plain serial communication to simplify the connection between the ROS node (written in Python) and Arduino. This approach works perfectly well for smaller, simpler projects. However, if you later scale your project or want to adhere closely to the ROS communication model, switching to rosserial would make the system more flexible.
Downsides of Skipping rosserial:
rosserial:Lack of Direct ROS Integration: Without
rosserial, the Arduino is not technically a full-fledged ROS node. This limits its ability to publish/subscribe to ROS topics or access ROS services directly.Manual Handling of Data: You must manually manage serial data (e.g., parsing commands, handling errors), whereas
rosserialhandles these internally.Limited in Large Projects: If your project scales (e.g., multiple sensors, more complex interaction),
rosserialoffers a more robust structure for communication.
Summary
For simple control tasks like turning on LEDs, controlling a servo, or reading simple sensors, you can skip
rosserialand handle everything with basic serial communication.For more complex systems where you want the Arduino to publish/subscribe to ROS topics, respond to services, or handle more complex data exchanges, you should consider using
rosserial.
In the case of your current project, skipping rosserial is perfectly fine since the focus is on simple control of LEDs and servo motors. However, keep in mind that for future, more advanced projects, you might want to adopt rosserial to take full advantage of ROS.
Last updated