Skip to content

Commit

Permalink
More simulation code minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
okalachev committed Dec 29, 2023
1 parent 46ba00f commit 78f3f6e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions gazebo/simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
#include <cmath>
#include <gazebo/gazebo.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/rendering/rendering.hh>
#include <gazebo/common/common.hh>
#include <gazebo/sensors/sensors.hh>
#include <gazebo/msgs/msgs.hh>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Pose3.hh>
#include <ignition/math/Quaternion.hh>
#include <iostream>
#include <fstream>

Expand Down Expand Up @@ -55,7 +53,6 @@ class ModelFlix : public ModelPlugin {
gzmsg << "Flix plugin loaded" << endl;
}

public:
void OnReset() {
attitude = Quaternion(); // reset estimated attitude
gzmsg << "Flix plugin reset" << endl;
Expand All @@ -82,12 +79,12 @@ class ModelFlix : public ModelPlugin {
control();
parseInput();

applyMotorsThrust();
applyMotorForces();
publishTopics();
logData();
}

void applyMotorsThrust() {
void applyMotorForces() {
// thrusts
const double dist = 0.035355; // motors shift from the center, m
const double maxThrust = 0.03 * ONE_G; // ~30 g, https://youtu.be/VtKI4Pjx8Sk?&t=78
Expand Down Expand Up @@ -115,6 +112,7 @@ class ModelFlix : public ModelPlugin {
nodeHandle = transport::NodePtr(new transport::Node());
nodeHandle->Init();
string ns = "~/" + model->GetName();
// create motors output topics for debugging and plotting
motorPub[0] = nodeHandle->Advertise<msgs::Int>(ns + "/motor0");
motorPub[1] = nodeHandle->Advertise<msgs::Int>(ns + "/motor1");
motorPub[2] = nodeHandle->Advertise<msgs::Int>(ns + "/motor2");
Expand Down

0 comments on commit 78f3f6e

Please sign in to comment.