Skip to content

Commit

Permalink
Generalized RotorVector
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-elsaharti committed Feb 1, 2021
1 parent 7817e33 commit 83e3a6d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions AirLib/include/api/RpcLibAdapatorsBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class RpcLibAdapatorsBase {
}
};
struct RotorVector {
RotorParameters rotor[4];
std::vector<RotorParameters> rotor;

MSGPACK_DEFINE_MAP(rotor);

Expand All @@ -74,16 +74,18 @@ class RpcLibAdapatorsBase {

RotorVector(const msr::airlib::RotorVector& s)
{
for (unsigned int i = 0; i < 5; i++)
rotor.clear();
for (unsigned int i = 0; i < s.rotor.size(); i++)
{
rotor.push_back(RotorParameters());
rotor[i] = s.rotor[i];
}
}

msr::airlib::RotorVector to() const
{
msr::airlib::RotorVector d;
for (unsigned int i = 0; i < 5; i++)
for (unsigned int i = 0; i < d.rotor.size(); i++)
{
d.rotor[i].speed = rotor[i].speed;
d.rotor[i].thrust = rotor[i].thrust;
Expand Down
2 changes: 1 addition & 1 deletion AirLib/include/common/CommonStructs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct RotorParameters {
{}
};
struct RotorVector {
RotorParameters rotor[4];
std::vector<RotorParameters> rotor;

RotorVector()
{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ void MultirotorPawnSimApi::updateRenderedState(float dt)
collision_response = multirotor_physics_body_->getCollisionResponseInfo();

//update rotor poses
rotor_states_.rotors.rotor.clear();
for (unsigned int i = 0; i < rotor_count_; ++i) {
const auto& rotor_output = multirotor_physics_body_->getRotorOutput(i);
// update private rotor variable
rotor_states_.rotors.rotor.push_back(RotorParameters());
rotor_states_.rotors.rotor[i].speed = rotor_output.speed;
rotor_states_.rotors.rotor[i].thrust = rotor_output.thrust;
rotor_states_.rotors.rotor[i].torque_scaler = rotor_output.torque_scaler;
Expand Down

0 comments on commit 83e3a6d

Please sign in to comment.