CodeSubWars 0.4.7b
CodeSubWars::CSWPySubmarine Class Reference

#include <CSWPySubmarine.h>

Inheritance diagram for CodeSubWars::CSWPySubmarine:

Public Member Functions

 CSWPySubmarine (std::string strName, double fLength)
 
virtual void initialize ()
 
virtual void update ()
 
virtual bool processEvent (std::shared_ptr< CSWEvent > pEvent)
 
virtual void finalize ()
 
std::shared_ptr< ARSTD::CommandProcessorgetCommandProcessor ()
 
std::shared_ptr< CSWEnginegetMainEngine ()
 
std::shared_ptr< CSWEnginegetBowsJetOar ()
 
std::shared_ptr< CSWEnginegetInclinationJetOar ()
 
std::shared_ptr< CSWEnginegetAxialInclinationJetOar ()
 
std::shared_ptr< CSWEnginegetBuoyancyTank ()
 
std::shared_ptr< CSWControlCentergetControlCenter ()
 
std::shared_ptr< CSWWeaponBatterygetFrontLeftWeaponBattery ()
 
std::shared_ptr< CSWWeaponBatterygetFrontRightWeaponBattery ()
 
std::shared_ptr< CSWWeaponBatterygetBackWeaponBattery ()
 
const double & getHealth () const
 
void setColor (const Vector4D &vecColor)
 
const Vector4D & getColor ()
 
Vector3D makeLocalDirection (const Vector3D &vecWorldTDirection)
 
Vector3D makeGlobalDirection (const Vector3D &vecObjectTDirection)
 
Vector3D makeLocalPosition (const Vector3D &vecWorldTPosition)
 
Vector3D makeGlobalPosition (const Vector3D &vecObjectTPosition)
 
- Public Member Functions inherited from CodeSubWars::CSWObject
const std::string & getName () const
 

Detailed Description

This is the base class for submarines defined in python. Submarines are the main actors in the world. Specialized submarines are defined in python. Therefore its behavior is very different. All submarines have the same equipment and the same types of weapons on bord. They are identically except its length. The length must be given in the constructor and must be in range [30, 110] m. The power of engines and the capacity of the weapon batteries is depend on the submarine length. Larger submarines have more powerful engines and a higher capacity of the weapon batteries. But larger submarines can be better hit and detected by sonar than smaller ones. Smaller ones are a bit faster in controlling rotation and position.
Submarines are equipped with:

  • Engines:
    • MainEngine: This engine is mounted at the back and is directed toward the front. Its function to let the submarin move forward or backward. Its direction can be changed within a range. The power is (depend on length $l$): $F_{max} [N] \approx l^3 * 90$
    • BuoyancyTank: This "engine" is mounted in the center and is directed up. Its function to let the submarin move up or down. The power is (depend on length $l$): $F_{max} [N] \approx l^3 * 0.12$
    • BowJetOar: This engine is mounted at the front and is directed to the right. Its function to let the submarin rotate leftside or rightside. The power is (depend on length $l$): $F_{max} [N] \approx l^3 * 4.4$

    • InclinationJetOar: This engine is mounted at the front and is directed up. Its function to let the submarin rotate upward or downward. The power is (depend on length $l$): $F_{max} [N] \approx l^3 * 4.4$

    • AxialInclinationJetOar: This engine is mounted at the middle top and is directed to the right. Its function to let the submarin rotate about his main axis. The power is (depend on length $l$): $F_{max} [N] \approx l^3 * 1.9$
  • Sensors:
    • ActiveSonar: This specialized active sonar is mounted in the center. The default scanning behavior is rotate horizontally. It scanning behavior can be defined.
    • PassiveSonar: This specialized passive sonar is mounted in the center. The default scanning behavior is rotate horizontally. It scanning behavior can be defined.
    • GPS: This gps system is mounted in the center.
    • GyroCompass: This compass is mounted in the center.
    • MovingPropertiesSensor: This sensor is mounted in the center.
  • Weapons:
  • Other:
    • Transceiver: This transceiver is mounted in the center.
    • Map: This map is mounted in the center. It handles reported position from active sonar.

Constructor & Destructor Documentation

◆ CSWPySubmarine()

CodeSubWars::CSWPySubmarine::CSWPySubmarine ( std::string  strName,
double  fLength 
)

Constructs a new submarine.

Parameters
strNameThe name of the new submarine.
fLengthThe length of the new submarine.
Warning
At this point the sensors have not correct values!

Member Function Documentation

◆ finalize()

virtual void CodeSubWars::CSWPySubmarine::finalize ( )
virtual

This method should be overriden if finalizations must be done. Its ensured that this method is called directly before destructing.

Reimplemented from CodeSubWars::CSWObject.

◆ getAxialInclinationJetOar()

std::shared_ptr< CSWEngine > CodeSubWars::CSWPySubmarine::getAxialInclinationJetOar ( )

Returns the axial inclination jet oar.

Returns
The axial inclination jet oar.

◆ getBackWeaponBattery()

std::shared_ptr< CSWWeaponBattery > CodeSubWars::CSWPySubmarine::getBackWeaponBattery ( )

Returns the back weapon battery.

Returns
The back weapon battery.

◆ getBowsJetOar()

std::shared_ptr< CSWEngine > CodeSubWars::CSWPySubmarine::getBowsJetOar ( )

Returns the bows jet oar.

Returns
The bows jet oar.

◆ getBuoyancyTank()

std::shared_ptr< CSWEngine > CodeSubWars::CSWPySubmarine::getBuoyancyTank ( )

Returns the buoyancy tank.

Returns
The buoyancy tank.

◆ getColor()

const Vector4D & CodeSubWars::CSWPySubmarine::getColor ( )
virtual

Returns the color of the object.

Returns
The red-green-blue-alpha - color of the object.

Reimplemented from CodeSubWars::CSWDynSolCol.

◆ getCommandProcessor()

std::shared_ptr< ARSTD::CommandProcessor > CodeSubWars::CSWPySubmarine::getCommandProcessor ( )
virtual

Returns the command processor. The behavior is like in real life your 1st commander. You (the captain) makes a list of commands that must be done. This list is given to the commander. He cares about the correct execution. Ones you give him the list of commands you are able to do other things while your commander do the execution.

Returns
The command processor.

Reimplemented from CodeSubWars::CSWSubmarine.

◆ getControlCenter()

std::shared_ptr< CSWControlCenter > CodeSubWars::CSWPySubmarine::getControlCenter ( )

Returns the control center.

Returns
The control center.

◆ getFrontLeftWeaponBattery()

std::shared_ptr< CSWWeaponBattery > CodeSubWars::CSWPySubmarine::getFrontLeftWeaponBattery ( )

Returns the front left weapon battery.

Returns
The front left weapon battery.

◆ getFrontRightWeaponBattery()

std::shared_ptr< CSWWeaponBattery > CodeSubWars::CSWPySubmarine::getFrontRightWeaponBattery ( )

Returns the front right weapon battery.

Returns
The front right weapon battery.

◆ getHealth()

const double & CodeSubWars::CSWPySubmarine::getHealth ( ) const
virtual

Returns the current health of the submarine.

Returns
The current health in range [0, 1] where 0 is dead and 1 is maximum.

Reimplemented from CodeSubWars::CSWDamDynSolCol.

◆ getInclinationJetOar()

std::shared_ptr< CSWEngine > CodeSubWars::CSWPySubmarine::getInclinationJetOar ( )

Returns the inclination jet oar.

Returns
The inclination jet oar.

◆ getMainEngine()

std::shared_ptr< CSWEngine > CodeSubWars::CSWPySubmarine::getMainEngine ( )

Returns the main engine.

Returns
The main engine.

◆ initialize()

virtual void CodeSubWars::CSWPySubmarine::initialize ( )
virtual

This method should be overriden if initializations must be done. Here all sensors return correct values. Its ensured that this method is called before any other method (except constructor) is called.

Reimplemented from CodeSubWars::CSWObject.

◆ makeGlobalDirection()

Vector3D CodeSubWars::CSWPySubmarine::makeGlobalDirection ( const Vector3D &  vecObjectTDirection)

Transforms a direction given in local coordinate system into the world coordinate system.

Parameters
vecObjectTDirectionThe direction in local coordinate system.
Returns
The direction in world coordinate system.

◆ makeGlobalPosition()

Vector3D CodeSubWars::CSWPySubmarine::makeGlobalPosition ( const Vector3D &  vecObjectTPosition)

Transforms a position given in local coordinate system into the world coordinate system.

Parameters
vecObjectTPositionThe position in local coordinate system.
Returns
The position in world coordinate system.

◆ makeLocalDirection()

Vector3D CodeSubWars::CSWPySubmarine::makeLocalDirection ( const Vector3D &  vecWorldTDirection)

Transforms a direction given in world coordinate system into the local system.

Parameters
vecWorldTDirectionThe direction in world coordinate system.
Returns
The direction in object coordinate system.

◆ makeLocalPosition()

Vector3D CodeSubWars::CSWPySubmarine::makeLocalPosition ( const Vector3D &  vecWorldTPosition)

Transforms a position given in world coordinate system into the local system.

Parameters
vecWorldTPositionThe position in world coordinate system.
Returns
The position in object coordinate system.

◆ processEvent()

virtual bool CodeSubWars::CSWPySubmarine::processEvent ( std::shared_ptr< CSWEvent pEvent)
virtual

This method must be overriden in the specialized class. This methode is called if an event has been received by the object that should be processed. Returning true reports the eventmanager that the event passed to the object has successfully processed and delete it. When returning false the event will be delivered the next time again until it expires or processed successfully. The main function should be reacting to events e.g. seting up commands or something like that. The specialized class can implement everything here, but the execution time must not exceed 6ms in average. If it does the object will be kicked from the world!

Parameters
pEventThe incoming event that should be processed.
Returns
True if the incoming event has been successfully processed. When returning false the event will be delivered next time again.

Reimplemented from CodeSubWars::CSWSubmarine.

◆ setColor()

void CodeSubWars::CSWPySubmarine::setColor ( const Vector4D &  vecColor)
virtual

Sets the color of the submarine.

Parameters
vecColorThe new red-green-blue-alpha - color. each color component in range [0, 1].

Reimplemented from CodeSubWars::CSWDynSolCol.

◆ update()

virtual void CodeSubWars::CSWPySubmarine::update ( )
virtual

This method must be overriden in the specialized class. This methode is called periodically about every 10ms. The main function should be checking sensors, seting up commands or something like that. The specialized class can implement everything here, but the execution time must not exceed 6ms in average. If it does the object will be kicked from the world!

Reimplemented from CodeSubWars::CSWSubmarine.


Generated at Sun Aug 7 2022 for project CodeSubWars. www.codesubwars.org