feito

Dependencies:   BufferedSerial

Committer:
josefg25
Date:
Thu May 20 16:18:59 2021 +0000
Revision:
9:d0ef39e209b7
Parent:
7:206792eb84c8
SRA_update

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yaaqobhpt 0:c25c4b67b6a1 1 /** @file */
yaaqobhpt 0:c25c4b67b6a1 2 #ifndef ROBOT_H_
yaaqobhpt 0:c25c4b67b6a1 3 #define ROBOT_H_
yaaqobhpt 0:c25c4b67b6a1 4
yaaqobhpt 0:c25c4b67b6a1 5 #include "mbed.h"
josefg25 5:31605c9c05f8 6 #include "Robot.cpp"
yaaqobhpt 0:c25c4b67b6a1 7
josefg25 7:206792eb84c8 8 //I2C i2c;
yaaqobhpt 0:c25c4b67b6a1 9 extern int16_t countsLeft;
yaaqobhpt 0:c25c4b67b6a1 10 extern int16_t countsRight;
yaaqobhpt 0:c25c4b67b6a1 11
josefg25 9:d0ef39e209b7 12 typedef struct{
josefg25 9:d0ef39e209b7 13 //Robot properties
josefg25 9:d0ef39e209b7 14 float worldTrobot[3][3];
josefg25 9:d0ef39e209b7 15 //Wheels properties
josefg25 9:d0ef39e209b7 16 float nWheels;
josefg25 9:d0ef39e209b7 17 float robotTwheels;
josefg25 9:d0ef39e209b7 18 float wheels2Twheels;
josefg25 9:d0ef39e209b7 19 float wheelsPoints;
josefg25 9:d0ef39e209b7 20 float hWheels;
josefg25 9:d0ef39e209b7 21 //Platform properties
josefg25 9:d0ef39e209b7 22 float platformRadius;
josefg25 9:d0ef39e209b7 23 float hPlatform;
josefg25 9:d0ef39e209b7 24 }Robot;
josefg25 4:0fac5e5d08f7 25
josefg25 6:af79dc3c6fc2 26 void getPose(struct Robot Robot,float *pose);
josefg25 3:892592b2c2ea 27
josefg25 3:892592b2c2ea 28 void velRobot2velWheels(float vRobot,float wRobot,float wheelsRadius,float wheelsDistance,float *w);
josefg25 3:892592b2c2ea 29
josefg25 3:892592b2c2ea 30 void nextPose(float T,float w,float wRobot,float *poseRobot,float wheelsRadius,float wheelsDistance,float *nextPose);
josefg25 3:892592b2c2ea 31
josefg25 5:31605c9c05f8 32 void robot_init(struct Robot *r, float rPos_a[],float rTheta,float nW);
josefg25 3:892592b2c2ea 33
josefg25 5:31605c9c05f8 34 void occupancy_grid_mapping(int *log_mapa[40][40], float d,float theta,float actual_x,float actual_y,float angle,int i,int j);
josefg25 3:892592b2c2ea 35
josefg25 7:206792eb84c8 36 void ComputeLidarPoint(float *pose, float *PointDetected, float distance, float angle);
josefg25 3:892592b2c2ea 37
josefg25 4:0fac5e5d08f7 38 int inverse_range_sensor_model(float d,float theta,float atual_x,float atual_y,float cell_x,float cell_y);
josefg25 3:892592b2c2ea 39
josefg25 3:892592b2c2ea 40 void setPose(Robot *r, float *pose);
yaaqobhpt 0:c25c4b67b6a1 41 /** \brief Sets the speed for both motors.
yaaqobhpt 0:c25c4b67b6a1 42 *
yaaqobhpt 0:c25c4b67b6a1 43 * \param leftSpeed A number from -300 to 300 representing the speed and
yaaqobhpt 0:c25c4b67b6a1 44 * direction of the left motor. Values of -300 or less result in full speed
yaaqobhpt 0:c25c4b67b6a1 45 * reverse, and values of 300 or more result in full speed forward.
yaaqobhpt 0:c25c4b67b6a1 46 * \param rightSpeed A number from -300 to 300 representing the speed and
yaaqobhpt 0:c25c4b67b6a1 47 * direction of the right motor. Values of -300 or less result in full speed
yaaqobhpt 0:c25c4b67b6a1 48 * reverse, and values of 300 or more result in full speed forward. */
yaaqobhpt 0:c25c4b67b6a1 49 void setSpeeds(int16_t leftSpeed, int16_t rightSpeed);
yaaqobhpt 0:c25c4b67b6a1 50
yaaqobhpt 0:c25c4b67b6a1 51 /** \brief Sets the speed for the left motor.
yaaqobhpt 0:c25c4b67b6a1 52 *
yaaqobhpt 0:c25c4b67b6a1 53 * \param speed A number from -300 to 300 representing the speed and
yaaqobhpt 0:c25c4b67b6a1 54 * direction of the left motor. Values of -300 or less result in full speed
yaaqobhpt 0:c25c4b67b6a1 55 * reverse, and values of 300 or more result in full speed forward. */
yaaqobhpt 0:c25c4b67b6a1 56 void setLeftSpeed(int16_t speed);
yaaqobhpt 0:c25c4b67b6a1 57
yaaqobhpt 0:c25c4b67b6a1 58 /** \brief Sets the speed for the right motor.
yaaqobhpt 0:c25c4b67b6a1 59 *
yaaqobhpt 0:c25c4b67b6a1 60 * \param speed A number from -300 to 300 representing the speed and
yaaqobhpt 0:c25c4b67b6a1 61 * direction of the right motor. Values of -300 or less result in full speed
yaaqobhpt 0:c25c4b67b6a1 62 * reverse, and values of 300 or more result in full speed forward. */
yaaqobhpt 0:c25c4b67b6a1 63 void setRightSpeed(int16_t speed);
yaaqobhpt 0:c25c4b67b6a1 64
yaaqobhpt 0:c25c4b67b6a1 65 /*! Returns the number of counts that have been detected from the both
yaaqobhpt 0:c25c4b67b6a1 66 * encoders. These counts start at 0. Positive counts correspond to forward
yaaqobhpt 0:c25c4b67b6a1 67 * movement of the wheel of the Romi, while negative counts correspond
yaaqobhpt 0:c25c4b67b6a1 68 * to backwards movement.
yaaqobhpt 0:c25c4b67b6a1 69 *
yaaqobhpt 0:c25c4b67b6a1 70 * The count is returned as a signed 16-bit integer. When the count goes
yaaqobhpt 0:c25c4b67b6a1 71 * over 32767, it will overflow down to -32768. When the count goes below
yaaqobhpt 0:c25c4b67b6a1 72 * -32768, it will overflow up to 32767. */
yaaqobhpt 0:c25c4b67b6a1 73 void getCounts();
yaaqobhpt 0:c25c4b67b6a1 74
yaaqobhpt 0:c25c4b67b6a1 75 /*! This function is just like getCounts() except it also clears the
yaaqobhpt 0:c25c4b67b6a1 76 * counts before returning. If you call this frequently enough, you will
yaaqobhpt 0:c25c4b67b6a1 77 * not have to worry about the count overflowing. */
yaaqobhpt 0:c25c4b67b6a1 78 void getCountsAndReset();
yaaqobhpt 0:c25c4b67b6a1 79
yaaqobhpt 0:c25c4b67b6a1 80 #endif /* ROBOT_H_ */
josefg25 5:31605c9c05f8 81