Commit 8767cf7b authored by Lorenz Meier's avatar Lorenz Meier
Browse files

Fix Gazebo 6 compile warning, make props only spin when armed.

parent 60b2ee59
......@@ -163,6 +163,7 @@ class GazeboMavlinkInterface : public ModelPlugin {
common::Time last_time_;
common::Time last_gps_time_;
common::Time last_actuator_time_;
double gps_update_interval_;
double lat_rad;
double lon_rad;
......
......@@ -166,9 +166,12 @@ void GazeboMavlinkInterface::OnUpdate(const common::UpdateInfo& /*_info*/) {
mav_msgs::msgs::CommandMotorSpeed turning_velocities_msg;
for (int i = 0; i < input_reference_.size(); i++){
turning_velocities_msg.add_motor_speed(input_reference_[i]);
if (last_actuator_time_ == 0 || (now - last_actuator_time_).Double() > 0.2) {
turning_velocities_msg.add_motor_speed(0);
} else {
turning_velocities_msg.add_motor_speed(input_reference_[i]);
}
}
// TODO Add timestamp and Header
// turning_velocities_msg->header.stamp.sec = now.sec;
......@@ -490,6 +493,8 @@ void GazeboMavlinkInterface::handle_message(mavlink_message_t *msg)
// TODO XXX: this makes SITL work again
bool is_fixed_wing = false;
last_actuator_time_ = world_->GetSimTime();
input_reference_.resize(_rotor_count);
// set rotor speeds for all systems
......@@ -505,7 +510,7 @@ void GazeboMavlinkInterface::handle_message(mavlink_message_t *msg)
// set angles of control surface joints (this should go into a message for the correct plugin)
double roll = 0.5 * (inputs.control[4] + inputs.control[5]);
double pitch = 0.5 * (inputs.control[4] - inputs.control[5]);
#if GAZEBO_MAJOR_VERSION >= 7
#if GAZEBO_MAJOR_VERSION >= 6
left_elevon_joint_->SetPosition(0, roll);
right_elevon_joint_->SetPosition(0, -roll);
elevator_joint_->SetPosition(0, -pitch);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment