forked from orocos/rtt_soem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ruben Smits
committed
Sep 14, 2010
0 parents
commit d3871f6
Showing
49 changed files
with
2,240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cmake_minimum_required(VERSION 2.4.6) | ||
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) | ||
|
||
# Append to CPACK_SOURCE_IGNORE_FILES a semicolon-separated list of | ||
# directories (or patterns, but directories should suffice) that should | ||
# be excluded from the distro. This is not the place to put things that | ||
# should be ignored everywhere, like "build" directories; that happens in | ||
# rosbuild/rosbuild.cmake. Here should be listed packages that aren't | ||
# ready for inclusion in a distro. | ||
# | ||
# This list is combined with the list in rosbuild/rosbuild.cmake. Note | ||
# that CMake 2.6 may be required to ensure that the two lists are combined | ||
# properly. CMake 2.4 seems to have unpredictable scoping rules for such | ||
# variables. | ||
#list(APPEND CPACK_SOURCE_IGNORE_FILES /core/experimental) | ||
|
||
rosbuild_make_distribution(0.1.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include $(shell rospack find mk)/cmake_stack.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
cmake_minimum_required(VERSION 2.4.6) | ||
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) | ||
|
||
# Set the build type. Options are: | ||
# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage | ||
# Debug : w/ debug symbols, w/o optimization | ||
# Release : w/o debug symbols, w/ optimization | ||
# RelWithDebInfo : w/ debug symbols, w/ optimization | ||
# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries | ||
#set(ROS_BUILD_TYPE RelWithDebInfo) | ||
|
||
rosbuild_init() | ||
|
||
#set the default path for built executables to the "bin" directory | ||
#set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) | ||
#set the default path for built libraries to the "lib" directory | ||
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib/orocos/plugins) | ||
|
||
#uncomment if you have defined messages | ||
rosbuild_genmsg() | ||
#uncomment if you have defined services | ||
#rosbuild_gensrv() | ||
|
||
rosbuild_add_library(${PROJECT_NAME} src/soem_beckhoff_drivers.cpp | ||
src/soem_el1xxx.cpp src/soem_el2xxx.cpp src/soem_el4004.cpp | ||
src/soem_el4034.cpp src/soem_el4032.cpp src/soem_el3062.cpp | ||
src/soem_el5101.cpp src/soem_el4038.cpp) | ||
|
||
#ros_generate_rtt_typekit() | ||
|
||
#common commands for building c++ executables and libraries | ||
#rosbuild_add_library(${PROJECT_NAME} src/example.cpp) | ||
#target_link_libraries(${PROJECT_NAME} another_library) | ||
#rosbuild_add_boost_directories() | ||
#rosbuild_link_boost(${PROJECT_NAME} thread) | ||
#rosbuild_add_executable(example examples/example.cpp) | ||
#target_link_libraries(example ${PROJECT_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include $(shell rospack find mk)/cmake.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
\mainpage | ||
\htmlinclude manifest.html | ||
|
||
\b soem_beckhoff_drivers is ... | ||
|
||
<!-- | ||
Provide an overview of your package. | ||
--> | ||
|
||
|
||
\section codeapi Code API | ||
|
||
<!-- | ||
Provide links to specific auto-generated API documentation within your | ||
package that is of particular interest to a reader. Doxygen will | ||
document pretty much every part of your code, so do your best here to | ||
point the reader to the actual API. | ||
|
||
If your codebase is fairly large or has different sets of APIs, you | ||
should use the doxygen 'group' tag to keep these APIs together. For | ||
example, the roscpp documentation has 'libros' group. | ||
--> | ||
|
||
|
||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<package> | ||
<description brief="soem_beckhoff_drivers"> | ||
|
||
soem_beckhoff_drivers contains drivers for the ethercat beckhoff modules to work together with the soem_master package, every module creates the necessary services, dataports and properties for its own functionality. | ||
|
||
</description> | ||
<author>Ruben Smits</author> | ||
<license>BSD</license> | ||
<review status="unreviewed" notes=""/> | ||
<url>http://ros.org/wiki/soem_beckhoff_drivers</url> | ||
<depend package="roscpp"/> | ||
<depend package="soem_core"/> | ||
<depend package="soem_master"/> | ||
<depend package="rtt"/> | ||
<export> | ||
<cpp cflags="-I${prefix}/msg/cpp" lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/lib"/> | ||
</export> | ||
|
||
</package> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
float32[] values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bool[] values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
uint8 status | ||
uint16 value | ||
uint16 latch | ||
uint32 frequency | ||
uint16 period | ||
uint16 window |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uint16 value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
uint8 control | ||
uint16 outvalue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bool power_ok | ||
bool overload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef COE_CONFIG_H | ||
#define COE_CONFIG_H | ||
|
||
extern "C"{ | ||
#include "ethercattype.h" | ||
#include "nicdrv.h" | ||
#include "ethercatbase.h" | ||
#include "ethercatmain.h" | ||
#include "ethercatconfig.h" | ||
#include "ethercatcoe.h" | ||
#include "ethercatdc.h" | ||
#include "ethercatprint.h" | ||
} | ||
|
||
|
||
typedef struct{ | ||
uint16 index; | ||
uint8 subindex; | ||
uint8 size; | ||
int param; | ||
string name; | ||
string description; | ||
}parameter; | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include <rtt/plugin/Plugin.hpp> | ||
|
||
extern "C" { | ||
bool loadRTTPlugin(RTT::TaskContext* c){ | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/*! | ||
* @author: Ruben Smits and Koen Buys | ||
* @description: Driver for Beckhoff EL1124 module, 4x5V digital inputs | ||
* @version: 9 April 2010 - 1.0 | ||
* @license: LGPL (see Berlios - SOEM) | ||
*/ | ||
#include "soem_el1xxx.h" | ||
#include <soem_master/soem_driver_factory.h> | ||
|
||
namespace soem_beckhoff_drivers{ | ||
|
||
SoemEL1xxx::SoemEL1xxx(ec_slavet* mem_loc): | ||
soem_master::SoemDriver(mem_loc), | ||
port_(this->getName()+"_bits") | ||
{ | ||
size_=mem_loc->Ibits; | ||
service_->doc(std::string("Services for Beckhoff ")+std::string(datap_->name)+std::string(" Dig. Input module")); | ||
service_->addOperation("isOn",&SoemEL1xxx::isOn,this).doc("Check if bit i is on").arg("i","bit nr"); | ||
service_->addOperation("isOff",&SoemEL1xxx::isOff,this).doc("Check if bit i is off").arg("i","bit nr"); | ||
service_->addOperation("readBit",&SoemEL1xxx::readBit,this).doc("Read value of bit i").arg("i","bit nr"); | ||
service_->addConstant("size",size_); | ||
msg_.values.resize(size_); | ||
//port_.doc("values of the bits"); | ||
port_.setDataSample(msg_); | ||
|
||
// port_.createPortObject("bits"); | ||
} | ||
|
||
void SoemEL1xxx::addPortsToTaskContext(RTT::TaskContext* tc){ | ||
tc->ports()->addPort(port_); | ||
} | ||
|
||
bool SoemEL1xxx::isOn( unsigned int bit) const{ | ||
return readBit(bit); | ||
} | ||
|
||
bool SoemEL1xxx::isOff( unsigned int bit) const{ | ||
return !readBit(bit); | ||
} | ||
|
||
bool SoemEL1xxx::readBit( unsigned int bit) const{ | ||
if(bit<size_){ | ||
bits_= ((out_el1xxxt*)(datap_->inputs))->outbits; | ||
return bits_[bit+datap_->Istartbit]; | ||
} | ||
else{ | ||
//TODO: We should raise somekind of error here | ||
return false; | ||
} | ||
} | ||
|
||
void SoemEL1xxx::updatePorts(){ | ||
bits_= ((out_el1xxxt*)(datap_->inputs))->outbits; | ||
for(unsigned int i=0;i<size_;i++) | ||
msg_.values[i]=bits_[i]; | ||
port_.write(msg_); | ||
} | ||
|
||
/* | ||
unsigned int SoemEL1xxx::readSequence(unsigned int start_bit, unsigned int stop_bit) const{ | ||
if(start_bit<size_&&stop_bit<size_){ | ||
bits_=((out_el1xxxt*)(datap_->inputs))->outbits; | ||
std::bitset<8> out_bits; | ||
unsigned int j=0; | ||
for(unsigned int i=start_bit;i<=stop_bit;i++) | ||
out_bits.set(j,bits_[datap_->Istartbit+i]); | ||
return out_bits.to_ulong(); | ||
} | ||
} | ||
*/ | ||
|
||
namespace { | ||
soem_master::SoemDriver* createSoemEL1xxx(ec_slavet* mem_loc){ | ||
return new SoemEL1xxx(mem_loc); | ||
} | ||
const bool registered1 = soem_master::SoemDriverFactory::Instance().registerDriver("EL1124",createSoemEL1xxx); | ||
const bool registered2 = soem_master::SoemDriverFactory::Instance().registerDriver("EL1144",createSoemEL1xxx); | ||
const bool registered3 = soem_master::SoemDriverFactory::Instance().registerDriver("EL1008",createSoemEL1xxx); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef SOEM_EL1xxx_H | ||
#define SOEM_EL1xxx_H | ||
|
||
#include <soem_master/soem_driver.h> | ||
#include <soem_beckhoff_drivers/DigitalMsg.h> | ||
#include <rtt/Port.hpp> | ||
#include <bitset> | ||
|
||
namespace soem_beckhoff_drivers{ | ||
|
||
class SoemEL1xxx : public soem_master::SoemDriver | ||
{ | ||
|
||
typedef struct PACKED | ||
{ | ||
uint8 outbits; | ||
} out_el1xxxt; | ||
|
||
public: | ||
SoemEL1xxx(ec_slavet* mem_loc); | ||
~SoemEL1xxx(){}; | ||
|
||
bool isOn( unsigned int bit = 0) const; | ||
bool isOff( unsigned int bit = 0) const; | ||
bool readBit( unsigned int bit = 0) const; | ||
|
||
void addPortsToTaskContext(RTT::TaskContext* tc); | ||
void updatePorts(); | ||
|
||
|
||
private: | ||
unsigned int size_; | ||
DigitalMsg msg_; | ||
mutable std::bitset<8> bits_; | ||
RTT::OutputPort<DigitalMsg> port_; | ||
}; | ||
|
||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#include "soem_el2xxx.h" | ||
#include <soem_master/soem_driver_factory.h> | ||
|
||
namespace soem_beckhoff_drivers{ | ||
|
||
SoemEL2xxx::SoemEL2xxx(ec_slavet* mem_loc): | ||
soem_master::SoemDriver(mem_loc), | ||
port_(this->getName()+"_bits") | ||
{ | ||
size_=mem_loc->Obits; | ||
service_->doc(std::string("Services for Beckhoff ")+std::string(datap_->name)+std::string(" Dig. Output module")); | ||
|
||
service_->addOperation("switchOn",&SoemEL2xxx::switchOn,this).doc("Switch bit i on").arg("i","bit nr"); | ||
service_->addOperation("switchOff",&SoemEL2xxx::switchOff,this).doc("Switch bit i off").arg("i","bit nr"); | ||
service_->addOperation("setBit",&SoemEL2xxx::setBit,this).doc("Set value of bit i to val").arg("i","bit nr").arg("val","new value for bit"); | ||
service_->addOperation("checkBit",&SoemEL2xxx::checkBit,this).doc("Check value of bit i").arg("i","bit nr"); | ||
service_->addConstant("size",size_); | ||
|
||
msg_.values.resize(size_); | ||
|
||
for(unsigned int i=0;i<size_;i++) | ||
bits_.set(i+datap_->Ostartbit,0); | ||
((out_el2xxxt*)(datap_->outputs))->outbits=bits_.to_ulong(); | ||
} | ||
|
||
void SoemEL2xxx::addPortsToTaskContext(RTT::TaskContext* tc){ | ||
tc->ports()->addPort(port_).doc("DigitalMsg containting the desired values of _all_ bits"); | ||
} | ||
|
||
void SoemEL2xxx::updatePorts(){ | ||
if(port_.connected()){ | ||
if(port_.read(msg_)==RTT::NewData){ | ||
if(msg_.values.size()<size_){ | ||
bits_=((out_el2xxxt*)(datap_->outputs))->outbits; | ||
for(unsigned int i=0;i<size_;i++) | ||
bits_.set(i+datap_->Ostartbit,msg_.values[i]); | ||
((out_el2xxxt*)(datap_->outputs))->outbits=bits_.to_ulong(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
void SoemEL2xxx::setBit(unsigned int bit,bool value){ | ||
if(bit<size_){ | ||
bits_=((out_el2xxxt*)(datap_->outputs))->outbits; | ||
bits_.set(bit+datap_->Ostartbit,value); | ||
((out_el2xxxt*)(datap_->outputs))->outbits=bits_.to_ulong(); | ||
} | ||
} | ||
|
||
void SoemEL2xxx::switchOn(unsigned int n){ | ||
this->setBit(n,true); | ||
} | ||
|
||
void SoemEL2xxx::switchOff(unsigned int n){ | ||
this->setBit(n,false); | ||
} | ||
/* | ||
void SoemEL2xxx::setSequence(unsigned int start_bit,unsigned int stop_bit,unsigned int value){ | ||
if(start_bit<size_&&stop_bit<size_){ | ||
bits_=((out_el2xxxt*)(datap_->outputs))->outbits; | ||
std::bitset<8> in_bits(value); | ||
for(unsigned int i=start_bit;i<=stop_bit;i++) | ||
bits_.set(i+datap_->Ostartbit,in_bits[i]); | ||
((out_el2xxxt*)(datap_->outputs))->outbits=bits_.to_ulong(); | ||
} | ||
} | ||
*/ | ||
|
||
bool SoemEL2xxx::checkBit(unsigned int bit)const{ | ||
if(bit<size_){ | ||
bits_=((out_el2xxxt*)(datap_->outputs))->outbits; | ||
return bits_.test(bit+datap_->Ostartbit); | ||
} | ||
return false; | ||
} | ||
/* | ||
unsigned int SoemEL2xxx::checkSequence(unsigned int start_bit,unsigned int stop_bit)const{ | ||
if(start_bit<size_&&stop_bit<size_){ | ||
bits_=((out_el2xxxt*)(datap_->outputs))->outbits; | ||
std::bitset<8> out_bits; | ||
unsigned int j=0; | ||
for(unsigned int i=start_bit;i<=stop_bit;i++) | ||
out_bits.set(j,bits_[datap_->Ostartbit+i]); | ||
return out_bits.to_ulong(); | ||
} | ||
} | ||
*/ | ||
|
||
namespace { | ||
soem_master::SoemDriver* createSoemEL2xxx(ec_slavet* mem_loc){ | ||
return new SoemEL2xxx(mem_loc); | ||
} | ||
const bool registered0 = soem_master::SoemDriverFactory::Instance().registerDriver("EL2002",createSoemEL2xxx); | ||
const bool registered1 = soem_master::SoemDriverFactory::Instance().registerDriver("EL2004",createSoemEL2xxx); | ||
const bool registered2 = soem_master::SoemDriverFactory::Instance().registerDriver("EL2008",createSoemEL2xxx); | ||
const bool registered3 = soem_master::SoemDriverFactory::Instance().registerDriver("EL2124",createSoemEL2xxx); | ||
} | ||
} |
Oops, something went wrong.