Mutex with multiple types of topics as input

asked 2016-06-27 05:16:50 -0500

rbaleksandar gravatar image

I'm currently looking into using the ROS mux (from topic_tools) for controlling an LED system on a mobile platform (similar to the PR2 but without the bulky robot on the top, just the base). Right now I have multiple services and normal topics that are handled by a node which controls the LEDs that are mounted at various locations on the platform. The problem is that there are no priorities. Priorities are essential here since each LED-related message is used to visualize some sort of situation that the user should/has to be aware of. For example minor errors (like object tracking failed in which situation the robot simply stops moving) are of lower priority compared to let's say the crash of a system-critical node (like velocity of the platform has reached a given limit in which case driving it around manually may become dangerous to either or both the user and the platform itself).

I would like to implement a priority-capable mutex (similar to the twist_mux and the cmd_vel_mux) however I would also like to keep the current state of the topic I have. This means that the outputs of the mutex will be of different type.

Here are some examples:

Force direction message (*.msg):

# Gives LED feedback of the direction and magnitude of the force that is applied to the platform by pulling it (can aslo be used
geometry_msgs/WrenchStamped force
std_msgs/ColorRGBA color

Blink action message (*.action):

# Gives LED feedback for a variety of scenarios
int32 blinks                    # Number of flashes (1 flash = 1 time on + 1 time off) - duration: long
int32 fast_blinks               # Number of flashes (1 flash = 1 time on + 1 time off) - duration: short (takes place from one long flash to another)

int32 start_led
int32 end_led

std_msgs/ColorRGBA color_outer
std_msgs/ColorRGBA color_inner

int32 num_inner_leds            # Number of LEDs for EACH inner stripe; it can be <= the half of all LEDs defined by start_led and end_led
---
int32 blinks_left               # Result (if == 0 then really successful); refers to the flashes with LONG duration only
---
int32 fast_blinks_left          # Feedback: number of flashes left until the next flash with long duration
int32 blinks_left               # Feedback: number of flashes left until the goal is completed; refers to the flashes with LONG duration only

Service message (*.srv):

# Turns on/off the LEDs
bool turn_on
std_msgs/ColorRGBA color    # RGB values [0-1] for all LEDs (when turning on)
---
bool success
string message

Obviously I will have to add a priority parameter to all messages (service request, standard topics and action goals) otherwise the mutex will have to decide on its own based on the type of the topic which one should be executed etc.

I'm struggling with the implementation namely how do you process multiple topics of a different type in a generic way? What I envision in my head is something like this:

  1. One of the many client nodes (each client node handles some sort of scenario that is linked indirectly to the LED system) detects the need to send a message that is ...
(more)
edit retag flag offensive close merge delete