-
Notifications
You must be signed in to change notification settings - Fork 17
Add support of the new power-board hardware #15
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
Open
paLeziart
wants to merge
3
commits into
open-dynamic-robot-initiative:main
Choose a base branch
from
paLeziart:support-power-board
base: main
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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,56 @@ | ||
/** | ||
* @file powerboard.hpp | ||
* @author Pierre-Alexandre Leziart ([email protected]) | ||
* license License BSD-3-Clause | ||
* @copyright Copyright (c) 2022, New York University, Max Planck | ||
* Gesellschaft and LAAS-CNRS | ||
* @date 2022-04-19 | ||
* | ||
* @brief Powerboard abstraction. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <math.h> | ||
#include <unistd.h> | ||
#include <stdexcept> | ||
|
||
#include "master_board_sdk/defines.h" | ||
#include "master_board_sdk/master_board_interface.h" | ||
|
||
#include <odri_control_interface/common.hpp> | ||
|
||
namespace odri_control_interface | ||
{ | ||
/** | ||
* @brief Class for dealing with the powerboard. | ||
*/ | ||
class Powerboard | ||
{ | ||
protected: | ||
std::shared_ptr<MasterBoardInterface> robot_if_; | ||
|
||
// Cache for the results. | ||
double current_; | ||
double voltage_; | ||
double energy_; | ||
|
||
public: | ||
Powerboard(const std::shared_ptr<MasterBoardInterface>& robot_if); | ||
|
||
// If needed, add some error handling for the powerboard as well. | ||
// For instance, check for low voltage or high current | ||
bool HasError() | ||
{ | ||
return false; | ||
} | ||
|
||
void ParseSensorData(); | ||
|
||
const std::shared_ptr<MasterBoardInterface>& GetMasterBoardInterface(); | ||
double GetCurrent(); | ||
double GetVoltage(); | ||
double GetEnergy(); | ||
}; | ||
|
||
} // namespace odri_control_interface |
This file contains hidden or 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 hidden or 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,50 @@ | ||
/** | ||
* @file powerboard.hpp | ||
* @author Pierre-Alexandre Leziart ([email protected]) | ||
* license License BSD-3-Clause | ||
* @copyright Copyright (c) 2020, New York University and Max Planck | ||
* Gesellschaft. | ||
* @date 2021-08-23 | ||
* | ||
* @brief Powerboard abstraction. | ||
*/ | ||
|
||
#include "odri_control_interface/powerboard.hpp" | ||
|
||
#include <iostream> | ||
|
||
namespace odri_control_interface | ||
{ | ||
Powerboard::Powerboard(const std::shared_ptr<MasterBoardInterface>& robot_if) | ||
: robot_if_(robot_if) | ||
{ | ||
} | ||
|
||
const std::shared_ptr<MasterBoardInterface>& Powerboard::GetMasterBoardInterface() | ||
{ | ||
return robot_if_; | ||
} | ||
|
||
double Powerboard::GetCurrent() | ||
{ | ||
return current_; | ||
} | ||
|
||
double Powerboard::GetVoltage() | ||
{ | ||
return voltage_; | ||
} | ||
|
||
double Powerboard::GetEnergy() | ||
{ | ||
return energy_; | ||
} | ||
|
||
void Powerboard::ParseSensorData() | ||
{ | ||
current_ = robot_if_->powerboard_current(); | ||
voltage_ = robot_if_->powerboard_voltage(); | ||
energy_ = robot_if_->powerboard_energy(); | ||
} | ||
|
||
} // namespace odri_control_interface |
This file contains hidden or 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 hidden or 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 hidden or 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
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.
This by default creates a power board. Does this make sense or should there be a flag in the yaml file to indicated if the powerboard is available on a robot or not?
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.
At the moment, the MasterBoard protocol will include all the fields even if a power board is not present. If so the values will read 0.
This is the same with the IMU.
We could in the future have the MasterBoard to auto detect the presence of IMU, PowerBoard and number of uDrivers. According to this, the network packets could be lighten. An expected hardware description via flags in the yaml could then allow to generate an error if some components are missing.
I think this is out of the scope if this PR, and the proposed implementation is coherent with IMU.
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.
Makes sense, thanks for the clearification.
About the master board SDK: Do we need to reflash all our master boards once the software changes to the SDK land that include the power board, even the ones that do not use a power board to get the zero values?
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.
Yes, all master boards will need to be updated together with the sdk.
My advice would be to flash your master board with open-dynamic-robot-initiative/master-board#107 as it's solves old issue we have.