Commit fcc74691 authored by Marius Bock's avatar Marius Bock

sad

parent f1dea3f4
......@@ -26,7 +26,7 @@ find_package(catkin REQUIRED COMPONENTS
message_generation
pcl_ros
cv_bridge
)
)
add_message_files(
FILES
......@@ -41,7 +41,7 @@ generate_messages(
catkin_package(
INCLUDE_DIRS include
LIBRARIES comon er1driver
LIBRARIES comon crs_er1driver
CATKIN_DEPENDS roscpp std_msgs message_runtime
)
......@@ -96,24 +96,71 @@ file(GLOB_RECURSE better_enum_HEADERS ${better_enum_INCLUDE_DIR}/*.h*)
set(comon_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/comon/)
file(GLOB comon_SOURCES ${comon_SOURCE_DIR}/*.c*)
add_library(comon ${comon_SOURCES} ${comon_HEADERS} ${threadpool_HEADERS} ${scopeguard_HEADERS} ${better_enum_HEADERS})
add_library(crs_comon ${comon_SOURCES} ${comon_HEADERS} ${threadpool_HEADERS} ${scopeguard_HEADERS} ${better_enum_HEADERS})
target_link_libraries(crs_comon ${TBB_LIBRARIES})
add_dependencies(crs_comon crs_generate_messages_cpp)
target_link_libraries(comon ${TBB_LIBRARIES})
####################################### crs_er1driver #######################################
set(crs_er1driver_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/er1driver/)
file(GLOB crs_er1driver_HEADERS ${crs_er1driver_INCLUDE_DIR}/*.h*)
add_dependencies(comon crs_generate_messages_cpp)
set(crs_er1driver_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/er1driver/)
file(GLOB crs_er1driver_SOURCES ${crs_er1driver_SOURCE_DIR}/*.c*)
add_library(crs_er1driver ${crs_er1driver_SOURCES} ${crs_er1driver_HEADERS})
add_dependencies(crs_er1driver crs_comon)
target_link_libraries(crs_er1driver crs_comon ${SDL2_LIBRARY})
####################################### er1driver #######################################
set(er1driver_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/er1driver/)
file(GLOB er1driver_HEADERS ${er1driver_INCLUDE_DIR}/*.h*)
set(er1driver_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/er1driver/)
file(GLOB er1driver_SOURCES ${er1driver_SOURCE_DIR}/*.c*)
add_library(er1driver ${er1driver_SOURCES} ${er1driver_HEADERS})
add_dependencies(er1driver comon)
target_link_libraries(er1driver comon)
####################################### er1_serial_node #######################################
set(er1_serial_nodeINCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/er1_serial_node/)
file(GLOB er1_serial_nodeHEADERS ${er1_serial_nodeINCLUDE_DIR}/*.h*)
set(er1_serial_nodeSOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/er1_serial_node/)
file(GLOB er1_serial_nodeSOURCES ${er1_serial_nodeSOURCE_DIR}/*.c*)
add_executable(er1_serial_node ${er1_serial_nodeSOURCES} ${er1_serial_node_HEADERS})
add_dependencies(er1_serial_node crs_er1driver)
target_link_libraries(er1_serial_node crs_comon crs_er1driver ${catkin_LIBRARIES})
####################################### er1_serial_node_student #######################################
set(er1_serial_node_studentINCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/er1_serial_node_student/)
file(GLOB er1_serial_node_studentHEADERS ${er1_serial_node_studentINCLUDE_DIR}/*.h*)
set(er1_serial_node_studentSOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/er1_serial_node_student/)
file(GLOB er1_serial_node_studentSOURCES ${er1_serial_node_studentSOURCE_DIR}/*.c*)
add_executable(er1_serial_node_student ${er1_serial_node_studentSOURCES} ${er1_serial_node_student_HEADERS})
add_dependencies(er1_serial_node_student crs_er1driver)
target_link_libraries(er1_serial_node_student crs_comon crs_er1driver ${catkin_LIBRARIE})
####################################### er1_loop_node #######################################
set(er1_loop_nodeINCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/er1_loop_node/)
file(GLOB er1_loop_nodeHEADERS ${er1_loop_nodeINCLUDE_DIR}/*.h*)
set(er1_loop_nodeSOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/er1_loop_node/)
file(GLOB er1_loop_nodeSOURCES ${er1_loop_nodeSOURCE_DIR}/*.c*)
add_executable(er1_loop_node ${er1_loop_nodeSOURCES} ${er1_loop_node_HEADERS})
add_dependencies(er1_loop_node crs_er1driver)
target_link_libraries(er1_loop_node crs_comon crs_er1driver ${catkin_LIBRARIES})
####################################### er1_loop_node_student #######################################
set(er1_loop_node_studentINCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/er1_loop_node_student/)
file(GLOB er1_loop_node_studentHEADERS ${er1_loop_node_studentINCLUDE_DIR}/*.h*)
set(er1_loop_node_studentSOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/er1_loop_node_student/)
file(GLOB er1_loop_node_studentSOURCES ${er1_loop_node_studentSOURCE_DIR}/*.c*)
add_executable(er1_loop_node_student ${er1_loop_node_studentSOURCES} ${er1_loop_node_student_HEADERS})
add_dependencies(er1_loop_node_student crs_er1driver)
target_link_libraries(er1_loop_node_student crs_comon crs_er1driver ${catkin_LIBRARIE})
####################################### er1_driver_node_student #######################################
......@@ -124,8 +171,8 @@ set(er1_driver_node_student_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/er1_driver_
file(GLOB er1_driver_node_student_SOURCES ${er1_driver_node_student_SOURCE_DIR}/*.c*)
add_executable(er1_driver_node_student ${er1_driver_node_student_SOURCES} ${er1_driver_node_student_HEADERS})
add_dependencies(er1_driver_node_student comon er1driver)
target_link_libraries(er1_driver_node_student comon er1driver ${catkin_LIBRARIES})
add_dependencies(er1_driver_node_student crs_er1driver)
target_link_libraries(er1_driver_node_student crs_comon crs_er1driver ${catkin_LIBRARIES})
####################################### er1_control_node_student #######################################
set(er1_control_node_student_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/er1_control_node_student/)
......@@ -135,8 +182,8 @@ set(er1_control_node_student_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/er1_contro
file(GLOB er1_control_node_student_SOURCES ${er1_control_node_student_SOURCE_DIR}/*.c*)
add_executable(er1_control_node_student ${er1_control_node_student_SOURCES} ${er1_control_node_student_HEADERS})
add_dependencies(er1_control_node_student er1driver)
target_link_libraries(er1_control_node_student er1driver ${SDL2_LIBRARY} ${catkin_LIBRARIES})
add_dependencies(er1_control_node_student crs_er1driver)
target_link_libraries(er1_control_node_student crs_er1driver ${SDL2_LIBRARY} ${catkin_LIBRARIES})
####################################### er1_driver_node #######################################
set(er1_driver_node_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/er1_driver_node/)
......@@ -145,9 +192,11 @@ file(GLOB er1_driver_node_HEADERS ${er1_driver_node_INCLUDE_DIR}/*.h*)
set(er1_driver_node_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/er1_driver_node/)
file(GLOB er1_driver_node_SOURCES ${er1_driver_node_SOURCE_DIR}/*.c*)
add_executable(er1_driver_node ${er1_driver_node_SOURCES} ${er1_driver_node_HEADERS})
add_dependencies(er1_driver_node comon er1driver)
target_link_libraries(er1_driver_node comon er1driver ${catkin_LIBRARIES})
add_executable(crs_er1_driver_node ${er1_driver_node_SOURCES} ${er1_driver_node_HEADERS})
set_target_properties(crs_er1_driver_node PROPERTIES OUTPUT_NAME er1_driver_node PREFIX "")
add_dependencies(crs_er1_driver_node crs_comon crs_er1driver)
target_link_libraries(crs_er1_driver_node crs_comon crs_er1driver ${catkin_LIBRARIES})
####################################### er1_control_node #######################################
set(er1_control_node_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/er1_control_node/)
......@@ -156,9 +205,12 @@ file(GLOB er1_control_node_HEADERS ${er1_control_node_INCLUDE_DIR}/*.h*)
set(er1_control_node_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/er1_control_node/)
file(GLOB er1_control_node_SOURCES ${er1_control_node_SOURCE_DIR}/*.c*)
add_executable(er1_control_node ${er1_control_node_SOURCES} ${er1_control_node_HEADERS})
add_dependencies(er1_control_node er1driver)
target_link_libraries(er1_control_node er1driver ${SDL2_LIBRARY} ${catkin_LIBRARIES})
add_executable(crs_er1_control_node ${er1_control_node_SOURCES} ${er1_control_node_HEADERS})
set_target_properties(crs_er1_control_node PROPERTIES OUTPUT_NAME er1_control_node PREFIX "")
add_dependencies(crs_er1_control_node crs_er1driver)
target_link_libraries(crs_er1_control_node crs_er1driver ${SDL2_LIBRARY} ${catkin_LIBRARIES})
if (0)
......@@ -170,9 +222,9 @@ set(student_image_node_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/student_image_no
file(GLOB student_image_node_SOURCES ${student_image_node_SOURCE_DIR}/*.c*)
add_executable(student_image_node ${student_image_node_SOURCES} ${student_image_node_HEADERS})
add_dependencies(student_image_node er1driver)
add_dependencies(student_image_node crs_er1driver)
target_link_libraries(student_image_node
comon
crs_comon
${Boost_LIBRARIES}
${PCL_COMMON_LIBRARIES}
${OpenCV_LIBS}
......@@ -189,7 +241,7 @@ file(GLOB student_pointcloud_node_SOURCES ${student_pointcloud_node_SOURCE_DIR}/
add_executable(student_pointcloud_node ${student_pointcloud_node_SOURCES} ${student_pointcloud_node_HEADERS})
target_link_libraries(student_pointcloud_node ${catkin_LIBRARIES}
comon
crs_comon
${Boost_LIBRARIES}
${PCL_COMMON_LIBRARIES}
${OpenCV_LIBS}
......@@ -205,7 +257,7 @@ file(GLOB student_fun_node_a_SOURCES ${student_fun_node_a_SOURCE_DIR}/*.c*)
add_executable(student_fun_node_a ${student_fun_node_a_SOURCES} ${student_fun_node_a_HEADERS})
target_link_libraries(student_fun_node_a ${catkin_LIBRARIES}
comon
crs_comon
${Boost_LIBRARIES}
${PCL_COMMON_LIBRARIES}
${OpenCV_LIBS}
......@@ -219,9 +271,9 @@ set(student_fun_node_b_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/student_fun_node
file(GLOB student_fun_node_b_SOURCES ${student_fun_node_b_SOURCE_DIR}/*.c*)
add_executable(student_fun_node_b ${student_fun_node_b_SOURCES} ${student_fun_node_b_HEADERS})
add_dependencies(student_fun_node_b er1driver)
add_dependencies(student_fun_node_b crs_er1driver)
target_link_libraries(student_fun_node_b ${catkin_LIBRARIES}
comon
crs_comon
${Boost_LIBRARIES}
${PCL_COMMON_LIBRARIES}
${OpenCV_LIBS}
......
#include <SDL2/SDL.h>
namespace crs {
enum class Key {
None = 0,
Up = SDLK_UP,
Down = SDLK_DOWN,
Left = SDLK_LEFT,
Right = SDLK_RIGHT,
Escape = SDLK_ESCAPE
};
class CRSInputHelper {
public:
~CRSInputHelper();
/**
* @brief Initializes the input helper and creates a window.
* If this window is focused the keyboard input will be grabbed.
*/
bool init();
Key getKeyDown();
bool isKeyUp();
void checkKeys();
private:
bool hasNewKeyUp = false;
bool hasNewKeyDown = false;
int currentDown = 0;
SDL_Window *window = nullptr;
};
} // namespace crs
#include "ros/ros.h"
#include <iostream>
#include <string>
#include <SDL2/SDL.h>
#include <crs/ER1ControlMsg.h>
#define ML_QUIT_ON_ERROR(x) { \
auto rrr = x; \
if (!rrr) { \
ROS_ERROR("%s", rrr.msg().c_str());\
robot.stop();\
robot.disconnect();\
return -1;\
}\
}
int main(int argc, char** argv) {
ROS_INFO("er1 motor control node started");
ros::init(argc, argv, "er1_motor_control");
ros::NodeHandle node;
ros::Publisher publisher = node.advertise<crs::ER1ControlMsg>("er1_motor_commands", 1000);
SDL_Event event;
bool done = false;
if (SDL_Init(SDL_INIT_VIDEO)!= 0) {
ROS_INFO("Could not init SDL2");
return -1;
}
SDL_Window *window; // Declare a pointer
// Create an application window with the following settings:
window = SDL_CreateWindow(
"An SDL2 window", // window title
SDL_WINDOWPOS_UNDEFINED, // initial x position
SDL_WINDOWPOS_UNDEFINED, // initial y position
640, // width, in pixels
480, // height, in pixels
SDL_WINDOW_OPENGL // flags - see below
);
int currentDown = 0;
while (!done) {
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN: {
auto code = event.key.keysym.sym;
if (code == SDLK_UP && currentDown != SDLK_UP) {
currentDown = code;
crs::ER1ControlMsg msg;
msg.er1command = crs::ER1ControlMsg::ER1CommandForward;
publisher.publish(msg);
} else if (code == SDLK_DOWN && currentDown != SDLK_DOWN) {
crs::ER1ControlMsg msg;
msg.er1command = crs::ER1ControlMsg::ER1CommandBackward;
currentDown = code;
publisher.publish(msg);
} else if (code == SDLK_LEFT && currentDown != SDLK_LEFT) {
crs::ER1ControlMsg msg;
msg.er1command = crs::ER1ControlMsg::ER1CommandTurnLeft;
currentDown = code;
publisher.publish(msg);
} else if (code == SDLK_RIGHT && currentDown != SDLK_RIGHT){
crs::ER1ControlMsg msg;
msg.er1command = crs::ER1ControlMsg::ER1CommandTurnRight;
currentDown = code;
publisher.publish(msg);
}
break;
}
case SDL_KEYUP:
currentDown = 0;
crs::ER1ControlMsg msg;
msg.er1command = crs::ER1ControlMsg::ER1CommandStop;
publisher.publish(msg);
auto code = event.key.keysym.sym;
if (code == SDLK_q) {
done = true;
}
break;
}
}
}
SDL_DestroyWindow(window);
SDL_Quit();
ROS_INFO("er1 motor listener node finished");
return 0;
}
#include "ros/ros.h"
#include <iostream>
#include <string>
#include <er1driver/crsinputhelper.hpp>
/*
This file is generated by ROS. It allows us to send messages of the type "ER1ControlMsg" we specified in the "msg" folder.
Msg-file location: ~/catkin_ws/src/crs/msgs/ER1ControlMsg.msg
*/
#include <crs/ER1ControlMsg.h>
/* Dump of the file ~/catkin_ws/src/crs/msgs/ER1ControlMsg.msg
----------------------- BEGIN OF FILE ---------------------
uint8 ER1CommandStop=0
uint8 ER1CommandForward=1
uint8 ER1CommandBackward=2
uint8 ER1CommandTurnLeft=3
uint8 ER1CommandTurnRight=4
uint8 er1command
----------------------- END OF FILE -----------------------
The type of the generated message-class is equal to the original file name.
Since this message-file is part of the package "crs" the message-class is also part of the namespace "crs".
Therefore this file declares the type: "crs::ER1ControlMsg".
In the first 4 lines of the msg-file we declare some constants.
Since they are part of the msg-class they are pushed into the namespace "crs::ER1ControlMsg".
Therefore the constants are:
crs::ER1ControlMsg::ER1CommandStop
crs::ER1ControlMsg::ER1CommandTurnLeft
crs::ER1ControlMsg::ER1CommandTurnRight
crs::ER1ControlMsg::ER1CommandTurnUp
crs::ER1ControlMsg::ER1CommandTurnDown
*/
using namespace crs;
int main(int argc, char** argv) {
// init ROS
ros::init(argc, argv, "er1_motor_control");
ros::NodeHandle node;
// Subscribe to the command topic and await messages of the type "crs::ER1ControlMsg"
ros::Publisher publisher = node.advertise<crs::ER1ControlMsg>("er1_motor_commands", 1000);
// Init Input helper
CRSInputHelper helper;
helper.init();
// Main Loop
bool done = false;
while(!done) {
// Check Keys
helper.checkKeys();
// Stop the robot on any keyup
if (helper.isKeyUp()) {
crs::ER1ControlMsg msg;
msg.er1command = crs::ER1ControlMsg::ER1CommandStop;
publisher.publish(msg);
}
// Send command if keydown
auto key = helper.getKeyDown();
if (key == Key::None) {
} else if (key == Key::Left) {
crs::ER1ControlMsg msg;
msg.er1command = crs::ER1ControlMsg::ER1CommandTurnLeft;
publisher.publish(msg);
} else if (key == Key::Right) {
crs::ER1ControlMsg msg;
msg.er1command = crs::ER1ControlMsg::ER1CommandTurnRight;
publisher.publish(msg);
} else if (key == Key::Up) {
crs::ER1ControlMsg msg;
msg.er1command = crs::ER1ControlMsg::ER1CommandForward;
publisher.publish(msg);
} else if (key == Key::Down) {
crs::ER1ControlMsg msg;
msg.er1command = crs::ER1ControlMsg::ER1CommandBackward;
publisher.publish(msg);
} else if (key == Key::Escape) {
done = true;
}
}
return 0;
}
#include "ros/ros.h"
#include <iostream>
#include <string>
#include <er1driver/crsinputhelper.hpp>
/*
This file is generated by ROS. It allows us to send messages of the type "ER1ControlMsg" we specified in the "msg" folder.
Msg-file location: ~/catkin_ws/src/crs/msgs/ER1ControlMsg.msg
*/
#include <crs/ER1ControlMsg.h>
/* Dump of the file ~/catkin_ws/src/crs/msgs/ER1ControlMsg.msg
----------------------- BEGIN OF FILE ---------------------
uint8 ER1CommandStop=0
uint8 ER1CommandForward=1
uint8 ER1CommandBackward=2
uint8 ER1CommandTurnLeft=3
uint8 ER1CommandTurnRight=4
uint8 er1command
----------------------- END OF FILE -----------------------
The type of the generated message-class is equal to the original file name.
Since this message-file is part of the package "crs" the message-class is also part of the namespace "crs".
Therefore this file declares the type: "crs::ER1ControlMsg".
In the first 4 lines of the msg-file we declare some constants.
Since they are part of the msg-class they are pushed into the namespace "crs::ER1ControlMsg".
Therefore the constants are:
crs::ER1ControlMsg::ER1CommandStop
crs::ER1ControlMsg::ER1CommandTurnLeft
crs::ER1ControlMsg::ER1CommandTurnRight
crs::ER1ControlMsg::ER1CommandTurnUp
crs::ER1ControlMsg::ER1CommandTurnDown
*/
using namespace crs;
int main(int argc, char** argv) {
// init ROS
ros::init(argc, argv, "er1_motor_control");
ros::NodeHandle node;
// Subscribe to the command topic and await messages of the type "crs::ER1ControlMsg"
ros::Publisher publisher = node.advertise<crs::ER1ControlMsg>("er1_motor_commands", 1000);
// Init Input helper
CRSInputHelper helper;
helper.init();
// Main Loop
bool done = false;
while(!done) {
// Check Keys
helper.checkKeys();
// Stop the robot on any keyup
if (helper.isKeyUp()) {
crs::ER1ControlMsg msg;
msg.er1command = crs::ER1ControlMsg::ER1CommandStop;
publisher.publish(msg);
}
}
return 0;
}
#include <er1driver/er1driver.hpp>
#include "ros/ros.h"
#include <iostream>
#include <string>
#include <SDL2/SDL.h>
#include <crs/ER1ControlMsg.h>
#define ML_QUIT_ON_ERROR(x) { \
auto rrr = x; \
if (!rrr) { \
ROS_ERROR("%s", rrr.msg().c_str());\
robot.stop();\
robot.disconnect();\
return -1;\
}\
}
er1driver::SimpleER1Interface robot; // Todo: very bad idea
void callback(crs::ER1ControlMsgConstPtr ptr) {
auto cmd = ptr->er1command;
if (cmd == crs::ER1ControlMsg::ER1CommandForward) {
robot.move(er1driver::Direction::Forward);
} else if (cmd == crs::ER1ControlMsg::ER1CommandBackward) {
robot.move(er1driver::Direction::Backward);
} else if (cmd == crs::ER1ControlMsg::ER1CommandTurnLeft) {
robot.turn(er1driver::Orientation::Left);
} else if (cmd == crs::ER1ControlMsg::ER1CommandTurnRight) {
robot.turn(er1driver::Orientation::Right);
} else {
robot.stop();
}
}
int main(int argc, char** argv) {
using namespace er1driver;
ros::init(argc, argv, "er1_driver_node");
ros::NodeHandle node;
ros::Subscriber sub = node.subscribe("er1_motor_commands", 1000, &callback);
ros::NodeHandle privateNode("~");
std::string robotName;
EvolutionRobotID id;
if (privateNode.hasParam("robot")) {
privateNode.getParam("robot", robotName);
if (robotName.empty()) {
ROS_ERROR("You have to specify a robot name. _robot:=\{Scorpion, ER1Small, ER1Medium, ER1Large\}");
return -1;
} else {
if (robotName == "Scorpion") {
id = EvolutionRobotID::Scorpion;
} else if (robotName == "ER1Small") {
id = EvolutionRobotID::ER1Small;
} else if (robotName == "ER1Medium") {
id = EvolutionRobotID::ER1Medium;
} else if (robotName == "ER1Large") {
id = EvolutionRobotID::ER1Large;
} else {
ROS_ERROR("Invalid robot name '%s'. Valid values _robot:=\{Scorpion, ER1Small, ER1Medium, ER1Large\}", robotName.c_str());
return -1;
}
ROS_INFO("Using Robot: %s", robotName.c_str());
}
} else {
ROS_ERROR("You have to specify a robot name. _robot:=\{Scorpion, ER1Small, ER1Medium, ER1Large\}");
return -1;
}
ML_QUIT_ON_ERROR(robot.connect(id));
ros::spin();
return 0;
}
#include <er1driver/er1driver.hpp>
#include "ros/ros.h"
#include <iostream>
#include <string>
/*
This file is generated by ROS. It allows us to send messages of the type "ER1ControlMsg" we specified in the "msg" folder.
Msg-file location: ~/catkin_ws/src/crs/msgs/ER1ControlMsg.msg
*/
#include <crs/ER1ControlMsg.h>
/* Dump of the file ~/catkin_ws/src/crs/msgs/ER1ControlMsg.msg
----------------------- BEGIN OF FILE ---------------------
uint8 ER1CommandStop=0
uint8 ER1CommandForward=1
uint8 ER1CommandBackward=2
uint8 ER1CommandTurnLeft=3
uint8 ER1CommandTurnRight=4
uint8 er1command
----------------------- END OF FILE -----------------------
The type of the generated message-class is equal to the original file name.
Since this message-file is part of the package "crs" the message-class is also part of the namespace "crs".
Therefore this file declares the type: "crs::ER1ControlMsg".
In the first 4 lines of the msg-file we declare some constants.
Since they are part of the msg-class they are pushed into the namespace "crs::ER1ControlMsg".
Therefore the constants are:
crs::ER1ControlMsg::ER1CommandStop
crs::ER1ControlMsg::ER1CommandTurnLeft
crs::ER1ControlMsg::ER1CommandTurnRight
crs::ER1ControlMsg::ER1CommandTurnUp
crs::ER1ControlMsg::ER1CommandTurnDown
*/
using namespace er1driver;
// the global robot interface
SimpleER1Interface robot;
/*
* This functions gets called whenever we receive a message of the type "ER1ControlMsg".
* Since this message type is part of the package "crs" it is part of the namespace "crs".
*/
void callback(crs::ER1ControlMsgConstPtr ptr) {