leds.cpp
Go to the documentation of this file.
1 #include "ros/ros.h"
2 #include <ros/package.h>
3 #include "raspicat/LedValues.h"
4 #include <fstream>
5 using namespace ros;
6 
7 void output(std::ofstream *ofs, bool input)
8 {
9  *ofs << (input ? '1' : '0') << std::endl;
10 }
11 
12 void cb(const raspicat::LedValues::ConstPtr& msg)
13 {
14  std::ofstream ofs0("/dev/rtled0");
15  output(&ofs0, msg->right_side);
16  std::ofstream ofs1("/dev/rtled1");
17  output(&ofs1, msg->right_forward);
18  std::ofstream ofs2("/dev/rtled2");
19  output(&ofs2, msg->left_forward);
20  std::ofstream ofs3("/dev/rtled3");
21  output(&ofs3, msg->left_side);
22 }
23 
24 
25 int main(int argc, char **argv)
26 {
27  init(argc,argv,"leds");
28  NodeHandle n;
29  Subscriber sub = n.subscribe("leds", 10, cb);
30 
31  ros::spin();
32  exit(0);
33 }
34 
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL void spin(Spinner &spinner)
int main(int argc, char **argv)
Definition: leds.cpp:25
void output(std::ofstream *ofs, bool input)
Definition: leds.cpp:7
void cb(const raspicat::LedValues::ConstPtr &msg)
Definition: leds.cpp:12


raspicat
Author(s): Ryuichi Ueda , Daisuke Sato
autogenerated on Mon Jun 10 2019 14:27:50