1 #ifndef H_CANOPEN_ROS_CHAIN 2 #define H_CANOPEN_ROS_CHAIN 6 #include <canopen_chain_node/GetObject.h> 7 #include <canopen_chain_node/SetObject.h> 10 #include <std_srvs/Trigger.h> 12 #include <boost/filesystem/path.hpp> 13 #include <boost/weak_ptr.hpp> 14 #include <boost/scoped_ptr.hpp> 26 template <
typename Tpub,
typename Tobj,
bool forced>
static void publish(
ros::Publisher &pub, ObjectStorage::Entry<Tobj> &entry){
28 msg.data = (
const typename Tpub::_data_type &)(forced? entry.get() : entry.get_cached());
31 template<
typename Tpub,
typename Tobj>
static FuncType
create(
ros::NodeHandle &nh,
const std::string &name, ObjectStorage::Entry<Tobj> entry,
bool force){
32 if(!entry.valid())
return 0;
35 return boost::bind(PublishFunc::publish<Tpub, Tobj, true>, pub, entry);
37 return boost::bind(PublishFunc::publish<Tpub, Tobj, false>, pub, entry);
50 std::pair<XmlRpc::XmlRpcValue::iterator,bool> res = _value.asStruct->insert(*it);
64 std::vector<boost::function< void (diagnostic_updater::DiagnosticStatusWrapper &)> >
entries_;
67 if(stat.level >= level){
69 stat.
add(name, getter());
71 stat.
add(name,
"<ERROR>");
79 bool add(uint8_t level,
const std::string &key,
bool forced){
81 ObjectDict::Key k(key);
83 std::string name = entry->desc.empty() ? key : entry->desc;
84 entries_.push_back(boost::bind(log_entry, _1, level, name, node_->getStorage()->getStringReader(k, !forced)));
87 catch(std::exception& e){
99 stat.
summary(stat.WARN,
"Not initailized");
105 for(std::vector<std::pair<std::string, std::string> >::const_iterator it = r.
values().begin(); it != r.
values().end(); ++it){
106 stat.
add(it->first, it->second);
108 for(
size_t i=0; i < entries_.size(); ++i) entries_[i](stat);
120 guarded_loaders().push_back(b);
123 guarded_loaders().clear();
127 static std::vector<ClassLoaderBaseSharedPtr> loaders;
138 : loader_(new Loader(package, allocator_base_class)) {
142 return loader_->createInstance(lookup_name);
150 template<
typename T1> ClassSharedPtr
allocateInstance(
const std::string& lookup_name,
const T1 & t1){
153 template<
typename T1,
typename T2> ClassSharedPtr
allocateInstance(
const std::string& lookup_name,
const T1 & t1,
const T2 & t2){
156 template<
typename T1,
typename T2,
typename T3> ClassSharedPtr
allocateInstance(
const std::string& lookup_name,
const T1 & t1,
const T2 & t2,
const T3 & t3){
197 return interface && interface->send(frame);
209 virtual bool handle_init(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res);
210 virtual bool handle_recover(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res);
213 virtual bool handle_shutdown(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res);
214 virtual bool handle_halt(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res);
216 bool handle_get_object(canopen_chain_node::GetObject::Request &req, canopen_chain_node::GetObject::Response &res);
217 bool handle_set_object(canopen_chain_node::SetObject::Request &req, canopen_chain_node::SetObject::Response &res);
221 bool setup_heartbeat();
225 virtual bool setup_chain();
can::StateListenerConstSharedPtr state_listener_
virtual void add(const VectorMemberSharedPtr &l)
boost::shared_ptr< pluginlib::ClassLoaderBase > ClassLoaderBaseSharedPtr
ros::ServiceServer srv_shutdown_
static FuncType create(ros::NodeHandle &nh, const std::string &name, ObjectStorage::Entry< Tobj > entry, bool force)
void publish(const boost::shared_ptr< M > &message) const
ros::ServiceServer srv_set_object_
void summary(unsigned char lvl, const std::string s)
boost::function< void()> func_type ROS_DEPRECATED
ClassSharedPtr allocateInstance(const std::string &lookup_name, const T1 &t1, const T2 &t2, const T3 &t3)
can::DriverInterfaceSharedPtr interface
const canopen::NodeSharedPtr node_
Base * createInstance(const std::string &derived_class_name, ClassLoader *loader)
static FuncType create(ros::NodeHandle &nh, const std::string &name, canopen::NodeSharedPtr node, const std::string &key, bool force)
std::vector< LoggerSharedPtr > loggers_
boost::shared_ptr< T > ClassSharedPtr
boost::shared_ptr< Logger > LoggerSharedPtr
const std::string reason() const
bool reset_errors_before_recover_
ClassAllocator(const std::string &package, const std::string &allocator_base_class)
ClassSharedPtr allocateInstance(const std::string &lookup_name, const T1 &t1)
static void log_entry(diagnostic_updater::DiagnosticStatusWrapper &stat, uint8_t level, const std::string &name, boost::function< std::string()> getter)
ros::ServiceServer srv_init_
ClassSharedPtr allocateInstance(const std::string &lookup_name, const T1 &t1, const T2 &t2)
boost::function< void()> FuncType
boost::shared_ptr< T > ClassSharedPtr
ros::ServiceServer srv_get_object_
ros::ServiceServer srv_halt_
MergedXmlRpcStruct(const XmlRpc::XmlRpcValue &a, const MergedXmlRpcStruct &b, bool recursive=true)
union XmlRpc::XmlRpcValue::@0 _value
boost::chrono::high_resolution_clock::duration time_duration
MergedXmlRpcStruct(const XmlRpc::XmlRpcValue &a)
Logger(canopen::NodeSharedPtr node)
virtual void log(diagnostic_updater::DiagnosticStatusWrapper &stat)
ClassAllocator< canopen::Master > master_allocator_
std::vector< PublishFunc::FuncType > publishers_
static void addLoader(ClassLoaderBaseSharedPtr b)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
static std::vector< ClassLoaderBaseSharedPtr > & guarded_loaders()
const std::vector< std::pair< std::string, std::string > > & values() const
GuardedClassLoader< can::DriverInterface > driver_loader_
GuardedClassLoader(const std::string &package, const std::string &allocator_base_class)
std::map< std::string, canopen::NodeSharedPtr > nodes_lookup_
~GuardedClassLoaderList()
void report_diagnostics(canopen::LayerStack &sync, diagnostic_updater::DiagnosticStatusWrapper &stat)
std::vector< boost::function< void(diagnostic_updater::DiagnosticStatusWrapper &)> > entries_
boost::shared_ptr< canopen::LayerGroupNoDiag< canopen::Node > > nodes_
ClassSharedPtr createInstance(const std::string &lookup_name)
can::DriverInterfaceSharedPtr interface_
static void publish(ros::Publisher &pub, ObjectStorage::Entry< Tobj > &entry)
canopen::SyncLayerSharedPtr sync_
time_duration update_duration_
diagnostic_updater::Updater diag_updater_
boost::scoped_ptr< boost::thread > thread_
void add(const std::string &key, const T &val)
pluginlib::ClassLoader< T > Loader
#define ROS_ERROR_STREAM(args)
boost::shared_ptr< Loader > loader_
void add(const boost::shared_ptr< T > &n)
void run(ClassLoader *loader)
bool add(uint8_t level, const std::string &key, bool forced)
boost::atomic< bool > running_
ros::ServiceServer srv_recover_
boost::shared_ptr< canopen::LayerGroupNoDiag< canopen::EMCYHandler > > emcy_handlers_