Privacy
An open-source, flexible 3D physical simulation framework
mars::sim::Controller Class Reference

The class to log all data. More...

#include <Controller.h>

Public Member Functions

 Controller (interfaces::sReal rate, const std::vector< SimMotor *> &motors, const std::vector< interfaces::BaseSensor *> &sensors, const std::vector< interfaces::NodeData *> &sNodes, interfaces::ControlCenter *control, int portn=1500)
 
virtual ~Controller (void)
 
virtual void update (interfaces::sReal time_ms)
 
virtual std::list< interfaces::sRealgetSensorValues (void)
 
void handleError (void)
 
void setID (unsigned long id)
 
unsigned long getID (void) const
 
const interfaces::ControllerData getSController () const
 
void getCoreExchange (interfaces::core_objects_exchange *obj) const
 
void resetData (void)
 
void setDylibPath (const std::string &dylib_path)
 
void setAutoMode (bool mode)
 
void setIP (const std::string &ip)
 
void setPort (int port)
 
bool getAutoMode (void) const
 
const std::string getIP (void) const
 
int getPort (void) const
 
void connect (void)
 
void disconnect (void)
 
- Public Member Functions inherited from mars::utils::Thread
 Thread ()
 
virtual ~Thread ()
 
void start ()
 Starts the execution of this Thread. More...
 
void cancel (bool block=false)
 Tries to cancel the Thread. More...
 
void setCancellationPoint ()
 Adds a cancellation point to your run method. More...
 
bool wait ()
 stops execution until the thread has finished. More...
 
bool join ()
 
bool wait (unsigned long timeoutMilliseconds)
 puts the Thread to sleep for a specified amount of time. More...
 
bool isRunning () const
 returns true if the Thread is running. More...
 
bool isFinished () const
 
void setStackSize (std::size_t stackSize)
 
std::size_t getStackSize () const
 
bool isCurrentThread () const
 

Protected Member Functions

int initServer (int port)
 
void getClient (void)
 
int openClient (const char *host, int port)
 
int connectClient (void)
 
int getSReal (const char *data, interfaces::sReal *value) const
 
int getChar (const char *data, char *c) const
 
void run (void)
 The thread will execute this method once it has been started . More...
 

Protected Attributes

int server
 
int conn
 
void * dy
 
interfaces::ControllerData sController
 
interfaces::ControllerInterfacedylibController
 
interfaces::sReal count_ms
 
bool auto_connect
 
int connected
 
int nport
 
int sock_state
 
struct sockaddr_in * myServAddr
 
std::string hostname
 
interfaces::ControlCentercontrol
 
bool running
 
std::vector< SimMotor * > motors
 
std::vector< interfaces::BaseSensor * > sensors
 
std::vector< interfaces::NodeData * > sNodes
 

Additional Inherited Members

- Static Public Member Functions inherited from mars::utils::Thread
static ThreadgetCurrentThread ()
 
static void cancelAll (bool block=false)
 
- Static Protected Member Functions inherited from mars::utils::Thread
static void msleep (unsigned long msec)
 causes the current thread to sleep for More...
 

Detailed Description

The class to log all data.

Definition at line 67 of file Controller.h.

Constructor & Destructor Documentation

◆ Controller()

mars::sim::Controller::Controller ( interfaces::sReal  rate,
const std::vector< SimMotor *> &  motors,
const std::vector< interfaces::BaseSensor *> &  sensors,
const std::vector< interfaces::NodeData *> &  sNodes,
interfaces::ControlCenter control,
int  portn = 1500 
)

Definition at line 58 of file Controller.cpp.

◆ ~Controller()

mars::sim::Controller::~Controller ( void  )
virtual

Definition at line 114 of file Controller.cpp.

Member Function Documentation

◆ connect()

void mars::sim::Controller::connect ( void  )

Definition at line 1038 of file Controller.cpp.

◆ connectClient()

int mars::sim::Controller::connectClient ( void  )
protected

Definition at line 978 of file Controller.cpp.

◆ disconnect()

void mars::sim::Controller::disconnect ( void  )

Definition at line 1043 of file Controller.cpp.

◆ getAutoMode()

bool mars::sim::Controller::getAutoMode ( void  ) const

Definition at line 1026 of file Controller.cpp.

◆ getChar()

int mars::sim::Controller::getChar ( const char *  data,
char *  c 
) const
protected

Definition at line 796 of file Controller.cpp.

◆ getClient()

void mars::sim::Controller::getClient ( void  )
protected

Definition at line 911 of file Controller.cpp.

◆ getCoreExchange()

void mars::sim::Controller::getCoreExchange ( interfaces::core_objects_exchange obj) const

Definition at line 149 of file Controller.cpp.

◆ getID()

unsigned long mars::sim::Controller::getID ( void  ) const

Definition at line 141 of file Controller.cpp.

◆ getIP()

const std::string mars::sim::Controller::getIP ( void  ) const

Definition at line 1030 of file Controller.cpp.

◆ getPort()

int mars::sim::Controller::getPort ( void  ) const

Definition at line 1034 of file Controller.cpp.

◆ getSController()

const ControllerData mars::sim::Controller::getSController ( void  ) const

Definition at line 145 of file Controller.cpp.

◆ getSensorValues()

std::list< sReal > mars::sim::Controller::getSensorValues ( void  )
virtual

Definition at line 1047 of file Controller.cpp.

◆ getSReal()

int mars::sim::Controller::getSReal ( const char *  data,
interfaces::sReal value 
) const
protected

Definition at line 776 of file Controller.cpp.

◆ handleError()

void mars::sim::Controller::handleError ( void  )

Definition at line 822 of file Controller.cpp.

◆ initServer()

int mars::sim::Controller::initServer ( int  port)
protected

Definition at line 885 of file Controller.cpp.

◆ openClient()

int mars::sim::Controller::openClient ( const char *  host,
int  port 
)
protected

Definition at line 933 of file Controller.cpp.

◆ resetData()

void mars::sim::Controller::resetData ( void  )

Definition at line 804 of file Controller.cpp.

◆ run()

void mars::sim::Controller::run ( void  )
protectedvirtual

The thread will execute this method once it has been started .

See also
start(), cancel(), wait(), wait(unsigned long)

Implements mars::utils::Thread.

Definition at line 996 of file Controller.cpp.

◆ setAutoMode()

void mars::sim::Controller::setAutoMode ( bool  mode)

Definition at line 1014 of file Controller.cpp.

◆ setDylibPath()

void mars::sim::Controller::setDylibPath ( const std::string &  dylib_path)

Definition at line 829 of file Controller.cpp.

◆ setID()

void mars::sim::Controller::setID ( unsigned long  id)

Definition at line 137 of file Controller.cpp.

◆ setIP()

void mars::sim::Controller::setIP ( const std::string &  ip)

Definition at line 1018 of file Controller.cpp.

◆ setPort()

void mars::sim::Controller::setPort ( int  port)

Definition at line 1022 of file Controller.cpp.

◆ update()

void mars::sim::Controller::update ( interfaces::sReal  time_ms)
virtual

Definition at line 154 of file Controller.cpp.

Member Data Documentation

◆ auto_connect

bool mars::sim::Controller::auto_connect
protected

Definition at line 112 of file Controller.h.

◆ conn

int mars::sim::Controller::conn
protected

Definition at line 106 of file Controller.h.

◆ connected

int mars::sim::Controller::connected
protected

Definition at line 113 of file Controller.h.

◆ control

interfaces::ControlCenter* mars::sim::Controller::control
protected

Definition at line 118 of file Controller.h.

◆ count_ms

interfaces::sReal mars::sim::Controller::count_ms
protected

Definition at line 111 of file Controller.h.

◆ dy

void* mars::sim::Controller::dy
protected

Definition at line 107 of file Controller.h.

◆ dylibController

interfaces::ControllerInterface* mars::sim::Controller::dylibController
protected

Definition at line 110 of file Controller.h.

◆ hostname

std::string mars::sim::Controller::hostname
protected

Definition at line 117 of file Controller.h.

◆ motors

std::vector<SimMotor*> mars::sim::Controller::motors
protected

Definition at line 120 of file Controller.h.

◆ myServAddr

struct sockaddr_in* mars::sim::Controller::myServAddr
protected

Definition at line 116 of file Controller.h.

◆ nport

int mars::sim::Controller::nport
protected

Definition at line 114 of file Controller.h.

◆ running

bool mars::sim::Controller::running
protected

Definition at line 119 of file Controller.h.

◆ sController

interfaces::ControllerData mars::sim::Controller::sController
protected

Definition at line 109 of file Controller.h.

◆ sensors

std::vector<interfaces::BaseSensor*> mars::sim::Controller::sensors
protected

Definition at line 121 of file Controller.h.

◆ server

int mars::sim::Controller::server
protected

Definition at line 105 of file Controller.h.

◆ sNodes

std::vector<interfaces::NodeData*> mars::sim::Controller::sNodes
protected

Definition at line 122 of file Controller.h.

◆ sock_state

int mars::sim::Controller::sock_state
protected

Definition at line 115 of file Controller.h.


The documentation for this class was generated from the following files: