-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Newer Battery #92
Open
DaanZ
wants to merge
20
commits into
development
Choose a base branch
from
battery
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Newer Battery #92
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
2091701
implemented battery
roy-basmacier 6b08550
implemented battery
roy-basmacier 03ffcad
implemented battery
roy-basmacier 607c3d4
adjusted for testing the battery levels
roy-basmacier 935aa80
fixed directory for battery data
roy-basmacier 08f83cd
fixed directory for battery data and speed data
roy-basmacier 35e9d50
fixed directory for battery data and speed data
roy-basmacier dd5daa2
fixed directory for battery data and speed data
roy-basmacier 81484c8
fixed directory for battery data and speed data
roy-basmacier f2f0dd8
fixed merge requests
roy-basmacier 039c028
Update PositionMotor.cpp
roy-basmacier 5776139
Update PositionMotor.cpp
roy-basmacier 04614a2
Update PositionMotor.cpp
roy-basmacier d2e2a62
Merged battery roy's branch into revolve battery branched from develo…
DaanZ 7fdf4fa
Patch merge commit
DaanZ a0dd716
Integrating Battery with RobotController instead of WorldController.
DaanZ 2cbf923
Removed legacy battery functions, but this will cause no change to th…
DaanZ d1a6c6a
Removed legacy battery functions, but this will cause no change to th…
DaanZ 1627a11
Processing pull request review comments on alignment, tabs and typo's.
DaanZ d4c01e2
Reviewed battery code
DaanZ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,31 @@ | ||
// | ||
// Created by Roy Basmacier on 2019-07-09. | ||
// | ||
|
||
#include "Battery.h" | ||
|
||
using namespace revolve::gazebo; | ||
|
||
Battery::Battery(double initial_charge) | ||
: initial_charge(initial_charge), current_charge(initial_charge), time_init(std::to_string(time(0))), robot_name("") | ||
{} | ||
|
||
void Battery::Update(double global_time, double delta_time) | ||
{ | ||
double sum = 0.0; | ||
// std::cout << "battery: " << this->Voltage() << "V" << std::endl; | ||
for (const auto &consumer: this->PowerLoads()) { | ||
// std::cout << "comsumer: " << consumer.first << " -> " << consumer.second << std::endl; | ||
sum += consumer.second; // TODO add constant so its linear | ||
} | ||
this->current_charge += sum * delta_time; // charge is measured in joules | ||
|
||
//TODO properly save battery data somewhere | ||
/* | ||
std::ofstream b_info_file; | ||
b_info_file.open("output/cpg_bo/" + this->robot_name + "/" + this->time_init + "/battery.txt", std::ios_base::app); | ||
if (b_info_file.fail()) | ||
std::cout << "Failed to open: " << b_info_file.fail() << " " << "output/cpg_bo/" + this->robot_name + "/" + this->time_init + "/battery.txt" << std::endl; | ||
b_info_file << global_time << " " << sum << " " << current_charge << std::endl; | ||
*/ | ||
} |
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,46 @@ | ||
// | ||
// Created by Roy Basmacier on 2019-07-09. | ||
// | ||
|
||
#ifndef REVOLVE_BATTERY_H | ||
#define REVOLVE_BATTERY_H | ||
|
||
|
||
#include <gazebo/gazebo.hh> | ||
#include <gazebo/physics/physics.hh> | ||
#include <gazebo/common/common.hh> | ||
#include <gazebo/msgs/msgs.hh> | ||
|
||
#include <revolve/gazebo/Types.h> | ||
|
||
namespace revolve{ | ||
namespace gazebo{ | ||
|
||
class Battery : public ::gazebo::common::Battery | ||
{ | ||
public: | ||
explicit Battery(double initial_charge); | ||
|
||
void Update(double global_time, double delta_time); | ||
|
||
protected: | ||
/// \brief initial charge of the battery in joules | ||
double initial_charge; // it is set in RobotController.cpp | ||
|
||
/// \brief current charge of the battery in joules | ||
double current_charge; | ||
|
||
/// \brief the time of initiation (for creating data files of battery delete later) | ||
std::string time_init; | ||
|
||
std::string robot_name; | ||
|
||
friend class RobotController; | ||
friend class Evaluator; | ||
friend class DifferentialCPG; | ||
}; | ||
|
||
} | ||
} | ||
|
||
#endif //REVOLVE_BATTERY_H |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There has to be a better way to this (this is only UNIX for example). Also it could be a security issue