25 #include <sensor_msgs/JointState.h> 27 #include <boost/filesystem.hpp> 34 int main(
int argc,
char** argv)
36 ros::init(argc, argv,
"move_arm_to_zero_node");
43 std::string can_device_name;
44 std::vector<std::string> chain_names;
45 std::map<std::string, std::vector<int> > chain_configuratuions;
46 std::vector<DS402Group::Ptr> chain_handles;
47 sensor_msgs::JointState joint_msg;
49 std::map<std::string, uint8_t> joint_name_mapping;
51 priv_nh.
getParam(
"chain_names", chain_names);
52 priv_nh.
param<std::string>(
"can_device_name", can_device_name,
"auto");
62 my_controller = boost::make_shared<CanOpenController>(can_device_name);
72 char const* tmp = std::getenv(
"CANOPEN_RESOURCE_PATH");
78 "The environment variable 'CANOPEN_RESOURCE_PATH' could not be read. No Schunk specific error codes will be used." <<
endl);
82 std::string emcy_emergency_errors_filename = boost::filesystem::path(tmp / boost::filesystem::path(
"EMCY_schunk.ini")).string();
91 for (
size_t i = 0; i < chain_names.size(); ++i)
93 std::string name =
"chain_" + chain_names[i];
94 my_controller->addGroup<
DS402Group>(chain_names[i]);
95 chain_handles.push_back(my_controller->getGroup<
DS402Group>(chain_names[i]));
96 std::vector<int> chain;
105 if (chain.size() == 0)
107 ROS_ERROR_STREAM(
"Did not find device list for chain " << chain_names[i] <<
". Make sure, that an entry " << name <<
" exists.");
110 ROS_INFO_STREAM (
"Found chain with name " << name <<
" and " << chain.size() <<
" nodes");
111 chain_configuratuions[name] = chain;
112 for (
size_t j = 0; j < chain.size(); ++j)
116 std::string joint_name =
"";
117 std::string mapping_key =
"~node_mapping_" + boost::lexical_cast<std::string>( chain[j]);
120 joint_name_mapping[joint_name] =
static_cast<uint8_t>(chain[j]);
121 joint_msg.name.push_back(joint_name);
127 my_controller->initNodes();
132 ROS_INFO (
"Going to shut down now");
138 ROS_INFO (
"Going to shut down now");
144 for (
size_t i = 0; i < chain_handles.size(); ++i)
148 chain_handles[i]->setupProfilePositionMode(ppm_config);
149 chain_handles[i]->enableNodes(mode);
153 ROS_ERROR_STREAM (
"Caught ProtocolException while enabling nodes from chain " <<
154 chain_handles[i]->
getName() <<
". Nodes from this group won't be enabled.");
158 std::vector<DS301Node::Ptr> nodes = chain_handles[i]->getNodes();
159 std::vector<float> targets (nodes.size(), 0.0);
161 chain_handles[i]->setTarget(targets);
163 my_controller->enablePPMotion();
165 std::vector<bool> foo;
169 size_t num_reached = 0;
171 my_controller->syncAll();
173 catch (
const std::exception& e)
180 for (
size_t i = 0; i < chain_handles.size(); ++i)
182 if (chain_handles[i]->isTargetReached(foo))
187 if (num_reached == chain_handles.size())
197 for (
size_t i = 0; i < chain_handles.size(); ++i)
199 chain_handles[i]->disableNodes();
Configuration parameters for a Profile_Position_Mode according to CiA DSP-402 V1.1 section 12...
static void addEmergencyErrorMap(const std::string &filename, const std::string &block_identifier)
Adds new information from an ini file to the emergency error map.
#define LOGGING_INFO(streamname, arg)
Basic CanOpen exception that contains the Object dictionary index and subindex.
This class gives a device specific interface for Schunk Powerballs, as they need some "special" treat...
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
std::string getName(void *handle)
virtual const char * what() const _GLIBCXX_USE_NOEXCEPT
The DS402Group class is the base class for canOpen devices implementing the DS402 device protocol (mo...
bool use_blending
If set to true, the device will blend over to a new setpoint. Defaults to true.
PDO related exceptions go here.
#define LOGGING_WARNING_C(streamname, classname, arg)
int main(int argc, char **argv)
The CanOpenController class is the main entry point for any calls to the canOpen System.
bool use_relative_targets
This parameter influences the interpretation of new set points. If set to true, new set point positio...
float profile_acceleration
This will be used for both acceleration ramps.
ROSCPP_DECL bool get(const std::string &key, std::string &s)
ThreadStream & endl(ThreadStream &stream)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
If something goes wrong with the host's CAN controller, this exception will be used.
virtual const char * what() const _GLIBCXX_USE_NOEXCEPT
#define ROS_INFO_STREAM(args)
float profile_velocity
Final velocity.
bool getParam(const std::string &key, std::string &s) const
virtual const char * what() const _GLIBCXX_USE_NOEXCEPT
#define ROS_ERROR_STREAM(args)
bool change_set_immediately
If this is set to true the device will not ramp down at a setpoint if a following one is given...
int usleep(unsigned long useconds)