Skip to content

Commit

Permalink
Addresses #75 - Remove unessecary units conversion in TethysComms (#129)
Browse files Browse the repository at this point in the history
This PR attempts to remove unnecessary unit conversions in tethys from angular velocity -> force -> angular velocity.

Signed-off-by: Arjo Chakravarty <[email protected]>

Co-authored-by: Louise Poubel <[email protected]>
  • Loading branch information
arjo129 and chapulina authored Jan 27, 2022
1 parent babce6a commit a573a08
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 21 deletions.
1 change: 1 addition & 0 deletions lrauv_description/models/tethys_equipped/model.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<fluid_density>1025</fluid_density>
<propeller_diameter>0.2</propeller_diameter>
<velocity_control>true</velocity_control>
<use_angvel_cmd>true</use_angvel_cmd>
</plugin>
<plugin
filename="ignition-gazebo-joint-position-controller-system"
Expand Down
17 changes: 1 addition & 16 deletions lrauv_ignition_plugins/src/TethysCommPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,21 +412,8 @@ void TethysCommPlugin::CommandCallback(

// Thruster
ignition::msgs::Double thrusterMsg;
// TODO(arjo):
// Conversion from angular velocity to force b/c thruster plugin takes force
// Maybe we should change that?
// https://github.com/osrf/lrauv/issues/75
auto angVel = _msg.propomegaaction_();

// force = thrust_coefficient * fluid_density * omega ^ 2 *
// propeller_diameter ^ 4
// These values are defined in the model's Thruster plugin's SDF
auto force = 0.004312328425753156 * this->oceanDensity * pow(0.2, 4) * angVel * angVel;
if (angVel < 0)
{
force *=-1;
}
thrusterMsg.set_data(force);
thrusterMsg.set_data(angVel);
this->thrusterPub.Publish(thrusterMsg);

// Mass shifter
Expand Down Expand Up @@ -495,8 +482,6 @@ void TethysCommPlugin::PostUpdate(
int(std::chrono::duration_cast<std::chrono::nanoseconds>(
_info.simTime).count()) - stateMsg.header().stamp().sec() * 1000000000);

// TODO(anyone) Maybe angular velocity should come from ThrusterPlugin
// Propeller angular velocity
auto propAngVelComp =
_ecm.Component<ignition::gazebo::components::JointVelocity>(thrusterJoint);
if (propAngVelComp->Data().size() != 1)
Expand Down
2 changes: 1 addition & 1 deletion lrauv_ignition_plugins/src/TethysCommPlugin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace tethys

/// Topic to publish to for thruster
private: std::string thrusterTopic
{"propeller_joint/cmd_pos"};
{"propeller_joint/cmd_vel"};

/// Topic to publish to for rudder
private: std::string rudderTopic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@ void commandVehicleForward(const std::string &_name)
transport::Node node;
auto pub =
node.Advertise<msgs::Double>(
"/model/" + _name + "/joint/propeller_joint/cmd_thrust");
"/model/" + _name + "/joint/propeller_joint/cmd_vel");

msgs::Double thrustCmd;

// 300 rpm -> 31.42rads^-1
// -> (31.42rads^-1)^2 * 0.004422 (thrust coeff) * 1000 (fluid density)
// * 0.2m ^ 4 (prop diameter) = 6.9857
thrustCmd.set_data(6.9857);
thrustCmd.set_data(31.42);

int sleep{0};
int maxSleep{30};
Expand Down

0 comments on commit a573a08

Please sign in to comment.