Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VLC #56

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

VLC #56

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Empty file modified Library/include/StonefishCommon.h
100644 → 100755
Empty file.
Empty file modified Library/include/actuators/Actuator.h
100644 → 100755
Empty file.
Empty file modified Library/include/actuators/ActuatorDynamics.h
100644 → 100755
Empty file.
Empty file modified Library/include/actuators/DCMotor.h
100644 → 100755
Empty file.
Empty file modified Library/include/actuators/JointActuator.h
100644 → 100755
Empty file.
2 changes: 2 additions & 0 deletions Library/include/actuators/Light.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ namespace sf
//! A method returning the type of the actuator.
ActuatorType getType() const;

OpenGLLight* getGLLight();

private:
void InitGraphics();

Expand Down
Empty file modified Library/include/actuators/LinkActuator.h
100644 → 100755
Empty file.
Empty file modified Library/include/actuators/Motor.h
100644 → 100755
Empty file.
Empty file modified Library/include/actuators/Propeller.h
100644 → 100755
Empty file.
Empty file modified Library/include/actuators/Push.h
100644 → 100755
Empty file.
Empty file modified Library/include/actuators/Rudder.h
100644 → 100755
Empty file.
Empty file modified Library/include/actuators/Servo.h
100644 → 100755
Empty file.
Empty file modified Library/include/actuators/SimpleThruster.h
100644 → 100755
Empty file.
Empty file modified Library/include/actuators/SuctionCup.h
100644 → 100755
Empty file.
Empty file modified Library/include/actuators/Thruster.h
100644 → 100755
Empty file.
Empty file modified Library/include/actuators/VariableBuoyancy.h
100644 → 100755
Empty file.
Empty file modified Library/include/comms/AcousticModem.h
100644 → 100755
Empty file.
17 changes: 16 additions & 1 deletion Library/include/comms/Comm.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,39 @@
#include <SDL2/SDL_mutex.h>
#include <deque>
#include "StonefishCommon.h"
#include <variant>

namespace sf
{
//! An enum defining types of comms.
enum class CommType {RADIO, ACOUSTIC, USBL, VLC};
enum class CommType {RADIO, ACOUSTIC, USBL, VLC, OPTIC};

struct Renderable;
class Entity;
class StaticEntity;
class MovingEntity;

struct Point {
float x, y, z;
float intensity;
};

struct PointCloud {
std::vector<Point> points;
std::string frame_id;
double timestamp;
};

struct CommDataFrame
{
using DataType = std::variant<int, float, double, std::string, std::vector<uint8_t>, std::vector<float>, std::vector<double>, PointCloud>;

Scalar timeStamp;
uint64_t seq;
uint64_t source;
uint64_t destination;
std::string data;
DataType data_mission;
};

//! An abstract class representing a communication device.
Expand Down
Empty file modified Library/include/comms/USBL.h
100644 → 100755
Empty file.
Empty file modified Library/include/comms/USBLReal.h
100644 → 100755
Empty file.
Empty file modified Library/include/comms/USBLSimple.h
100644 → 100755
Empty file.
127 changes: 127 additions & 0 deletions Library/include/comms/VLC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
This file is a part of Stonefish.

Stonefish 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.

Stonefish 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 <https://www.gnu.org/licenses/>.
*/

//
// VLC.h
// Stonefish

#ifndef __Stonefish_VLC__
#define __Stonefish_VLC__

#include "actuators/Light.h"
#include "comms/Comm.h"
#include "graphics/OpenGLDataStructs.h"
#include <map>

namespace sf
{
class Light;
class StaticEntity;
class AnimatedEntity;

//! A class representing a light of two common types: omni and spot.
class VLC : public Comm
{
public:
//! A constructor of an omni light.
/*!
\param uniqueName a name of the light
\param radius a radius of the light source [m]
\param color a color of the light
\param lum the luminous power of the light [lm]
*/
VLC(std::string uniqueName, uint64_t deviceId, Scalar minVerticalFOVDeg, Scalar maxVerticalFOVDeg, Scalar range, Scalar comm_speed);

void SendMessage(std::string data, const CommDataFrame::DataType& data_mission);
//! A constructor of a spot light.
/*!
\param uniqueName a name of the light
\param radius a radius of the light source [m]
\param coneAngleDeg a cone angle of the spot light in degrees [deg]
\param color a color of the light
\param lum the luminous power of the light [lm]
*/

//! A method used to attach the comm device to the world origin.
/*!
\param origin the place where the comm should be attached in the world frame
*/
/*!
\param dt a time step of the simulation
*/
virtual void InternalUpdate(Scalar dt);

//! A method implementing the rendering of the light dummy.
std::vector<Renderable> Render();

//! A method returning the type of the actuator.
CommType getType() const;

std::vector<Light*> getLights();

void SwitchOff();

void SwitchOn();

bool isActive();

void enable(bool t);

Scalar getRange();

void setRange(Scalar r);

Scalar getCommSpeed();

void setCommSpeed(Scalar r);

void addLight(Light* l);

bool getOcclusionTest() const;
CommDataFrame* getData();
void setWaterType(Scalar t);



protected:

virtual void ProcessMessages();
static VLC* getNode(uint64_t deviceId);

private:

Scalar R;
Scalar Fi;
Scalar coneAngle;
std::vector<Light*> lights;
Scalar minFov2, maxFov2;
bool active;
Scalar range;
Scalar comm_speed;
static std::vector<uint64_t> getNodeIds();
static bool mutualContact(uint64_t device1Id, uint64_t device2Id);
bool isReceptionPossible(Vector3 dir, Scalar distance);
bool occlusion;
static std::map<uint64_t, VLC*> nodes;
CommDataFrame* data;
Scalar water_type;


};
}

#endif
40 changes: 40 additions & 0 deletions Library/include/core/Battery.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef BATTERY_H
#define BATTERY_H

#include <vector>
#include "sensors/Sensor.h"
#include <iostream>

namespace sf
{

class Battery
{
private:
float voltage; // Battery voltage in volts
float capacity; // Battery capacity in ampere-hours (Ah)
float maxCapacity; // Maximum battery capacity in ampere-hours
double powerDraw; // Current power draw in watts (calculated)
double energyRemaining; // Energy remaining in watt-hours (Wh)

public:
Battery(float voltage, float capacity);

// Copy Constructor
Battery(const Battery& other);

// Assignment Operator
Battery& operator=(const Battery& other);

float getVoltage() const;
float getCapacity() const;
double getEnergyRemaining() const;
void consume(const std::vector<Sensor*>& sensors, float timeStep); // timeStep in seconds
void setVoltage(Scalar v);
void setMaxCapacity(Scalar mc);
};

} // namespace sf

#endif // BATTERY_H

Empty file modified Library/include/core/Console.h
100644 → 100755
Empty file.
Empty file modified Library/include/core/ConsoleSimulationApp.h
100644 → 100755
Empty file.
Empty file modified Library/include/core/FeatherstoneRobot.h
100644 → 100755
Empty file.
Empty file modified Library/include/core/FilteredCollisionDispatcher.h
100644 → 100755
Empty file.
Empty file modified Library/include/core/GeneralRobot.h
100644 → 100755
Empty file.
Empty file modified Library/include/core/GraphicalSimulationApp.h
100644 → 100755
Empty file.
Empty file modified Library/include/core/MaterialManager.h
100644 → 100755
Empty file.
Empty file modified Library/include/core/NED.h
100644 → 100755
Empty file.
Empty file modified Library/include/core/NameManager.h
100644 → 100755
Empty file.
54 changes: 52 additions & 2 deletions Library/include/core/Robot.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <utility>
#include "StonefishCommon.h"
#include "joints/Joint.h"
#include "Battery.h"

namespace sf
{
Expand Down Expand Up @@ -82,6 +83,21 @@ namespace sf
void DefineRevoluteJoint(std::string jointName, std::string parentName, std::string childName, const Transform& origin,
const Vector3& axis, std::pair<Scalar, Scalar> positionLimits = std::make_pair(Scalar(1), Scalar(-1)), Scalar damping = Scalar(-1));

//! A method used to define a spherical joint between two mechanical parts of the robot.
/*!
\param jointName a name for the joint
\param parentName a name of the parent link
\param childName a name of the child link
\param origin frame of the joint
\param axis an axis of the joint
\param positionLimits a pair of min and max limit of joint position (if min > max then joint has no limits)
\param damping joint motion damping (works when there is no actuator attached to the joint)
*/
void DefineSphericalJoint(std::string jointName, std::string parentName, std::string childName, const Transform& origin,
const Vector3& axis, std::pair<Scalar, Scalar> positionLimits = std::make_pair(Scalar(1), Scalar(-1)), Scalar damping = Scalar(-1));



//! A method used to define a prismatic joint between two mechanical parts of the robot.
/*!
\param jointName a name for the joint
Expand Down Expand Up @@ -138,7 +154,7 @@ namespace sf
\param actuatedLinkName a name of the link which is to be actuated
\param origin a transformation from the link origin to the actuator frame
*/
virtual void AddLinkActuator(LinkActuator* a, const std::string& actuatedLinkName, const Transform& origin);
void AddLinkActuator(LinkActuator* a, const std::string& actuatedLinkName, const Transform& origin);

//! A method used to attach an actuator to a specified joint of the robot.
/*!
Expand All @@ -156,6 +172,14 @@ namespace sf
*/
void AddComm(Comm* c, const std::string& attachmentLinkName, const Transform& origin);

//VISUAL EFFECTS
//! A method used to attach a visual to a specified link of the robot.
/*!
\param v a pointer to a visual object
\param attachmentLinkName a name of the link to which the visual is attached
\param origin a transformation from the link origin to the visual frame
*/

//GENERAL
//! A method adding the robot to the simulation world (includes consistency checking).
/*!
Expand Down Expand Up @@ -212,7 +236,14 @@ namespace sf
\return a pointer to the comm object
*/
Comm* getComm(size_t index);



//! A method returning a pointer to the visual by index.
/*!
\param index the id of the visual
\return a pointer to the visual object
*/

//! A method returning a pointer to the base link solid.
SolidEntity* getBaseLink();

Expand All @@ -239,6 +270,22 @@ namespace sf
//! A method returning type of algorithm used for the robot.
virtual RobotType getType() const = 0;

Battery* getBattery();

void setBattery(Battery* b);

unsigned short getPort();

std::string getIPaddress();

void setPort(unsigned short p);

void setIPaddress(std::string ip);


std::vector<Sensor*> getSensors();
std::vector<Actuator*> getActuators();

protected:
struct JointData
{
Expand All @@ -260,6 +307,9 @@ namespace sf
std::vector<Comm*> comms;
std::string name;
bool fixed;
Battery* battery;
unsigned short port;
std::string ip_address;
};
}

Expand Down
4 changes: 3 additions & 1 deletion Library/include/core/ScenarioParser.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace sf
{
class SimulationManager;
class Robot;
class Battery;
class Entity;
class SolidEntity;
class Sensor;
Expand Down Expand Up @@ -279,7 +280,8 @@ namespace sf
\return full file path
*/
std::string GetFullPath(const std::string& path);


virtual bool ParseBattery(XMLElement* element, Battery* battery);
//! A method informing if the simulation is working in graphical mode.
bool isGraphicalSim();

Expand Down
Empty file modified Library/include/core/ScrewConstraint.h
100644 → 100755
Empty file.
Empty file modified Library/include/core/SimulationApp.h
100644 → 100755
Empty file.
Empty file modified Library/include/core/SimulationManager.h
100644 → 100755
Empty file.
Empty file modified Library/include/core/TorusShape.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/AnimatedEntity.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/Entity.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/FeatherstoneEntity.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/ForcefieldEntity.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/MovingEntity.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/SolidEntity.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/StaticEntity.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/animation/BSTrajectory.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/animation/CRTrajectory.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/animation/ManualTrajectory.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/animation/PWLTrajectory.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/animation/Trajectory.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/forcefields/Atmosphere.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/forcefields/Jet.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/forcefields/Ocean.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/forcefields/Pipe.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/forcefields/Stream.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/forcefields/Trigger.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/forcefields/Uniform.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/forcefields/VelocityField.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/solids/Box.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/solids/Compound.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/solids/Cylinder.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/solids/Polyhedron.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/solids/Sphere.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/solids/Torus.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/solids/Wing.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/statics/Obstacle.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/statics/Plane.h
100644 → 100755
Empty file.
Empty file modified Library/include/entities/statics/Terrain.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/GLSLShader.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/IMGUI.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLAtmosphere.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLCamera.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLConsole.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLContent.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLDataStructs.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLDebugDrawer.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLDepthCamera.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLFLS.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLFlatOcean.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLLight.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLMSIS.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLOcean.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLOceanParticles.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLParticles.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLPipeline.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLPointLight.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLPrinter.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLRealCamera.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLRealOcean.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLSSS.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLSonar.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLSpotLight.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLState.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLTrackball.h
100644 → 100755
Empty file.
Empty file modified Library/include/graphics/OpenGLView.h
100644 → 100755
Empty file.
Empty file modified Library/include/joints/CylindricalJoint.h
100644 → 100755
Empty file.
Empty file modified Library/include/joints/FixedJoint.h
100644 → 100755
Empty file.
Empty file modified Library/include/joints/Joint.h
100644 → 100755
Empty file.
Empty file modified Library/include/joints/PrismaticJoint.h
100644 → 100755
Empty file.
Empty file modified Library/include/joints/RevoluteJoint.h
100644 → 100755
Empty file.
Empty file modified Library/include/joints/SphericalJoint.h
100644 → 100755
Empty file.
Empty file modified Library/include/joints/SpringJoint.h
100644 → 100755
Empty file.
Empty file modified Library/include/sensors/Contact.h
100644 → 100755
Empty file.
Empty file modified Library/include/sensors/Sample.h
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions Library/include/sensors/ScalarSensor.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
namespace sf
{
//! An enum defining types of scalar sensors.
enum class ScalarSensorType {ACC, CURRENT, DVL, COMPASS, FT, GPS, GYRO, IMU, INS, MULTIBEAM, ODOM, PRESSURE, PROFILER, ENCODER, TORQUE, POSE};
enum class ScalarSensorType {ACC, CURRENT, DVL, COMPASS, FT, GPS, GYRO, IMU, INS, MULTIBEAM, ODOM, PRESSURE, PROFILER, ENCODER, TORQUE, POSE, LASERMEMS};

//! An enum defining the type of quantity represented by the measurement.
enum class QuantityType
Expand Down Expand Up @@ -105,7 +105,7 @@ namespace sf
virtual void InternalUpdate(Scalar dt) = 0;

//! A method returning the type of the sensor.
virtual SensorType getType() const = 0;
virtual SensorType getType() = 0;

//! A method resetting the sensor.
virtual void Reset();
Expand Down Expand Up @@ -161,7 +161,7 @@ namespace sf
SensorChannel getSensorChannelDescription(unsigned int channel) const;

//! A method returning the type of scalar sensor.
virtual ScalarSensorType getScalarSensorType() const = 0;
virtual ScalarSensorType getScalarSensorType() = 0;

//! A method returning the sensor measurement frame.
virtual Transform getSensorFrame() const = 0;
Expand Down
Loading