Commit a2892cda authored by Martí Morta Garriga's avatar Martí Morta Garriga
Browse files

TO TEST! applied changes in segwayrmp200 constructor

parent d778cd46
......@@ -12,6 +12,10 @@ CSegwayRMP400::CSegwayRMP400() :
use_correction_wheel_factor_(true)
{
scan_ftdi_for_segways();
for (unsigned int i = 0;i < NUM_SEGWAY_200 ;i++) {
CSegwayRMP200 * segway = new CSegwayRMP200();
segways_.push_back(segway);
}
}
CSegwayRMP400::CSegwayRMP400(const std::string serial1, const std::string serial2) :
......@@ -55,20 +59,22 @@ CSegwayRMP400::scan_ftdi_for_segways()
void
CSegwayRMP400::start()
{
for (unsigned int i = 0;i < NUM_SEGWAY_200 ;i++) {
for (unsigned int i = 0;i < segways_.size();i++) {
// for (unsigned int i = 0;i < NUM_SEGWAY_200 ;i++) {
try
{
CSegwayRMP200 * segway = new CSegwayRMP200(serial_ftdi_segway_devices_[i]);
segways_.push_back(segway);
// CSegwayRMP200 * segway = new CSegwayRMP200();
segways_[i]->connect(serial_ftdi_segway_devices_[i]);
// segways_.push_back(segway);
}
catch (CSegwayRMP200Exception & e)
{
// Something failed while starting engines
// clean up previous (if any) started engine
for (unsigned int i = 0; i < segways_.size(); i++) {
segways_[i]->stop();
delete segways_[i];
segways_[i]->close();
// delete segways_[i];
}
status_ = rmp400_off;
......@@ -79,6 +85,14 @@ CSegwayRMP400::start()
status_ = rmp400_connected;
}
void
CSegwayRMP400::close()
{
for (unsigned int i = 0;i < segways_.size();i++) {
segways_[i]->close();
}
}
std::ostream &
operator<< (std::ostream& data, CSegwayRMP400 & segway)
{
......@@ -271,6 +285,6 @@ CSegwayRMP400::stop()
CSegwayRMP400::~CSegwayRMP400()
{
for (unsigned int i=0;i < segways_.size(); i++)
for (unsigned int i=0;i < segways_.size(); i++)
delete segways_[i];
}
......@@ -42,7 +42,7 @@ class CSegwayRMP400
/**
* \brief yaw displacement
*
* This value has the rotation of the whole platform in revolutions.
* This value has the rotation of the whole platform in revolutions.
* TODO: should be a thread periodically updating this value
*/
float yaw_displacement_;
......@@ -50,7 +50,7 @@ class CSegwayRMP400
/**
* \brief yaw rate
*
* This value has the yaw rate of the platform in degrees per second.
* This value has the yaw rate of the platform in degrees per second.
* TODO: should be a thread periodically updating this value
*/
float yaw_rate_;
......@@ -150,7 +150,7 @@ class CSegwayRMP400
/**
* \brief function to return the total forward displacement
*
* This function returns the current forward displacement in meters. This
* This function returns the current forward displacement in meters. This
* function only returns the value of the internal attribute, but it does
* not access the hardware platform. This value is periodically updated by
* the feedback thread.
......@@ -165,9 +165,9 @@ class CSegwayRMP400
/**
* \brief function to return the total yaw displacement
*
* This function returns the current yaw displacement in revolutions per
* This function returns the current yaw displacement in revolutions per
* second. This function only returns the value of the internal attribute,
* but it does not access the hardware platform. This value is periodically
* but it does not access the hardware platform. This value is periodically
* updated by the feedback thread.
*
* Both yaw displacement from segways are sum and a mean is calculated
......@@ -180,9 +180,9 @@ class CSegwayRMP400
/**
* \brief function to return the yaw rate
*
* This function returns the current yaw rate in revolutions per second.
* This function only returns the value of the internal attribute, but it
* does not access the hardware platform. This value is periodically updated
* This function returns the current yaw rate in revolutions per second.
* This function only returns the value of the internal attribute, but it
* does not access the hardware platform. This value is periodically updated
* by the feedback thread.
*
* Both yaw rate from segways are sum and a mean is calculated
......@@ -225,6 +225,9 @@ class CSegwayRMP400
* This function stops the vehicle
*/
void stop();
void close();
friend std::ostream& operator<< (std::ostream& out, CSegwayRMP400& segway);
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment