#include <sr09.h>
Public Member Functions | |
virtual void | construct (EtherCAT_SlaveHandler *sh, int &start_address) |
Construct function, run at startup to set SyncManagers and FMMUs. More... | |
virtual int | initialize (hardware_interface::HardwareInterface *hw, bool allow_unprogrammed=true) |
virtual void | multiDiagnostics (vector< diagnostic_msgs::DiagnosticStatus > &vec, unsigned char *buffer) |
This function gives some diagnostics data. More... | |
virtual void | packCommand (unsigned char *buffer, bool halt, bool reset) |
packs the commands before sending them to the EtherCAT bus More... | |
SR09 () | |
Constructor of the SR09 driver. More... | |
virtual bool | unpackState (unsigned char *this_buffer, unsigned char *prev_buffer) |
This functions receives data from the EtherCAT bus. More... | |
Public Member Functions inherited from SrEdc | |
void | build_CAN_message (ETHERCAT_CAN_BRIDGE_DATA *message) |
bool | can_data_is_ack (ETHERCAT_CAN_BRIDGE_DATA *packet) |
This function checks if the can packet in the unpackState() this_buffer is an ACK. More... | |
virtual void | construct (EtherCAT_SlaveHandler *sh, int &start_address, unsigned int ethercat_command_data_size, unsigned int ethercat_status_data_size, unsigned int ethercat_can_bridge_data_size, unsigned int ethercat_command_data_address, unsigned int ethercat_status_data_address, unsigned int ethercat_can_bridge_data_command_address, unsigned int ethercat_can_bridge_data_status_address) |
Construct function, run at startup to set SyncManagers and FMMUs. More... | |
void | erase_flash () |
Erase the PIC18F Flash memory. More... | |
bool | read_flash (unsigned int offset, unsigned int baddr) |
Function that reads back 8 bytes from PIC18F program memory. More... | |
bool | simple_motor_flasher (sr_robot_msgs::SimpleMotorFlasher::Request &req, sr_robot_msgs::SimpleMotorFlasher::Response &res) |
ROS Service that flashes a new firmware into a SimpleMotor board. More... | |
SrEdc () | |
Constructor of the SrEdc driver. More... | |
Protected Types | |
typedef realtime_tools::RealtimePublisher< std_msgs::Int16 > | rt_pub_int16_t |
Protected Types inherited from SrEdc | |
typedef realtime_tools::RealtimePublisher< std_msgs::Int16 > | rt_pub_int16_t |
Protected Types inherited from SR0X | |
enum | { MODE_OFF = 0x00, MODE_ENABLE = (1 << 0), MODE_CURRENT = (1 << 1), MODE_SAFETY_RESET = (1 << 4), MODE_SAFETY_LOCKOUT = (1 << 5), MODE_UNDERVOLTAGE = (1 << 6), MODE_RESET = (1 << 7) } |
enum | { EC_PRODUCT_ID_BRIDGE = 0, EC_PRODUCT_ID_SHADOWCAN = 2, EC_PRODUCT_ID_DUALMOTOR = 3 } |
Protected Member Functions | |
virtual void | get_board_id_and_can_bus (int board_id, int *can_bus, unsigned int *board_can_id) |
bool | imu_scale_callback_ (sr_robot_msgs::SetImuScale::Request &request, sr_robot_msgs::SetImuScale::Response &response, const char *which) |
virtual void | reinitialize_boards () |
This function will call the reinitialization function for the boards attached to the CAN bus. More... | |
Protected Attributes | |
boost::shared_ptr< realtime_tools::RealtimePublisher< std_msgs::Float64MultiArray > > | extra_analog_inputs_publisher |
Extra analog inputs real time publisher (+ accelerometer and gyroscope) More... | |
std::vector< boost::shared_ptr< rt_pub_int16_t > > | realtime_pub_ |
Protected Attributes inherited from SrEdc | |
bool | can_packet_acked |
int | counter_ |
std::string | device_id_ |
std::string | device_joint_prefix_ |
boost::shared_ptr< realtime_tools::RealtimePublisher< std_msgs::Float64MultiArray > > | extra_analog_inputs_publisher |
Extra analog inputs real time publisher (+ accelerometer and gyroscope) More... | |
bool | flashing |
ros::NodeHandle | nh_tilde_ |
ros::NodeHandle | nodehandle_ |
std::vector< boost::shared_ptr< rt_pub_int16_t > > | realtime_pub_ |
Protected Attributes inherited from SR0X | |
uint8_t | board_major_ |
uint8_t | board_minor_ |
int | command_base_ |
int | device_offset_ |
uint8_t | fw_major_ |
uint8_t | fw_minor_ |
int | level_ |
string | reason_ |
int | status_base_ |
Private Member Functions | |
void | readImu (ETHERCAT_DATA_STRUCTURE_0240_PALM_EDC_STATUS *status) |
This funcion reads the ethercat status and fills the imu_state with the relevant values. More... | |
Private Attributes | |
int16_t | cycle_count |
boost::shared_ptr< realtime_tools::RealtimePublisher< sr_robot_msgs::EthercatDebug > > | debug_publisher |
Debug real time publisher: publishes the raw ethercat data. More... | |
ros_ethercat_model::RobotState * | hw_ |
ros::ServiceServer | imu_acc_scale_server_ |
ros::ServiceServer | imu_gyr_scale_server_ |
int | imu_scale_acc_ |
bool | imu_scale_change_ |
int | imu_scale_gyr_ |
ros_ethercat_model::ImuState * | imu_state_ |
boost::shared_ptr< shadow_robot::SrMotorHandLib< ETHERCAT_DATA_STRUCTURE_0240_PALM_EDC_STATUS, ETHERCAT_DATA_STRUCTURE_0240_PALM_EDC_COMMAND > > | sr_hand_lib |
unsigned int | zero_buffer_read |
|
protected |
SR09::SR09 | ( | ) |
|
virtual |
Construct function, run at startup to set SyncManagers and FMMUs.
The role of this function is to setup the SyncManagers and the FMMUs used by this EtherCAT slave. This slave is using two Mailboxes on two different memory areas.
Here we are setting up the way of communicating between ROS and the PIC32 using the EtherCAT protocol.
We communicate using Shared Memory areas.
The FMMUs are usefull to map the logical memory used by ROS to the Physical memory of the EtherCAT slave chip (ET1200 chip). So that the chip receiving the packet will know that the data at address 0x10000 is in reality to be written at physical address 0x1000 of the chip memory for example. It is the mapping between the EtherCAT bus address space and each slave's chip own memory address space.
The SyncManagers are usefull to give a safe way of accessing this Shared Memory, using a consumer / producer model. There are features like interrupts to tell the consumer that there is something to consume or to tell the producer that the Mailbox is empty and then ready to receive a new message.
That's basically one Mailbox for upstream and one Mailbox for downstream.
This function sets the two private members command_size_ and status_size_ to be the size of each Mailbox. It is important for these numbers to be accurate since they are used by the EthercatHardware class when manipulating the buffers. If you need to have several commands like in this SR09 driver, put the sum of the size, same thing for the status.
|
protectedvirtual |
Given the identifier for a certain board (motor board/ muscle driver) determines the right value for the CAN bus and the ID of the board in that CAN bus.
board_id | the unique identifier for the board |
can_bus | pointer to the can bus number we want to determine |
board_can_id | pointer to the board id we want to determine |
Implements SrEdc.
|
protected |
|
virtual |
|
virtual |
|
virtual |
packs the commands before sending them to the EtherCAT bus
This is one of the most important functions of this driver. This function is called each millisecond (1 kHz freq) by the EthercatHardware::update() function in the controlLoop() of the ros_etherCAT node.
This function is called with a buffer as a parameter, the buffer provided is where we write the commands to send via EtherCAT.
We just cast the buffer to our structure type, fill the structure with our data, then add the structure size to the buffer address to shift into memory and access the second command. The buffer has been allocated with command_size_ bytes, which is the sum of the two command size, so we have to put the two commands one next to the other. In fact we access the buffer using this kind of code :
|
private |
|
protectedvirtual |
|
virtual |
This functions receives data from the EtherCAT bus.
This function allows the driver to get the data present on the EtherCAT bus and intended for us.
It gives us access to the logical memory registered during the construct().
In order to be able to do differentials two buffers are kept, this_buffer is the actual data that has just been received and prev_buffer is the previous buffer received from the EtherCAT bus.
We access the data sent by PIC32 here using the same tricks we used in packCommand().
this_buffer | The data just being received by EtherCAT |
prev_buffer | The previous data received by EtherCAT |
|
private |
|
private |
|
protected |
|
private |
|
private |
|
private |
|
protected |
|
private |