Skip to content

Commit

Permalink
allow setting initial scale of aircraft in a mission file
Browse files Browse the repository at this point in the history
  • Loading branch information
esquires committed Feb 13, 2021
1 parent ab1ce08 commit 857aa88
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/source/overview/xml-tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,5 @@ and match between the two paradigms for a single entity.
- ``controller`` : whether to enable or disable running controller plugins in threads (``default = true``)
- ``motion`` : whether to enable or disable running motion plugins in threads (``default = true``)
- ``sensor`` : whether to enable or disable running sensor plugins in threads (``default = true``)

- ``scale``: the initial scale of the vehicles in the gui (``default = 1.0``)
2 changes: 2 additions & 0 deletions include/scrimmage/viewer/Updater.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class Updater : public vtkCommand {
const double &z);

void reset_scale();
void set_init_scale(double init_scale) {init_scale_ = init_scale;}

void set_reset_camera();
void set_camera_reset_params(double pos_x, double pos_y, double pos_z,
Expand Down Expand Up @@ -351,6 +352,7 @@ class Updater : public vtkCommand {

bool show_helpmenu_;
double label_scale_ = 0.3;
double init_scale_ = 1.0;
};

} // namespace scrimmage
Expand Down
2 changes: 2 additions & 0 deletions include/scrimmage/viewer/Viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class Viewer {
int local_port_ = 50051;
std::string remote_ip_ = "localhost";
int remote_port_ = 50052;

double init_scale_ = 1.0;
};

} // namespace scrimmage
Expand Down
2 changes: 1 addition & 1 deletion src/viewer/Updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@ void Updater::inc_follow_offset() {follow_offset_ *= 1.1;}
void Updater::dec_follow_offset() {follow_offset_ /= 1.1;}

void Updater::reset_scale() {
scale_ = 1.0;
scale_ = init_scale_;
scale_required_ = true;
}

Expand Down
3 changes: 3 additions & 0 deletions src/viewer/Viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ bool Viewer::init(const std::shared_ptr<MissionParse>& mp,
renderWindow_->SetFullScreen(false);
renderWindow_->SetSize(mp->window_width(), mp->window_height());
}
init_scale_ = get<double>("scale", mp->params(), 1.0);

log_dir_ = mp->log_dir();
dt_ = mp->dt();
Expand Down Expand Up @@ -134,6 +135,8 @@ bool Viewer::run() {
updater->set_incoming_interface(incoming_interface_);
updater->set_outgoing_interface(outgoing_interface_);
updater->set_max_update_rate(update_rate);
updater->set_init_scale(init_scale_);
updater->reset_scale();

std::string camera_pos_str =
get<std::string>("pos", camera_params_, "0, 1, 200");
Expand Down

0 comments on commit 857aa88

Please sign in to comment.