Commit 7749594d authored by Arnaud Cadot's avatar Arnaud Cadot

- Fixed warnings in robot.cpp

- Updated FishingNet class
- Added doc du FishingNet class
parent 08760aa5
......@@ -105,7 +105,7 @@ HEADERS += \
../../include/vector.h \
../../include/strategie/krabijunior2016.h \
../../include/strategie/krabi2016.h \
../../stm32/include/actionneurs/fishingNet.h
../../include/actionneurs/fishingNet.h
SOURCES += \
......
#ifndef FICHINGNET_H
#define FICHINGNET_H
/**
* @brief This singleton class handles the fishing net actuator.
* @see getSingleton
*/
class FishingNet
{
/**
* The ID of the innermost AX12 (i.e. for rotation)
*/
static const int SERVO_INT_ID = 0; // To update
/**
* The ID of the outermost AX12 (i.e. for folding/unfolding)
*/
static const int SERVO_EXT_ID = 1;
/**
* Those constantes are angles sent to the relevant servos for the relevant action (names are pretty explicit)
*/
static const int SERVO_EXT_CLOSED_POS = 0x00;
static const int SERVO_EXT_DEPLOYED_POS = 0x00;
static const int SERVO_EXT_RAISED_POS = 0x00;
......@@ -13,9 +26,7 @@ class FishingNet
static const int SERVO_INT_RAISED_POS = 0x00;
static const int SERVO_INT_LOWERED_POS = 0x00;
public:
FishingNet();
public:
enum NET_STATE
{
CLOSED,
......@@ -24,21 +35,69 @@ class FishingNet
NET_LOWERED
};
/**
* @brief FishingNet is a singleton. This static method will return the only possible instance of FishingNet (and create it if deemed necessary)
*/
static FishingNet* getSingleton();
/**
* @brief Closes the arm (folds it against the robot)
*/
void close();
/**
* @brief Deploys the arm and gets the net ready to fish
*/
void deploy();
/**
* @brief Lower the net (start to fish)
*/
void lowerNet();
/**
* @brief Raise the net (finnish fishing)
*/
void raiseNet();
/**
* @brief Raise the net's arm (to avoid hitting the tank's sides)
*/
void raiseArm();
/**
* @brief Returns the current software state of the device. Note it may not reflect the actual positions of the servos.
* @see NET_STATE
*/
NET_STATE getCurrentState() const;
private:
/**
* @brief Constructor
* @see getSingleton
*/
FishingNet();
/**
* @brief Move (i.e. lower or raise) the arm to a set angle
* @param destAngle The angle (as used by the AX12)
*/
void moveArm(int destAngle);
/**
* @brief Rotate (i.e. turn on itself) the arm to a set angle
* @param destAngle The angle (as used by the AX12)
*/
void rotateArm(int destAngle);
/**
* @brief The software state of this device may not reflect its hardware state (servo locked, etc.).
*
* This function will NOT move the servos, do not call it directly.
* @param The new software state of the device
*/
void setCurrentState(NET_STATE state);
NET_STATE m_currentState;
};
......
......@@ -36,25 +36,40 @@ void FishingNet::close()
{
rotateArm(SERVO_INT_RAISED_POS);
moveArm(SERVO_EXT_CLOSED_POS);
setCurrentState(CLOSED);
}
void FishingNet::deploy()
{
moveArm(SERVO_EXT_DEPLOYED_POS);
rotateArm(SERVO_INT_RAISED_POS);
setCurrentState(OPENED);
}
void FishingNet::lowerNet()
{
rotateArm(SERVO_INT_LOWERED_POS);
setCurrentState(NET_LOWERED);
}
void FishingNet::raiseNet()
{
rotateArm(SERVO_INT_RAISED_POS);
setCurrentState(OPENED);
}
void FishingNet::raiseArm()
{
moveArm(SERVO_EXT_RAISED_POS);
setCurrentState(RAISED);
}
void FishingNet::setCurrentState(NET_STATE state)
{
m_currentState = state;
}
FishingNet::NET_STATE FishingNet::getCurrentState() const
{
return m_currentState;
}
......@@ -12,7 +12,7 @@
#define ratio_qt_box2d 0.01
Robot::Robot(b2World & world, bool manual, bool isYellow) : world(world), olds(10000), mRemoteMod(false), body(NULL)
Robot::Robot(b2World & world, bool manual, bool isYellow) : world(world), olds(10000), body(NULL), mRemoteMod(false)
{
this->manual = manual;
level = 0;
......@@ -92,7 +92,7 @@ Robot::Robot(b2World & world, bool manual, bool isYellow) : world(world), olds(1
// 2dbox limite à 8 le nombre de vertex par polygone
inc = 0;
for(int i = 0; i < robotPolygonPoints.size(); i += 1)
for(size_t i = 0; i < robotPolygonPoints.size(); i += 1)
{
v[0].Set(0., 0.);
v[1].Set(robotPolygonPoints[i].x() * ratio_qt_box2d, robotPolygonPoints[i].y() * ratio_qt_box2d);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment