11 : rokubiminis_(), busManagers_(), standalone_(standalone), timeStep_(timeStep), nh_(
std::move(nh))
13 if (installSignalHandler)
32 std::vector<std::shared_ptr<Rokubimini>> rokubimini_out;
38 return rokubimini_out;
53 for (
const auto& rokubimini_setup : setup->rokubiminis_)
72 bool RokubiminiManager::RokubiminiManager::createAndConfigureRokubimini(
73 const std::shared_ptr<rokubimini::setup::Rokubimini>& rokubiminiSetup)
76 if (!
rokubimini->loadRokubiminiSetup(rokubiminiSetup))
89 const std::string name = rokubimini->getName();
92 ROS_ERROR_STREAM(
"Cannot add Rokubimini with name '" << name <<
"', because it already exists.");
143 ROS_WARN_STREAM(
"Cannot start up, Rokubimini Manager is already running.");
149 throw ros::Exception(
"Cannot start up, a communication manager has not been set.");
157 if (!bus_manager_ptr->startupCommunication())
161 for (
const auto& rokubimini_setup : bus_manager_ptr->getRokubiminiSetups())
169 for (
const auto& bus_manager_ptr : busManagers_)
171 bus_manager_ptr->setConfigMode();
177 for (
const auto& bus_manager_ptr : busManagers_)
179 bus_manager_ptr->setRunMode();
186 update_worker_options.
name_ =
"RokubiminiManager::updateWorker";
209 bus_manager_ptr->readAllBuses();
224 bus_manager_ptr->writeToAllBuses();
231 ROS_WARN_STREAM(
"Cannot shut down, Rokubimini Manager is not running.");
241 update_worker_options.
name_ =
"RokubiminiManager::updateWorker (shutdown)";
258 bus_manager_ptr->shutdownAllBuses();
278 ROS_INFO_STREAM(
"Received signal (" << signum <<
"), requesting shutdown ...");
280 if (signum == SIGSEGV)
282 signal(signum, SIG_DFL);
283 kill(getpid(), signum);
std::shared_ptr< bota_worker::Worker > updateWorker_
A Worker instance that handles the update process.
void updateCommunicationManagerReadMessages()
Instructs each BusManager to read the messages.
bool addRokubimini(const std::shared_ptr< Rokubimini > &rokubimini)
Adds a Rokubimini instance to the list.
void createRokubiminiRosPublishers() const
Creates ROS Publishers for each attached rokubimini.
bool createRokubiminisFromSetup(const rokubimini::setup::SetupPtr &setup)
Creates the Rokubimini instances from a Setup.
void updateProcessReadings()
Gets the Readings from each Rokubimini device.
bool startup() override
Starts the communication with all the Rokubimini devices.
bool loadSetup() override
Loads the Setup from the parameter server.
std::vector< std::unique_ptr< RokubiminiBusManager > > busManagers_
void createRokubiminiRosServices() const
Creates ROS Services for each attached rokubimini.
std::atomic< bool > shutdownRequested_
Boolean that specifies if shutdown has been requested.
std::atomic< double > timeStep_
bool updateWorkerCb(const bota_worker::WorkerEvent &event)
Callback method which when triggered calls the update() method.
void updateCommunicationManagerWriteMessages()
Instructs each BusManager to write the messages.
std::vector< std::shared_ptr< Rokubimini > > rokubiminis_
void handleSignal(const int signum)
Handles the signal received. Specifically requests shuts down if the signum is SIGSEGV.
std::shared_ptr< Setup > SetupPtr
std::shared_ptr< Rokubimini > getRokubimini(const std::string &name) const
Returns the Rokubimini instance with name name.
bool loadBusManagersSetup()
Calls the loadSetup() of each Bus Manager.
std::shared_ptr< ros::NodeHandle > NodeHandlePtr
void requestShutdown()
Sets a flag that represents that shutdown has been requested.
#define ROS_WARN_STREAM(args)
#define ROS_DEBUG_STREAM(args)
bool createAndConfigureRokubimini(const std::shared_ptr< rokubimini::setup::Rokubimini > &rokubiminiSetup)
Creates an implementation-specific Rokubimini instance (through the rokubimini_factory), loads the RokubiminiSetup to it and adds the new instance to the list.
std::atomic< bool > enforceRate_
bool update() override
Updates with new values from/to the Rokubiminis.
#define ROS_INFO_STREAM(args)
std::atomic< bool > isRunning_
Boolean that specifies if the Manager is already running.
bool rokubiminiExists(const std::string &name) const
Decides if a specific Rokubimini instance exists in the list.
void setNodeHandle(const std::shared_ptr< ros::NodeHandle > &nh) const
Sets the ROS NodeHandle to each rokubimini.
#define ROS_ERROR_STREAM(args)
std::vector< std::shared_ptr< Rokubimini > > getRokubiminis() const
std::shared_ptr< rokubimini::Rokubimini > createRokubiminiFactory(const std::shared_ptr< rokubimini::setup::Rokubimini > &rokubiminiSetup, const NodeHandlePtr &nh)
void publishRosMessages() const
Publishes the ROS messages for each attached rokubimini.
static void bindAll(void(T::*fp)(int), T *object)
RokubiminiManager()=delete
rokubimini::setup::SetupPtr loadBusSetup(std::vector< std::unique_ptr< RokubiminiBusManager >> &busManagers, const NodeHandlePtr &nh)
void shutdown() override
Shuts down everything.