pheeno_robot.h
Go to the documentation of this file.
1 #ifndef PHEENO_ROS_PHEENO_ROBOT_H
2 #define PHEENO_ROS_PHEENO_ROBOT_H
3 
4 #include "ros/ros.h"
5 #include "std_msgs/Float32.h"
6 #include "std_msgs/Int16.h"
7 #include "geometry_msgs/Twist.h"
8 #include "geometry_msgs/Vector3.h"
9 #include "nav_msgs/Odometry.h"
10 #include <vector>
11 #include <complex>
12 #include <cstdlib>
13 
14 namespace Pheeno
15 {
16  enum IR
17  {
24  };
25 
26  enum ENCODER
27  {
28  LL,
29  LR,
30  RL,
32  };
33 }
34 
36 {
37 
38 public:
39  // Constructor
40  PheenoRobot(std::string pheeno_name);
41 
42  // Pheeno name
43  std::string pheeno_namespace_id_;
44 
45  // Sensor Messages
46  std_msgs::Float32 ir_sensor_center_;
47  std_msgs::Float32 ir_sensor_back_;
48  std_msgs::Float32 ir_sensor_right_;
49  std_msgs::Float32 ir_sensor_left_;
50  std_msgs::Float32 ir_sensor_c_right_;
51  std_msgs::Float32 ir_sensor_c_left_;
52  std_msgs::Int16 ir_sensor_bottom_;
53  std::vector<double> ir_sensor_vals_;
54  std::vector<int> encoder_vals_;
55  std::vector<double> magnetometer_vals_;
56  std::vector<double> gyroscope_vals_;
57  std::vector<double> accelerometer_vals_;
58 
59  // Odometry Messages
60  nav_msgs::Odometry odom_msg_;
61  std::vector<double> odom_pose_position_;
62  std::vector<double> odom_pose_orient_;
63  std::vector<double> odom_twist_linear_;
64  std::vector<double> odom_twist_angular_;
65 
66  // Camera Messages
67  std::vector<bool> color_state_facing_;
68 
69  // Public Sensor Methods
70  bool irSensorTriggered(float sensor_limits);
71 
72  // Public Movement Methods
73  double randomTurn(float angular = 0.06);
74  void avoidObstaclesLinear(double &linear, double &angular,
75  float angular_velocity = 1.2, float linear_velocity = 0.08,
76  double range_to_avoid = 20.0);
77  void avoidObstaclesAngular(double &angular, double &random_turn_value,
78  float angular_velocity = 1.2, double range_to_avoid = 20.0);
79 
80  // Public Publishers
81  void publish(geometry_msgs::Twist velocity);
82 
83  // Public camera methods
84  bool checkFrontColor(int color);
85 
86 private:
87  // ROS Node handle
89 
90  // Private Subscribers
107 
108  // Private Publishers
110 
111  // IR Callback Methods
112  void irSensorCenterCallback(const std_msgs::Float32::ConstPtr& msg);
113  void irSensorBackCallback(const std_msgs::Float32::ConstPtr& msg);
114  void irSensorRightCallback(const std_msgs::Float32::ConstPtr& msg);
115  void irSensorLeftCallback(const std_msgs::Float32::ConstPtr& msg);
116  void irSensorCRightCallback(const std_msgs::Float32::ConstPtr& msg);
117  void irSensorCLeftCallback(const std_msgs::Float32::ConstPtr& msg);
118  void irSensorBottomCallback(const std_msgs::Int16::ConstPtr& msg);
119 
120  // Odom Callback Methods
121  void odomCallback(const nav_msgs::Odometry::ConstPtr& msg);
122 
123  // Encoder Callback Methods
124  void encoderLLCallback(const std_msgs::Int16::ConstPtr& msg);
125  void encoderLRCallback(const std_msgs::Int16::ConstPtr& msg);
126  void encoderRLCallback(const std_msgs::Int16::ConstPtr& msg);
127  void encoderRRCallback(const std_msgs::Int16::ConstPtr& msg);
128 
129  // Other Sensor Callback Methods
130  void magnetometerCallback(const geometry_msgs::Vector3::ConstPtr& msg);
131  void gyroscopeCallback(const geometry_msgs::Vector3::ConstPtr& msg);
132  void accelerometerCallback(const geometry_msgs::Vector3::ConstPtr& msg);
133 
134  // Camera Callback Modules
135  void piCamCallback();
136 };
137 
138 #endif // PHEENO_ROS_PHEENO_ROBOT_H
ros::NodeHandle nh_
Definition: pheeno_robot.h:88
std::vector< double > gyroscope_vals_
Definition: pheeno_robot.h:56
ros::Subscriber sub_pheeno_cam_
Definition: pheeno_robot.h:98
ros::Subscriber sub_ir_cr_
Definition: pheeno_robot.h:94
ros::Subscriber sub_odom_
Definition: pheeno_robot.h:99
std_msgs::Float32 ir_sensor_back_
Definition: pheeno_robot.h:47
std_msgs::Float32 ir_sensor_center_
Definition: pheeno_robot.h:46
ros::Subscriber sub_gyroscope_
Definition: pheeno_robot.h:105
std::vector< double > odom_pose_position_
Definition: pheeno_robot.h:61
ros::Subscriber sub_encoder_RL_
Definition: pheeno_robot.h:102
ros::Subscriber sub_magnetometer_
Definition: pheeno_robot.h:104
nav_msgs::Odometry odom_msg_
Definition: pheeno_robot.h:60
ros::Subscriber sub_ir_left_
Definition: pheeno_robot.h:93
ros::Subscriber sub_encoder_LR_
Definition: pheeno_robot.h:101
std_msgs::Int16 ir_sensor_bottom_
Definition: pheeno_robot.h:52
std_msgs::Float32 ir_sensor_c_right_
Definition: pheeno_robot.h:50
std::vector< double > odom_twist_angular_
Definition: pheeno_robot.h:64
ros::Subscriber sub_ir_bottom_
Definition: pheeno_robot.h:97
std::vector< double > accelerometer_vals_
Definition: pheeno_robot.h:57
std::vector< double > odom_pose_orient_
Definition: pheeno_robot.h:62
std_msgs::Float32 ir_sensor_c_left_
Definition: pheeno_robot.h:51
std_msgs::Float32 ir_sensor_right_
Definition: pheeno_robot.h:48
std::vector< int > encoder_vals_
Definition: pheeno_robot.h:54
ros::Subscriber sub_encoder_RR_
Definition: pheeno_robot.h:103
ros::Subscriber sub_ir_center_
Definition: pheeno_robot.h:91
ros::Subscriber sub_ir_right_
Definition: pheeno_robot.h:92
std::vector< double > odom_twist_linear_
Definition: pheeno_robot.h:63
ros::Subscriber sub_accelerometer_
Definition: pheeno_robot.h:106
ros::Subscriber sub_encoder_LL_
Definition: pheeno_robot.h:100
std::vector< double > magnetometer_vals_
Definition: pheeno_robot.h:55
ros::Publisher pub_cmd_vel_
Definition: pheeno_robot.h:109
ros::Subscriber sub_ir_back_
Definition: pheeno_robot.h:96
ros::Subscriber sub_ir_cl_
Definition: pheeno_robot.h:95
std_msgs::Float32 ir_sensor_left_
Definition: pheeno_robot.h:49
std::vector< double > ir_sensor_vals_
Definition: pheeno_robot.h:53
std::string pheeno_namespace_id_
Definition: pheeno_robot.h:43
std::vector< bool > color_state_facing_
Definition: pheeno_robot.h:67


pheeno_ros
Author(s): Zahi Kakish, Sean Wilson
autogenerated on Mon Jun 10 2019 14:10:48