Skip to content

Instantly share code, notes, and snippets.

@bmagyar
Created October 11, 2016 13:56
Show Gist options
  • Save bmagyar/1f92aa2f4f290a5faea8ce752ac1bc77 to your computer and use it in GitHub Desktop.
Save bmagyar/1f92aa2f4f290a5faea8ce752ac1bc77 to your computer and use it in GitHub Desktop.
rosconsolecolours.h
#ifndef ROSCONSOLECOLOURS_H
#define ROSCONSOLECOLOURS_H
#include <ros/console.h>
#include <iostream>
#define ROS_RED_STREAM(SSS) ROS_INFO_STREAM("\033[31;1m" << SSS << "\033[0m\n")
#define ROS_GREEN_STREAM(SSS) ROS_INFO_STREAM("\033[32;1m" << SSS << "\033[0m\n")
#define ROS_YELLOW_STREAM(SSS) ROS_INFO_STREAM("\033[33;1m" << SSS << "\033[0m\n")
#define ROS_BLUE_STREAM(SSS) ROS_INFO_STREAM("\033[34;1m" << SSS << "\033[0m\n")
#define ROS_MAGENTA_STREAM(SSS) ROS_INFO_STREAM("\033[35;1m" << SSS << "\033[0m\n")
#define ROS_CYAN_STREAM(SSS) ROS_INFO_STREAM("\033[36;1m" << SSS << "\033[0m\n")
#define ROS_WHITE_STREAM(SSS) ROS_INFO_STREAM("\033[30;47m" << SSS << "\033[0m\n")
template <typename T>
std::ostream& operator<< (std::ostream& stream, const std::vector<T>& vector)
{
for(const T& elem : vector)
stream << elem << ", ";
stream.seekp(-2, std::ios_base::end); // remove last ", "
return stream;
}
/* free test code here
ROS_RED_STREAM("bold red text");
ROS_YELLOW_STREAM("yellow stuff");
ROS_GREEN_STREAM("Green stuff");
ROS_BLUE_STREAM("blue");
ROS_CYAN_STREAM("cyan is different fromb blue");
ROS_MAGENTA_STREAM("magenta is not pink or is it?");
ROS_WHITE_STREAM("white bricks");
*/
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment