20 int main (
int argc,
char* argv[])
35 node->printSupportedModesOfOperation();
45 node->setTransmissionFactor(65000);
49 float current_position;
50 float target_position = 0.2;
55 node->setupProfilePositionMode(config);
60 std::string target_string =
"0.0";
62 while (target_string !=
"q")
64 LOGGING_INFO(CanOpen,
"Please insert a new target position (between 0 and 1, insert q to abort: " <<
endl);
65 std::cin >> target_string;
66 std::cout << std::endl;
70 target_position = boost::lexical_cast<
float>(target_string);
72 catch(boost::bad_lexical_cast &)
74 if (target_string !=
"q")
76 LOGGING_ERROR (CanOpen,
"Invalid input! Please insert a numeric target or q to exit." <<
endl);
81 node->setTarget(target_position);
83 bool is_reached =
false;
87 while ((!is_reached && counter > 5) || counter <= 5)
92 catch (
const std::exception& e)
107 is_reached = node->isTargetReached();
108 current_position = node->getTPDOValue<
int32_t>(
"measured_position");
111 catch (
const std::exception& e)
bool initialize(int &argc, char *argv[], bool remove_read_arguments)
Configuration parameters for a Profile_Position_Mode according to CiA DSP-402 V1.1 section 12...
int main(int argc, char *argv[])
#define LOGGING_INFO(streamname, arg)
void initNodes(const int16_t node_id=-1)
Initializes a node with a given ID or all nodes.
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.
#define LOGGING_ERROR(streamname, arg)
unsigned int sleep(unsigned int seconds)
The CanOpenController class is the main entry point for any calls to the canOpen System.
void enablePPMotion(const int16_t node_id=-1)
When using the ProfilePositionMode is used, in addition to setting the target motion has to be trigge...
boost::shared_ptr< NodeT > getNode(const uint8_t node_id)
Returns a shared pointer handle to a node.
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.
ThreadStream & endl(ThreadStream &stream)
virtual void setDefaultPDOMapping(const eDefaultPDOMapping mapping)
Choose one of the predefined default mappings. Please see the enum eDefaultPDOMapping for a list of a...
boost::shared_ptr< GroupT > getGroup(const std::string &index="default")
Returns a shared pointer to the group with a given index if possible.
float profile_velocity
Final velocity.
void addNode(const uint8_t node_id, const std::string &group_name="default")
Adds a new node to a group. If the group is not found (e.g. it was not created before), nothing will be done.
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...
Class that holds devices according to the DS402 (drives and motion control) specification.
void syncAll()
Downloads all the RPDOs, Sends a Sync and Uploads all the TPDOs.
int usleep(unsigned long useconds)