|
From: <stu...@us...> - 2008-08-05 22:25:22
|
Revision: 2591
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=2591&view=rev
Author: stuglaser
Date: 2008-08-05 22:25:31 +0000 (Tue, 05 Aug 2008)
Log Message:
-----------
Changed the array of actuators in HardwareInterface to a vector of pointers.
Modified Paths:
--------------
pkg/trunk/controllers/generic_controllers/manifest.xml
pkg/trunk/drivers/motor/ethercat_hardware/src/ethercat_hardware.cpp
pkg/trunk/mechanism/hardware_interface/include/hardware_interface/hardware_interface.h
pkg/trunk/mechanism/hardware_interface/manifest.xml
pkg/trunk/mechanism/mechanism_control/src/mechanism_control.cpp
pkg/trunk/mechanism/mechanism_model/include/mechanism_model/robot.h
pkg/trunk/mechanism/mechanism_model/manifest.xml
Modified: pkg/trunk/controllers/generic_controllers/manifest.xml
===================================================================
--- pkg/trunk/controllers/generic_controllers/manifest.xml 2008-08-05 22:24:39 UTC (rev 2590)
+++ pkg/trunk/controllers/generic_controllers/manifest.xml 2008-08-05 22:25:31 UTC (rev 2591)
@@ -6,10 +6,11 @@
<license>BSD</license>
<depend package="mechanism_model" />
<depend package="wg_robot_description_parser" />
+ <depend package="stl_utils" />
<url>http://pr.willowgarage.com</url>
<repository>http://pr.willowgarage.com/repos</repository>
<export>
<cpp cflags='-I${prefix}/include' lflags='-Wl,-rpath,${prefix}/lib -L${prefix}/lib -lgeneric_controllers'/>
</export>
-
+
</package>
Modified: pkg/trunk/drivers/motor/ethercat_hardware/src/ethercat_hardware.cpp
===================================================================
--- pkg/trunk/drivers/motor/ethercat_hardware/src/ethercat_hardware.cpp 2008-08-05 22:24:39 UTC (rev 2590)
+++ pkg/trunk/drivers/motor/ethercat_hardware/src/ethercat_hardware.cpp 2008-08-05 22:25:31 UTC (rev 2591)
@@ -132,9 +132,9 @@
// Convert HW Interface commands to MCB-specific buffers
current = current_buffer_;
- for (int i = 0; i < hw_->num_actuators_; ++i)
+ for (int i = 0; i < hw_->actuators_.size(); ++i)
{
- slaves[i]->convertCommand(hw_->actuators_[i].command_, current);
+ slaves[i]->convertCommand(hw_->actuators_[i]->command_, current);
current += slaves[i]->commandSize + slaves[i]->statusSize;
}
@@ -144,9 +144,9 @@
// Convert status back to HW Interface
current = current_buffer_;
last = last_buffer_;
- for (int i = 0; i < hw_->num_actuators_; ++i)
+ for (int i = 0; i < hw_->actuators_.size(); ++i)
{
- slaves[i]->convertState(hw_->actuators_[i].state_, current, last);
+ slaves[i]->convertState(hw_->actuators_[i]->state_, current, last);
current += slaves[i]->commandSize + slaves[i]->statusSize;
last += slaves[i]->commandSize + slaves[i]->statusSize;
}
Modified: pkg/trunk/mechanism/hardware_interface/include/hardware_interface/hardware_interface.h
===================================================================
--- pkg/trunk/mechanism/hardware_interface/include/hardware_interface/hardware_interface.h 2008-08-05 22:24:39 UTC (rev 2590)
+++ pkg/trunk/mechanism/hardware_interface/include/hardware_interface/hardware_interface.h 2008-08-05 22:25:31 UTC (rev 2591)
@@ -35,6 +35,8 @@
#ifndef HARDWARE_INTERFACE_H
#define HARDWARE_INTERFACE_H
+#include <stl_utils/stl_utils.h>
+
class ActuatorState{
public:
ActuatorState() :
@@ -87,12 +89,14 @@
{
public:
HardwareInterface(int num_actuators)
+ : actuators_(num_actuators, (Actuator*)NULL)
{
- actuators_ = new Actuator[num_actuators];
- num_actuators_ = num_actuators;
}
- Actuator *actuators_;
- int num_actuators_;
+ ~HardwareInterface()
+ {
+ deleteElements(&actuators_);
+ }
+ std::vector<Actuator*> actuators_;
double current_time_;
};
Modified: pkg/trunk/mechanism/hardware_interface/manifest.xml
===================================================================
--- pkg/trunk/mechanism/hardware_interface/manifest.xml 2008-08-05 22:24:39 UTC (rev 2590)
+++ pkg/trunk/mechanism/hardware_interface/manifest.xml 2008-08-05 22:25:31 UTC (rev 2591)
@@ -4,6 +4,7 @@
<author>Eric Berger be...@wi...</author>
<license>BSD</license>
<url>http://pr.willowgarage.com</url>
+<depend package="stl_utils" />
<export>
<cpp cflags="-I${prefix}/include"/>
</export>
Modified: pkg/trunk/mechanism/mechanism_control/src/mechanism_control.cpp
===================================================================
--- pkg/trunk/mechanism/mechanism_control/src/mechanism_control.cpp 2008-08-05 22:24:39 UTC (rev 2590)
+++ pkg/trunk/mechanism/mechanism_control/src/mechanism_control.cpp 2008-08-05 22:25:31 UTC (rev 2591)
@@ -77,9 +77,9 @@
{
// Looks up the joint and the actuator used by the transmission.
Robot::IndexMap::iterator joint_it =
- model_.joints_lookup_.find(elt->FirstChildElement("joint")->Attribute("name"));
+ model_.joints_lookup_.find(elt->FirstChildElement("joint")->Attribute("name"));
Robot::IndexMap::iterator actuator_it =
- model_.actuators_lookup_.find(elt->FirstChildElement("actuator")->Attribute("name"));
+ model_.actuators_lookup_.find(elt->FirstChildElement("actuator")->Attribute("name"));
if (joint_it == model_.joints_lookup_.end())
{
// TODO: report: The joint was not declared in the XML file
@@ -91,15 +91,11 @@
continue;
}
- Transmission
- *tr =
- new SimpleTransmission(model_.joints_[joint_it->second], &hw_->actuators_[actuator_it->second], atof(
- elt->FirstChildElement(
- "mechanicalReduction")->Value()), atof(
- elt->FirstChildElement(
- "motorTorqueConstant")->Value()), atof(
- elt->FirstChildElement(
- "pulsesPerRevolution")->Value()));
+ Transmission *tr =
+ new SimpleTransmission(model_.joints_[joint_it->second], hw_->actuators_[actuator_it->second],
+ atof(elt->FirstChildElement("mechanicalReduction")->Value()),
+ atof(elt->FirstChildElement("motorTorqueConstant")->Value()),
+ atof(elt->FirstChildElement("pulsesPerRevolution")->Value()));
model_.transmissions_.push_back(tr);
}
else
Modified: pkg/trunk/mechanism/mechanism_model/include/mechanism_model/robot.h
===================================================================
--- pkg/trunk/mechanism/mechanism_model/include/mechanism_model/robot.h 2008-08-05 22:24:39 UTC (rev 2590)
+++ pkg/trunk/mechanism/mechanism_model/include/mechanism_model/robot.h 2008-08-05 22:25:31 UTC (rev 2591)
@@ -39,6 +39,7 @@
#include <vector>
#include <map>
#include <string>
+#include "stl_utils/stl_utils.h"
#include "mechanism_model/link.h"
#include "mechanism_model/joint.h"
#include "mechanism_model/transmission.h"
@@ -54,12 +55,8 @@
~Robot()
{
- std::vector<Transmission *>::size_type t;
- for (t = 0; t < transmissions_.size(); ++t)
- delete transmissions_[t];
- std::vector<Joint *>::size_type j;
- for (j = 0; j < joints_.size(); ++j)
- delete joints_[j];
+ deleteElements(&transmissions_);
+ deleteElements(&joints_);
}
std::vector<Joint*> joints_;
@@ -82,7 +79,7 @@
IndexMap::iterator it = actuators_lookup_.find(name);
if (it == actuators_lookup_.end())
return NULL;
- return &hw_->actuators_[it->second];
+ return hw_->actuators_[it->second];
}
HardwareInterface *hw_;
Modified: pkg/trunk/mechanism/mechanism_model/manifest.xml
===================================================================
--- pkg/trunk/mechanism/mechanism_model/manifest.xml 2008-08-05 22:24:39 UTC (rev 2590)
+++ pkg/trunk/mechanism/mechanism_model/manifest.xml 2008-08-05 22:25:31 UTC (rev 2591)
@@ -4,6 +4,7 @@
<author>Eric Berger be...@wi...</author>
<license>BSD</license>
<depend package='hardware_interface'/>
+<depend package="stl_utils" />
<url>http://pr.willowgarage.com</url>
<export>
<cpp cflags="-I${prefix}/include" lflags="-L${prefix}/lib -lmechanism_model -Wl,-rpath,${prefix}/lib"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|