forked from RoboCup-SSL/grSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
robot.h
104 lines (93 loc) · 2.81 KB
/
robot.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
grSim - RoboCup Small Size Soccer Robots Simulator
Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ROBOT_H
#define ROBOT_H
#include "Physics/pworld.h"
#include "Physics/pcylinder.h"
#include "Physics/pbox.h"
#include "Physics/pball.h"
#include "configwidget.h"
class Robot
{
PWorld* w;
PBall* m_ball;
dReal m_x,m_y,m_z;
dReal m_r,m_g,m_b;
dReal m_dir;
int m_rob_id;
bool firsttime;
bool last_state;
public:
ConfigWidget* cfg;
dSpaceID space;
PCylinder* chassis;
PBall* dummy;
dJointID dummy_to_chassis;
PBox* boxes[3];
bool on;
//these values are not controled by this class
bool selected;
dReal select_x,select_y,select_z;
QImage *img,*number;
class Wheel
{
public:
int id;
Wheel(Robot* robot,int _id,dReal ang,dReal ang2,int wheeltexid);
void step();
dJointID joint;
dJointID motor;
PCylinder* cyl;
dReal speed;
Robot* rob;
} *wheels[4];
class Kicker
{
private:
bool kicking;
int rolling;
int kickstate;
dReal m_kickspeed,m_kicktime;
public:
Kicker(Robot* robot);
void step();
void kick(dReal kickspeedx, dReal kickspeedz);
void setRoller(int roller);
int getRoller();
void toggleRoller();
bool isTouchingBall();
dJointID joint;
PBox* box;
Robot* rob;
} *kicker;
Robot(PWorld* world,PBall* ball,ConfigWidget* _cfg,dReal x,dReal y,dReal z,dReal r,dReal g,dReal b,int rob_id,int wheeltexid,int dir);
~Robot();
void step();
void drawLabel();
void setSpeed(int i,dReal s); //i = 0,1,2,3
void setSpeed(dReal vx, dReal vy, dReal vw);
dReal getSpeed(int i);
void incSpeed(int i,dReal v);
void resetSpeeds();
void resetRobot();
void getXY(dReal& x,dReal& y);
dReal getDir();
void setXY(dReal x,dReal y);
void setDir(dReal ang);
int getID();
PBall* getBall();
};
#define ROBOT_START_Z(cfg) (cfg->robotSettings.RobotHeight*0.5 + cfg->robotSettings.WheelRadius*1.1 + cfg->robotSettings.BottomHeight)
#endif // ROBOT_H