wg_soft_processor.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2008, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #ifndef ETHERCAT_HARDWARE__WG_SOFT_PROCESSOR_H
36 #define ETHERCAT_HARDWARE__WG_SOFT_PROCESSOR_H
37 
38 #include <ros/ros.h>
41 #include "ethercat_hardware/SoftProcessorFirmwareWrite.h"
42 #include "ethercat_hardware/SoftProcessorFirmwareRead.h"
43 #include "ethercat_hardware/SoftProcessorReset.h"
44 
45 #include <vector>
46 #include <ostream>
47 #include <string>
48 
49 namespace ethercat_hardware
50 {
51 
52 
57 class WGSoftProcessor
58 {
59 public:
61  bool initialize(EthercatCom *com);
62 
63  struct Info
64  {
65  Info() : mbx_(NULL), iram_address_(-1), ctrl_address_(-1) {}
66  Info( WGMailbox *mbx,
67  const std::string &actuator_name,
68  const std::string &processor_name,
69  unsigned iram_address, unsigned ctrl_address ) :
70  mbx_(mbx), actuator_name_(actuator_name), processor_name_(processor_name),
71  iram_address_(iram_address), ctrl_address_(ctrl_address) {}
72  WGMailbox *mbx_;
73  std::string actuator_name_;
74  std::string processor_name_;
75  unsigned iram_address_;
76  unsigned ctrl_address_;
77  };
78 
79  void add(WGMailbox *mbx, const std::string &actuator_name, const std::string &processor_name,
80  unsigned iram_address, unsigned ctrl_address);
81 
82 protected:
83 
84  static const unsigned IRAM_INSTRUCTION_LENGTH = 1024;
85 
86  std::vector<Info> processors_;
87 
88  bool writeFirmwareCB(ethercat_hardware::SoftProcessorFirmwareWrite::Request &request,
89  ethercat_hardware::SoftProcessorFirmwareWrite::Response &response);
90  bool readFirmwareCB(ethercat_hardware::SoftProcessorFirmwareRead::Request &request,
91  ethercat_hardware::SoftProcessorFirmwareRead::Response &response);
92  bool resetCB(ethercat_hardware::SoftProcessorReset::Request &request,
93  ethercat_hardware::SoftProcessorReset::Response &response);
94 
98 
100  bool assertReset(const Info &info, std::ostream &err_msg);
101 
103  bool releaseReset(const Info &info, std::ostream &err_msg);
104 
106  const WGSoftProcessor::Info* get(const std::string &actuator_name, const std::string &processor_name, std::ostream &err_out) const;
107 
108  EthercatCom *com_;
109 };
110 
111 
112 }; // end namespace ethercat_hardware
113 
114 #endif //ETHERCAT_HARDWARE__WG_SOFT_PROCESSOR_H
ethercat_hardware::WGSoftProcessor::IRAM_INSTRUCTION_LENGTH
static const unsigned IRAM_INSTRUCTION_LENGTH
Definition: wg_soft_processor.h:148
ethercat_hardware::WGSoftProcessor::Info::ctrl_address_
unsigned ctrl_address_
Definition: wg_soft_processor.h:140
EthercatCom
Definition: ethercat_com.h:44
ethercat_hardware::WGSoftProcessor::Info::actuator_name_
std::string actuator_name_
Definition: wg_soft_processor.h:137
ethercat_hardware::WGSoftProcessor::releaseReset
bool releaseReset(const Info &info, std::ostream &err_msg)
Takes soft processor out of reset.
Definition: wg_soft_processor.cpp:184
ethercat_hardware::WGSoftProcessor::initialize
bool initialize(EthercatCom *com)
Definition: wg_soft_processor.cpp:15
ros.h
ethercat_hardware::WGSoftProcessor::Info::mbx_
WGMailbox * mbx_
Definition: wg_soft_processor.h:136
ethercat_hardware::WGSoftProcessor::add
void add(WGMailbox *mbx, const std::string &actuator_name, const std::string &processor_name, unsigned iram_address, unsigned ctrl_address)
Definition: wg_soft_processor.cpp:26
ethercat_hardware::WGSoftProcessor::Info::iram_address_
unsigned iram_address_
Definition: wg_soft_processor.h:139
ethercat_hardware::WGSoftProcessor::writeFirmwareCB
bool writeFirmwareCB(ethercat_hardware::SoftProcessorFirmwareWrite::Request &request, ethercat_hardware::SoftProcessorFirmwareWrite::Response &response)
Definition: wg_soft_processor.cpp:106
ethercat_hardware
Definition: motor_heating_model.h:53
ethercat_hardware::WGSoftProcessor::processors_
std::vector< Info > processors_
Definition: wg_soft_processor.h:150
ros::ServiceServer
ethercat_com.h
ethercat_hardware::WGSoftProcessor::Info::Info
Info()
Definition: wg_soft_processor.h:129
ethercat_hardware::WGSoftProcessor::com_
EthercatCom * com_
Definition: wg_soft_processor.h:172
ethercat_hardware::WGSoftProcessor::Info::processor_name_
std::string processor_name_
Definition: wg_soft_processor.h:138
ethercat_hardware::WGSoftProcessor::resetCB
bool resetCB(ethercat_hardware::SoftProcessorReset::Request &request, ethercat_hardware::SoftProcessorReset::Response &response)
Definition: wg_soft_processor.cpp:143
Info
Info
ethercat_hardware::WGSoftProcessor::read_firmware_service_
ros::ServiceServer read_firmware_service_
service that allows read of soft processor firmware
Definition: wg_soft_processor.h:159
ethercat_hardware::WGSoftProcessor::write_firmware_service_
ros::ServiceServer write_firmware_service_
service that allows write of soft processor firmware
Definition: wg_soft_processor.h:160
ethercat_hardware::WGSoftProcessor::get
const WGSoftProcessor::Info * get(const std::string &actuator_name, const std::string &processor_name, std::ostream &err_out) const
Get pointer to soft processor by name. Returns NULL if processor d/n exist and create message in err_...
Definition: wg_soft_processor.cpp:38
wg_mailbox.h
ethercat_hardware::WGSoftProcessor::Info
Definition: wg_soft_processor.h:127
ethercat_hardware::WGSoftProcessor::WGSoftProcessor
WGSoftProcessor()
Definition: wg_soft_processor.cpp:10
ethercat_hardware::WGSoftProcessor::readFirmwareCB
bool readFirmwareCB(ethercat_hardware::SoftProcessorFirmwareRead::Request &request, ethercat_hardware::SoftProcessorFirmwareRead::Response &response)
Definition: wg_soft_processor.cpp:56
ethercat_hardware::WGSoftProcessor::assertReset
bool assertReset(const Info &info, std::ostream &err_msg)
Puts soft processor in reset.
Definition: wg_soft_processor.cpp:176
ethercat_hardware::WGSoftProcessor::reset_service_
ros::ServiceServer reset_service_
service that resets soft-processor
Definition: wg_soft_processor.h:161


ethercat_hardware
Author(s): Rob Wheeler , Derek King
autogenerated on Thu Sep 26 2024 02:44:04