3 #include "measurement.h"
6 b2Fixture * GetSensor(b2Body * body);
9 b2Body * GetDisturbance(b2World *);
14 bool overlaps(
const b2PolygonShape&,
Disturbance *,
const b2Transform& robot_pose=b2Transform_zero);
17 void world_cleanup(b2World & _world);
25 b2Transform start=b2Transform_zero;
27 Direction direction= DEFAULT;
29 AffordanceIndex affordance=NONE;
35 float linearSpeed=WHEEL_SPEED_DEFAULT*2;
38 float R=WHEEL_SPEED_DEFAULT;
39 float L=WHEEL_SPEED_DEFAULT;
46 void init(Direction& direction){
48 case Direction::DEFAULT:
49 L=WHEEL_SPEED_DEFAULT;
50 R=WHEEL_SPEED_DEFAULT;
56 case Direction::RIGHT:
69 void setVelocities(
const float & l,
const float &r){
70 omega = (MAX_SPEED*(r-l)/BETWEEN_WHEELS);
72 linearSpeed = MAX_SPEED*(l+r)/2;
77 b2Vec2 getLinearVelocity(
const float &dt=1)
const{
79 velocity.x = linearSpeed *cos(omega)*dt;
80 velocity.y = linearSpeed *sin(omega)*dt;
84 b2Transform getTransform(
const float &dt=1)
const{
85 return b2Transform(getLinearVelocity(dt), b2Rot(getOmega(dt)));
88 float getRWheelSpeed()
const{
92 float getLWheelSpeed()
const{
96 void setRWheelSpeed(
float f){
100 void setLWheelSpeed(
float f){
108 float getLinearSpeed(){
112 float getOmega(
const float &dt=1)
const{
122 float getOmega(
const float l,
const float r,
float dt=1)
const{
123 float result = (MAX_SPEED*(r-l)/BETWEEN_WHEELS)*TURN_FRICTION*dt;
127 void setOmega(
const float &o){
131 void setLinearSpeed(
const float & s){
143 std::vector <b2Body*> collisions;
147 void BeginContact(b2Contact * contact) {
148 b2Fixture * fixtureA= contact->GetFixtureA();
149 b2Fixture * fixtureB= contact->GetFixtureB();
150 b2BodyUserData bodyData = fixtureA->GetBody()->GetUserData();
151 if (bodyData.pointer==ROBOT_FLAG) {
152 b2Body * other = contact->GetFixtureB()->GetBody();
153 if (fixtureA->IsSensor()){
154 if (other->GetUserData().pointer==DISTURBANCE_FLAG){
159 if (fixtureB->IsSensor()){
162 collisions.push_back(other);
164 bodyData = fixtureB->GetBody()->GetUserData();
165 if (bodyData.pointer==ROBOT_FLAG) {
166 b2Body * other = contact->GetFixtureA()->GetBody();
167 if (fixtureB->IsSensor()){
168 if (other->GetUserData().pointer==DISTURBANCE_FLAG){
173 if (fixtureA->IsSensor()){
176 collisions.push_back(other);
180 std::vector <b2Body*> get_collisions(){
189 AffordanceIndex getAffIndex(){
203 Direction
H(
Disturbance ob, Direction d,
bool topDown=0);
206 void setEndCriteria(
const Angle& angle=SAFE_ANGLE,
const Distance& distance=BOX2DRANGE);
208 void setEndCriteria(
const Distance& distance);
224 EndedResult checkEnded(b2Transform robotTransform= b2Transform_zero, Direction dir=UNDEFINED,
bool relax=0, b2Body* robot=NULL, std::pair<bool,b2Transform> use_start= std::pair <bool,b2Transform>(1, b2Transform_zero));
235 EndedResult checkEnded(
const State& n, Direction dir=UNDEFINED,
bool relax=
false, std::pair<bool,b2Transform> use_start= std::pair <bool,b2Transform>(1, b2Transform_zero));
246 bool checkEnded(
const b2PolygonShape &box,
const b2Transform& robot_pose=b2Transform_zero,
Disturbance * dist_obs=NULL );
249 start = b2Transform(b2Vec2(0.0, 0.0), b2Rot(0));
251 action.init(direction);
256 action.init(direction);
259 Task(
Disturbance ob, Direction d, b2Transform _start=b2Transform(b2Vec2(0.0, 0.0), b2Rot(0.0)),
bool topDown=0){
262 affordance=disturbance.getAffIndex();
263 direction =
H(disturbance, d, topDown);
264 action.init(direction);
286 b2Transform from_Di(
const b2Transform * custom_start=NULL,
Disturbance * d_obs=NULL);
288 void set_change(
bool b){
303 return change || motorStep==0;
319 void setMotorStep(
int i){
323 int & getMotorStep(){
return motorStep;}
325 b2Transform getStart(){
329 b2Transform& getStartRef(){
333 Direction get_direction(){
337 void set_direction(Direction d){
Definition: measurement.h:44
Definition: configurator.h:17
Definition: measurement.h:52
Direction H(Disturbance ob, Direction d, bool topDown=0)
Agent transfer function H which generates a motor output (Action) in response to a disturbance.
Definition: task.cpp:175
EndedResult checkEnded(b2Transform robotTransform=b2Transform_zero, Direction dir=UNDEFINED, bool relax=0, b2Body *robot=NULL, std::pair< bool, b2Transform > use_start=std::pair< bool, b2Transform >(1, b2Transform_zero))
Check if this task has ended based on state information (default are info for the task which calls th...
Definition: task.cpp:240
simResult bumping_that(b2World &_world, int iteration, b2Body *, float remaining=SIM_DURATION)
Executes this task in a Box2D simulation.
Definition: task.cpp:59
Disturbance * get_disturbance_ptr()
Get a pointer to the disturbance.
Definition: task.h:311
bool is_over()
If task has finished executing.
Definition: task.h:302
Definition: disturbance.h:112
Definition: measurement.h:60
Definition: measurement.h:74
Hybrid states in the transition system.
Definition: graphTools.h:69
float getOmega(const float l, const float r, float dt=1) const
Uses kinematic model to calculate angle.
Definition: task.h:122
Definition: disturbance.h:268