ChirpSim
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Friends
Macros
include
PhysicalObjects
chirp.h
Go to the documentation of this file.
1
#ifndef CHIRP_H
2
#define CHIRP_H
3
4
#include <QGraphicsItem>
5
#include <QSharedPointer>
6
#include <QVector>
7
8
#include <QPainter>
9
#include <QStyleOptionGraphicsItem>
10
#include <QWidget>
11
#include <QGraphicsScene>
12
#include <QJsonObject>
13
#include <QReadWriteLock>
14
15
#include "
robot.h
"
16
#include "
irsensor.h
"
17
#include "
world.h
"
18
#include "
physicalobject.h
"
19
20
class
Chirp
;
21
28
PhysicalObject
*
chirpFactory
(
World
*world,
const
QJsonObject &obj);
29
40
class
Chirp
:
public
Robot
,
public
PhysicalObject
,
public
QGraphicsItem
41
{
42
public
:
57
explicit
Chirp::Chirp
(b2World *world,
unsigned
id
, QPointF position,
float
startAngle,
float
noiseMax,
float
radius,
float
wheelDistance,
float
wheelRadius,
float
wheelWidth);
58
~Chirp
();
59
64
QRectF
boundingRect
()
const
;
65
69
void
paint
(QPainter *painter,
const
QStyleOptionGraphicsItem *option, QWidget *widget);
70
75
void
setSpeed
(QVector<float> speeds);
76
81
QVector<float>
sensors
()
const
;
82
87
b2Body *
body
()
const
{
return
_body
; }
88
93
QGraphicsItem *
item
()
const
{
return
const_cast<
Chirp
*
>
(
this
); }
94
102
void
step
(
float
dt);
103
107
void
stepGraphics
();
108
109
private
:
110
friend
PhysicalObject
*
chirpFactory
(
World
*world,
const
QJsonObject &obj);
111
112
// Helper functions for advance()
113
void
applyImpulses
();
114
void
removeLateralSpeed
();
115
116
// Helper functions for constructor
117
void
computeBoundingRect
();
118
void
createPhysicalBody
(QPointF position,
float
startAngle, b2World* world);
119
void
createSensors
();
120
private
:
121
b2Body*
_body
;
122
float
_halfWheelDistance
;
123
float
_wheelRadius
;
124
float
_wheelWidth
;
125
float
_radius
;
126
float
_noiseMax
;
127
128
quint32
_id
;
129
130
QRectF
_boundingRect
;
131
132
QVector<Sensor*>
_sensors
;
133
134
float
_leftWheelSpeed
;
135
float
_rightWheelSpeed
;
136
137
bool
_isSelected
;
138
};
139
140
#endif // CHIRP_H
Generated on Tue Jun 18 2013 18:44:13 for ChirpSim by
1.8.4