|
From: <hsu...@us...> - 2008-12-13 01:59:01
|
Revision: 8050
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=8050&view=rev
Author: hsujohnhsu
Date: 2008-12-13 01:58:55 +0000 (Sat, 13 Dec 2008)
Log Message:
-----------
update battery controller in gazebo with default consumption rate of -10 J/s.
Modified Paths:
--------------
pkg/trunk/drivers/simulator/gazebo_plugin/include/gazebo_plugin/gazebo_battery.h
pkg/trunk/drivers/simulator/gazebo_plugin/src/gazebo_battery.cpp
pkg/trunk/robot_descriptions/wg_robot_description/pr2_robot_defs/gazebo_defs.xml
Modified: pkg/trunk/drivers/simulator/gazebo_plugin/include/gazebo_plugin/gazebo_battery.h
===================================================================
--- pkg/trunk/drivers/simulator/gazebo_plugin/include/gazebo_plugin/gazebo_battery.h 2008-12-13 01:22:37 UTC (rev 8049)
+++ pkg/trunk/drivers/simulator/gazebo_plugin/include/gazebo_plugin/gazebo_battery.h 2008-12-13 01:58:55 UTC (rev 8050)
@@ -151,14 +151,12 @@
/// \brief power drain, if this is negative, we are charging the battery.
private: double consumption_rate_;
+ private: double default_consumption_rate_;
/// \brief listen to ROS to see if we are charging
private: void SetPlug();
private: gazebo_plugin::PlugCommand plug_msg_;
-/// @todo make DISCHAGE_RATE something else
-#define DISCHARGE_RATE 1.0
-
};
/** \} */
Modified: pkg/trunk/drivers/simulator/gazebo_plugin/src/gazebo_battery.cpp
===================================================================
--- pkg/trunk/drivers/simulator/gazebo_plugin/src/gazebo_battery.cpp 2008-12-13 01:22:37 UTC (rev 8049)
+++ pkg/trunk/drivers/simulator/gazebo_plugin/src/gazebo_battery.cpp 2008-12-13 01:58:55 UTC (rev 8050)
@@ -82,8 +82,9 @@
/// faking the plug and unplug of robot
rosnode_->subscribe("plugged_in",this->plug_msg_,&GazeboBattery::SetPlug,this,10);
+ this->default_consumption_rate_ = node->GetDouble("default_consumption_rate",-10.0,0);
this->full_capacity_ = node->GetDouble("full_charge_energy",0.0,0);
- this->default_charge_rate_ = node->GetDouble("default_charge_rate",-2.0,0);
+ this->default_charge_rate_ = node->GetDouble("default_charge_rate",-10.0,0);
/// @todo make below useful
//this->diagnostic_rate_ = node->GetDouble("diagnostic_rate",1.0,0);
@@ -95,9 +96,9 @@
{
this->lock_.lock();
if (this->plug_msg_.status == "the robot is very much plugged into the wall")
- this->consumption_rate_ = this->default_charge_rate_ + DISCHARGE_RATE;
+ this->consumption_rate_ = this->default_charge_rate_ + this->default_consumption_rate_;
else
- this->consumption_rate_ = DISCHARGE_RATE;
+ this->consumption_rate_ = this->default_consumption_rate_;
this->lock_.unlock();
}
@@ -108,7 +109,7 @@
/// initialize battery
this->charge_ = this->full_capacity_; /// our convention is joules
- this->consumption_rate_ = DISCHARGE_RATE; /// time based decay rate in watts
+ this->consumption_rate_ = this->default_consumption_rate_; /// time based decay rate in watts
}
void GazeboBattery::UpdateChild()
@@ -120,7 +121,7 @@
/* update battery */
/* */
/**********************************************************/
- this->charge_ = this->charge_ - (this->current_time_ - this->last_time_)*this->consumption_rate_;
+ this->charge_ = this->charge_ + (this->current_time_ - this->last_time_)*this->consumption_rate_;
if (this->charge_ < 0) this->charge_ = 0;
if (this->charge_ > this->full_capacity_) this->charge_ = this->full_capacity_;
//std::cout << " battery charge remaining: " << this->charge_ << " Joules " << std::endl;
@@ -134,6 +135,7 @@
this->battery_state_.header.stamp.sec = (unsigned long)floor(this->current_time_);
this->battery_state_.header.stamp.nsec = (unsigned long)floor( 1e9 * ( this->current_time_ - this->battery_state_.header.stamp.sec) );
this->battery_state_.energy_remaining = this->charge_;
+ this->battery_state_.energy_capacity = this->full_capacity_;
this->battery_state_.power_consumption = this->consumption_rate_;
this->lock_.lock();
Modified: pkg/trunk/robot_descriptions/wg_robot_description/pr2_robot_defs/gazebo_defs.xml
===================================================================
--- pkg/trunk/robot_descriptions/wg_robot_description/pr2_robot_defs/gazebo_defs.xml 2008-12-13 01:22:37 UTC (rev 8049)
+++ pkg/trunk/robot_descriptions/wg_robot_description/pr2_robot_defs/gazebo_defs.xml 2008-12-13 01:58:55 UTC (rev 8050)
@@ -16,9 +16,10 @@
<alwaysOn>true</alwaysOn>
<updateRate>1.0</updateRate>
<timeout>5</timeout>
+ <default_consumption_rate>-10.0</default_consumption_rate> <!-- -5 is the magic number, need to be smaller than that CM -->
<diagnostic_rate>1.0</diagnostic_rate>
- <battery_state_rate>1.0</battery_state_rate>
- <full_charge_energy>120.0</full_charge_energy>
+ <battery_state_rate>10.0</battery_state_rate> <!-- does nothing for now-->
+ <full_charge_energy>1200000.0</full_charge_energy>
<diagnosticTopicName>diagnostic</diagnosticTopicName>
<stateTopicName>battery_state</stateTopicName>
<selfTestServiceName>self_test</selfTestServiceName>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|