The CanOpenController class is the main entry point for any calls to the canOpen System. More...
#include <CanOpenController.h>
Public Types | |
typedef boost::shared_ptr < const CanOpenController > | ConstPtr |
Shared pointer to a const CanOpenController. | |
typedef boost::shared_ptr < CanOpenController > | Ptr |
Shared pointer to a CanOpenController. | |
Public Member Functions | |
template<typename GroupT > | |
void | addGroup (const std::string &identifier) |
Adds a new node group with a given identifier. The group's type is given as template parameter. | |
template<typename NodeT > | |
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. | |
CanOpenController (const std::string can_device_identifier="/dev/pcanusb0", const uint32_t baud_rate=500, const std::string &resource_folder_location="") | |
CanOpenController constructor. | |
void | deleteGroup (const std::string &identifier) |
Deletes a group with the given identifier. Also deletes all its nodes. | |
void | deleteNode (const uint8_t node_id) |
Delete a node with a given CANOPEN-ID. | |
void | enablePPMotion (const int16_t node_id=-1) |
When using the ProfilePositionMode is used, in addition to setting the target motion has to be triggered manually. Therefor, intermediate syncs are needed, which is why this is done in the controller-. | |
CanDevPtr | getCanDevice () const |
Get a handle to the current CAN device. This is basically for debugging with a Dummy Can Device. | |
template<typename GroupT > | |
boost::shared_ptr< GroupT > | getGroup (const std::string &index="default") |
Returns a shared pointer to the group with a given index if possible. | |
template<typename NodeT > | |
boost::shared_ptr< NodeT > | getNode (const uint8_t node_id) |
Returns a shared pointer handle to a node. | |
std::vector< uint8_t > | getNodeList () |
Returns a list containing all used node ids. | |
void | initNodes (const int16_t node_id=-1) |
Initializes a node with a given ID or all nodes. | |
void | processCanMsgCallback (const icl_hardware::can::tCanMessage &msg) |
Incoming can messages are processed in this function and forwarded to the addressed node. | |
void | reconnectCanDevice (const std::string &can_identifier, const uint32_t baud_rate) |
Reconnects the CAN device with the given configuration. | |
void | stopAll () |
Calls stop() on all registered nodes. | |
void | syncAll () |
Downloads all the RPDOs, Sends a Sync and Uploads all the TPDOs. | |
~CanOpenController () | |
Private Member Functions | |
DS301Node::Ptr | getNodeById (const uint8_t node_id) |
get a handle for a node identified by its CANOPEN-ID | |
void | getResources () |
Load resources like error-code lookup maps. | |
void | init () |
Private Attributes | |
CanDevPtr | m_can_device |
Handle for the can device. | |
std::map< std::string, DS301Group::Ptr > | m_groups |
Map of all node groups, with string identifier. | |
HeartBeatMonitor::Ptr | m_heartbeat_monitor |
std::map< uint8_t, DS301Node::Ptr > | m_nodes |
Map of all nodes with id identifier. | |
uint32_t | m_polling_period_ms |
The CAN message polling period duration in milliseconds. | |
CanOpenReceiveThreadPtr | m_receive_thread |
Handle for the can receive thread. | |
std::string | m_resource_folder_location |
This folder contains for example the error code definitions. | |
size_t | m_ws_broadcast_counter |
size_t | m_ws_broadcast_rate |
Counts sync cycles. | |
boost::shared_ptr < icl_comm::websocket::WsBroadcaster > | m_ws_broadcaster |
Interface to send out diagnostics data. Only available if compiled with _IC_BUILDER_ICL_COMM_WEBSOCKET_. | |
std::string | m_can_device_name |
int32_t | m_can_device_flags |
unsigned char | m_can_device_acceptance_code |
unsigned char | m_can_device_acceptance_mask |
uint32_t | m_can_device_send_fifo_size |
uint32_t | m_can_device_receive_fifo_size |
uint32_t | m_can_device_baud_rate |
The CanOpenController class is the main entry point for any calls to the canOpen System.
The CanOpenController is the main entry point for any calls to the whole canOpen System. It is used to set up the hardware (i.e. can device used), configure device groups and add individual devices to these groups. It is also the entity providing access to the device groups, handling all the required type conversions as to provide the most safe and convenient way to access the hardware. Actual control commands (i.e. move a motor to a given position) are usually send directly to the corresponding group as each group might present an individual interface.
Definition at line 65 of file CanOpenController.h.
typedef boost::shared_ptr<const CanOpenController> icl_hardware::canopen_schunk::CanOpenController::ConstPtr |
Shared pointer to a const CanOpenController.
Definition at line 71 of file CanOpenController.h.
typedef boost::shared_ptr<CanOpenController> icl_hardware::canopen_schunk::CanOpenController::Ptr |
Shared pointer to a CanOpenController.
Definition at line 69 of file CanOpenController.h.
icl_hardware::canopen_schunk::CanOpenController::CanOpenController | ( | const std::string | can_device_identifier = "/dev/pcanusb0" , |
const uint32_t | baud_rate = 500 , |
||
const std::string & | resource_folder_location = "" |
||
) |
CanOpenController constructor.
can_device_identifier | identifier string for the can device |
baud_rate | baud rate of the can device |
resource_folder_location | Folder location that contains ini files with error messages. If none is given, it defaults to the environment variable CANOPEN_RESOURCE_PATH. If that is not defined either, it searches in the resources subfolder where the program was launched. If no error description is found at all, plain error codes will be displayed instead. |
Definition at line 40 of file CanOpenController.cpp.
Definition at line 60 of file CanOpenController.cpp.
void icl_hardware::canopen_schunk::CanOpenController::addGroup | ( | const std::string & | identifier | ) |
Adds a new node group with a given identifier. The group's type is given as template parameter.
identifier | Name of the new group |
Definition at line 34 of file CanOpenController.hpp.
void icl_hardware::canopen_schunk::CanOpenController::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.
node_id | ID of the new node |
group_name | The new node will belong to this group. |
Definition at line 80 of file CanOpenController.hpp.
void icl_hardware::canopen_schunk::CanOpenController::deleteGroup | ( | const std::string & | identifier | ) |
Deletes a group with the given identifier. Also deletes all its nodes.
identifier | The group's identifier |
Definition at line 451 of file CanOpenController.cpp.
void icl_hardware::canopen_schunk::CanOpenController::deleteNode | ( | const uint8_t | node_id | ) |
Delete a node with a given CANOPEN-ID.
node_id | CANOPEN-ID of the node that should be deleted. |
Definition at line 482 of file CanOpenController.cpp.
void icl_hardware::canopen_schunk::CanOpenController::enablePPMotion | ( | const int16_t | node_id = -1 | ) |
When using the ProfilePositionMode is used, in addition to setting the target motion has to be triggered manually. Therefor, intermediate syncs are needed, which is why this is done in the controller-.
node_id | If left out or given a negative value, the function will be called for all nodes in the group, otherwise it will only be used for the given node-id. |
Definition at line 611 of file CanOpenController.cpp.
CanDevPtr icl_hardware::canopen_schunk::CanOpenController::getCanDevice | ( | ) | const [inline] |
Get a handle to the current CAN device. This is basically for debugging with a Dummy Can Device.
Definition at line 165 of file CanOpenController.h.
boost::shared_ptr< GroupT > icl_hardware::canopen_schunk::CanOpenController::getGroup | ( | const std::string & | index = "default" | ) |
Returns a shared pointer to the group with a given index if possible.
Note that this function will return a NULL pointer if either the given index does not exist or if the group cannot be casted to the requested type. Error messages are output in both cases. Therefore, check for NULL pointers after calling this method.
index | The group's identifier string |
Definition at line 56 of file CanOpenController.hpp.
boost::shared_ptr< NodeT > icl_hardware::canopen_schunk::CanOpenController::getNode | ( | const uint8_t | node_id | ) |
Returns a shared pointer handle to a node.
node_id | The node's CanOpen-ID |
NotFoundException | when no node with the given ID can be found |
std::bad_cast | when the node can't be casted into the requested template type. |
Definition at line 124 of file CanOpenController.hpp.
DS301Node::Ptr icl_hardware::canopen_schunk::CanOpenController::getNodeById | ( | const uint8_t | node_id | ) | [private] |
get a handle for a node identified by its CANOPEN-ID
Definition at line 502 of file CanOpenController.cpp.
Returns a list containing all used node ids.
Definition at line 592 of file CanOpenController.cpp.
void icl_hardware::canopen_schunk::CanOpenController::getResources | ( | ) | [private] |
Load resources like error-code lookup maps.
Definition at line 515 of file CanOpenController.cpp.
void icl_hardware::canopen_schunk::CanOpenController::init | ( | ) | [private] |
Start can device and Message receiving throws a DeviceException if the device can't be initialized
Definition at line 320 of file CanOpenController.cpp.
void icl_hardware::canopen_schunk::CanOpenController::initNodes | ( | const int16_t | node_id = -1 | ) |
Initializes a node with a given ID or all nodes.
node_id | If left out or given a negative value, the function will be called for all nodes in the group, otherwise it will only be used for the given node-id. |
Definition at line 69 of file CanOpenController.cpp.
void icl_hardware::canopen_schunk::CanOpenController::processCanMsgCallback | ( | const icl_hardware::can::tCanMessage & | msg | ) |
Incoming can messages are processed in this function and forwarded to the addressed node.
msg | Can message received by m_receive_thread |
Definition at line 80 of file CanOpenController.cpp.
void icl_hardware::canopen_schunk::CanOpenController::reconnectCanDevice | ( | const std::string & | can_identifier, |
const uint32_t | baud_rate | ||
) |
Reconnects the CAN device with the given configuration.
can_identifier | Identifier string for the can device |
baud_rate | Baud rate of the can device |
Definition at line 297 of file CanOpenController.cpp.
Calls stop() on all registered nodes.
Definition at line 581 of file CanOpenController.cpp.
Downloads all the RPDOs, Sends a Sync and Uploads all the TPDOs.
Definition at line 547 of file CanOpenController.cpp.
Handle for the can device.
Definition at line 217 of file CanOpenController.h.
unsigned char icl_hardware::canopen_schunk::CanOpenController::m_can_device_acceptance_code [private] |
Definition at line 224 of file CanOpenController.h.
unsigned char icl_hardware::canopen_schunk::CanOpenController::m_can_device_acceptance_mask [private] |
Definition at line 225 of file CanOpenController.h.
Definition at line 228 of file CanOpenController.h.
Definition at line 223 of file CanOpenController.h.
std::string icl_hardware::canopen_schunk::CanOpenController::m_can_device_name [private] |
Can device parameters
Definition at line 222 of file CanOpenController.h.
Definition at line 227 of file CanOpenController.h.
Definition at line 226 of file CanOpenController.h.
std::map<std::string, DS301Group::Ptr> icl_hardware::canopen_schunk::CanOpenController::m_groups [private] |
Map of all node groups, with string identifier.
Definition at line 236 of file CanOpenController.h.
HeartBeatMonitor::Ptr icl_hardware::canopen_schunk::CanOpenController::m_heartbeat_monitor [private] |
Definition at line 230 of file CanOpenController.h.
std::map<uint8_t, DS301Node::Ptr> icl_hardware::canopen_schunk::CanOpenController::m_nodes [private] |
Map of all nodes with id identifier.
Definition at line 238 of file CanOpenController.h.
The CAN message polling period duration in milliseconds.
Definition at line 233 of file CanOpenController.h.
Handle for the can receive thread.
Definition at line 214 of file CanOpenController.h.
std::string icl_hardware::canopen_schunk::CanOpenController::m_resource_folder_location [private] |
This folder contains for example the error code definitions.
Definition at line 241 of file CanOpenController.h.
Definition at line 245 of file CanOpenController.h.
size_t icl_hardware::canopen_schunk::CanOpenController::m_ws_broadcast_rate [private] |
Counts sync cycles.
Definition at line 246 of file CanOpenController.h.
boost::shared_ptr<icl_comm::websocket::WsBroadcaster> icl_hardware::canopen_schunk::CanOpenController::m_ws_broadcaster [private] |
Interface to send out diagnostics data. Only available if compiled with _IC_BUILDER_ICL_COMM_WEBSOCKET_.
Definition at line 244 of file CanOpenController.h.