root / scout / scoutsim / include / scoutsim / scout.h @ 266ae7f2
History | View | Annotate | Download (3.21 KB)
1 |
/*
|
---|---|
2 |
* This package was developed by the CMU Robotics Club project using code
|
3 |
* from Willow Garage, Inc. Please see licensing.txt for details.
|
4 |
*
|
5 |
* All rights reserved.
|
6 |
*
|
7 |
* @file scout.h
|
8 |
* @author Colony Project, CMU Robotics Club
|
9 |
* @author Alex Zirbel
|
10 |
*/
|
11 |
|
12 |
#ifndef SCOUTSIM_SCOUT_H
|
13 |
#define SCOUTSIM_SCOUT_H
|
14 |
|
15 |
#include <ros/ros.h> |
16 |
#include <boost/shared_ptr.hpp> |
17 |
|
18 |
#include <scoutsim/Pose.h> |
19 |
#include <scoutsim/Velocity.h> |
20 |
#include <scoutsim/SetPen.h> |
21 |
#include <scoutsim/TeleportRelative.h> |
22 |
#include <scoutsim/TeleportAbsolute.h> |
23 |
#include <scoutsim/Color.h> |
24 |
|
25 |
#include <wx/wx.h> |
26 |
|
27 |
#define PI 3.14159265 |
28 |
|
29 |
namespace scoutsim |
30 |
{ |
31 |
|
32 |
struct Vector2
|
33 |
{ |
34 |
Vector2() |
35 |
: x(0.0) |
36 |
, y(0.0) |
37 |
{} |
38 |
|
39 |
Vector2(float _x, float _y) |
40 |
: x(_x) |
41 |
, y(_y) |
42 |
{} |
43 |
|
44 |
bool operator==(const Vector2& rhs) |
45 |
{ |
46 |
return x == rhs.x && y == rhs.y;
|
47 |
} |
48 |
|
49 |
bool operator!=(const Vector2& rhs) |
50 |
{ |
51 |
return x != rhs.x || y != rhs.y;
|
52 |
} |
53 |
|
54 |
float x;
|
55 |
float y;
|
56 |
}; |
57 |
|
58 |
class Scout |
59 |
{ |
60 |
public:
|
61 |
Scout(const ros::NodeHandle& nh, const wxImage& scout_image, |
62 |
const Vector2& pos, float orient); |
63 |
|
64 |
void update(double dt, wxMemoryDC& path_dc, |
65 |
const wxImage& path_image, wxColour background_color,
|
66 |
float canvas_width, float canvas_height); |
67 |
void paint(wxDC& dc);
|
68 |
|
69 |
private:
|
70 |
void velocityCallback(const VelocityConstPtr& vel); |
71 |
bool setPenCallback(scoutsim::SetPen::Request&,
|
72 |
scoutsim::SetPen::Response&); |
73 |
bool teleportRelativeCallback(scoutsim::TeleportRelative::Request&,
|
74 |
scoutsim::TeleportRelative::Response&); |
75 |
bool teleportAbsoluteCallback(scoutsim::TeleportAbsolute::Request&,
|
76 |
scoutsim::TeleportAbsolute::Response&); |
77 |
|
78 |
ros::NodeHandle nh_; |
79 |
|
80 |
wxImage scout_image_; |
81 |
wxBitmap scout_; |
82 |
|
83 |
Vector2 pos_; |
84 |
float orient_;
|
85 |
|
86 |
float lin_vel_;
|
87 |
float ang_vel_;
|
88 |
bool pen_on_;
|
89 |
wxPen pen_; |
90 |
|
91 |
ros::Subscriber velocity_sub_; |
92 |
ros::Publisher pose_pub_; |
93 |
ros::Publisher color_pub_; |
94 |
ros::ServiceServer set_pen_srv_; |
95 |
ros::ServiceServer teleport_relative_srv_; |
96 |
ros::ServiceServer teleport_absolute_srv_; |
97 |
|
98 |
ros::WallTime last_command_time_; |
99 |
|
100 |
float meter_;
|
101 |
|
102 |
struct TeleportRequest
|
103 |
{ |
104 |
TeleportRequest(float x, float y, float _theta, |
105 |
float _linear, bool _relative) |
106 |
: pos(x, y) |
107 |
, theta(_theta) |
108 |
, linear(_linear) |
109 |
, relative(_relative) |
110 |
{} |
111 |
|
112 |
Vector2 pos; |
113 |
float theta;
|
114 |
float linear;
|
115 |
bool relative;
|
116 |
}; |
117 |
|
118 |
typedef std::vector<TeleportRequest> V_TeleportRequest;
|
119 |
V_TeleportRequest teleport_requests_; |
120 |
}; |
121 |
typedef boost::shared_ptr<Scout> ScoutPtr;
|
122 |
|
123 |
} |
124 |
|
125 |
#endif
|