Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions epos_hardware/include/epos_hardware/epos.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Epos {
EposFactory* epos_factory_;
std::string name_;
std::string actuator_name_;
std::string comm_protocol_;
uint64_t serial_number_;
OperationMode operation_mode_;
NodeHandlePtr node_handle_;
Expand Down
1 change: 1 addition & 0 deletions epos_hardware/launch/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
my_joint_actuator:
actuator_name: 'test_joint_actuator'
serial_number: '662080000026'
communication_protocol: 'RS232' # or USB
operation_mode: 'profile_velocity'
clear_faults: true

Expand Down
43 changes: 34 additions & 9 deletions epos_hardware/src/util/epos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ Epos::Epos(const std::string& name,
valid_ = false;
}

if(!config_nh_.getParam("communication_protocol", comm_protocol_)) {
ROS_WARN("You haven't specified which communication protocol you want to use\nWill be USB by default");
valid_ = false;
}

std::string serial_number_str;
if(!config_nh_.getParam("serial_number", serial_number_str)) {
ROS_ERROR("You must specify a serial number");
Expand Down Expand Up @@ -139,16 +144,36 @@ bool Epos::init() {

ROS_INFO_STREAM("Initializing: 0x" << std::hex << serial_number_);
unsigned int error_code;
node_handle_ = epos_factory_->CreateNodeHandle("EPOS2", "MAXON SERIAL V2", "USB", serial_number_, &error_code);
if(!node_handle_) {
ROS_ERROR("Could not find motor");
return false;

if((comm_protocol_ == "USB") || (comm_protocol_ == "")){
node_handle_ = epos_factory_->CreateNodeHandle("EPOS2", "MAXON SERIAL V2", "USB", serial_number_, &error_code);
if(!node_handle_) {
ROS_ERROR("Could not find motor");
return false;
}
ROS_INFO_STREAM("Found Motor");
if(!VCS_SetProtocolStackSettings(node_handle_->device_handle->ptr, 1000000, 500, &error_code)) {
ROS_ERROR("Failed to SetProtocolStackSettings");
return false;
}
}
ROS_INFO_STREAM("Found Motor");

if(!VCS_SetProtocolStackSettings(node_handle_->device_handle->ptr, 1000000, 500, &error_code)) {
ROS_ERROR("Failed to SetProtocolStackSettings");
return false;
else{
if(comm_protocol_ == "RS232"){
node_handle_ = epos_factory_->CreateNodeHandle("EPOS2", "MAXON_RS232", "RS232", serial_number_, &error_code);
if(!node_handle_) {
ROS_ERROR("Could not find motor");
return false;
}
ROS_INFO_STREAM("Found Motor");
if(!VCS_SetProtocolStackSettings(node_handle_->device_handle->ptr, 115200, 500, &error_code)) {
ROS_ERROR("Failed to SetProtocolStackSettings");
return false;
}
}
else{
ROS_ERROR_STREAM("Specified communication protocol was : "<<comm_protocol_<<" . Must be either USB or RS232");
return false;
}
}

if(!VCS_SetDisableState(node_handle_->device_handle->ptr, node_handle_->node_id, &error_code)) {
Expand Down