Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AttitudeAngularVelocityBody, AttitudeAngularVelocityBody and ActuatorOutputStatus to telemetry #832

Merged
merged 6 commits into from
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion proto
124 changes: 107 additions & 17 deletions src/backend/src/generated/telemetry/telemetry.grpc.pb.cc

Large diffs are not rendered by default.

599 changes: 523 additions & 76 deletions src/backend/src/generated/telemetry/telemetry.grpc.pb.h

Large diffs are not rendered by default.

7,429 changes: 4,949 additions & 2,480 deletions src/backend/src/generated/telemetry/telemetry.pb.cc

Large diffs are not rendered by default.

2,551 changes: 2,059 additions & 492 deletions src/backend/src/generated/telemetry/telemetry.pb.h

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions src/backend/src/plugins/telemetry/telemetry_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,34 @@ class TelemetryServiceImpl final : public mavsdk::rpc::telemetry::TelemetryServi
return grpc::Status::OK;
}

grpc::Status SubscribeAttitudeAngularVelocityBody(
grpc::ServerContext* /* context */,
const mavsdk::rpc::telemetry::SubscribeAttitudeAngularVelocityBodyRequest* /* request */,
grpc::ServerWriter<rpc::telemetry::AttitudeAngularVelocityBodyResponse>* writer) override
{
std::mutex attitude_angular_velocity_body_mutex{};

_telemetry.attitude_angular_velocity_body_async(
[&writer, &attitude_angular_velocity_body_mutex](
mavsdk::Telemetry::AngularVelocityBody angular_velocity_body) {
auto rpc_angular_velocity_body = new mavsdk::rpc::telemetry::AngularVelocityBody();
rpc_angular_velocity_body->set_roll_rad_s(angular_velocity_body.roll_rad_s);
rpc_angular_velocity_body->set_pitch_rad_s(angular_velocity_body.pitch_rad_s);
rpc_angular_velocity_body->set_yaw_rad_s(angular_velocity_body.yaw_rad_s);

mavsdk::rpc::telemetry::AttitudeAngularVelocityBodyResponse
rpc_angular_velocity_body_response;
rpc_angular_velocity_body_response.set_allocated_attitude_angular_velocity_body(
rpc_angular_velocity_body);

std::lock_guard<std::mutex> lock(attitude_angular_velocity_body_mutex);
writer->Write(rpc_angular_velocity_body_response);
});

_stop_future.wait();
return grpc::Status::OK;
}

grpc::Status SubscribeAttitudeEuler(
grpc::ServerContext* /* context */,
const mavsdk::rpc::telemetry::SubscribeAttitudeEulerRequest* /* request */,
Expand Down Expand Up @@ -440,6 +468,66 @@ class TelemetryServiceImpl final : public mavsdk::rpc::telemetry::TelemetryServi
return grpc::Status::OK;
}

grpc::Status SubscribeActuatorControlTarget(
grpc::ServerContext* /* context */,
const mavsdk::rpc::telemetry::SubscribeActuatorControlTargetRequest* /* request */,
grpc::ServerWriter<rpc::telemetry::ActuatorControlTargetResponse>* writer) override
{
std::mutex actuator_control_target_mutex{};

_telemetry.actuator_control_target_async(
[&writer, &actuator_control_target_mutex](
mavsdk::Telemetry::ActuatorControlTarget actuator_control_target) {
auto rpc_actuator_control_target =
new mavsdk::rpc::telemetry::ActuatorControlTarget();
rpc_actuator_control_target->set_group(actuator_control_target.group);
for (int i = 0; i < 8; i++) {
rpc_actuator_control_target->add_controls(actuator_control_target.controls[i]);
}

mavsdk::rpc::telemetry::ActuatorControlTargetResponse
rpc_actuator_control_target_response;
rpc_actuator_control_target_response.set_allocated_actuator_control_target(
rpc_actuator_control_target);

std::lock_guard<std::mutex> lock(actuator_control_target_mutex);
writer->Write(rpc_actuator_control_target_response);
});

_stop_future.wait();
return grpc::Status::OK;
}

grpc::Status SubscribeActuatorOutputStatus(
grpc::ServerContext* /* context */,
const mavsdk::rpc::telemetry::SubscribeActuatorOutputStatusRequest* /* request */,
grpc::ServerWriter<rpc::telemetry::ActuatorOutputStatusResponse>* writer) override
{
std::mutex actuator_output_status_mutex{};

_telemetry.actuator_output_status_async(
[&writer, &actuator_output_status_mutex](
mavsdk::Telemetry::ActuatorOutputStatus actuator_output_status) {
auto rpc_actuator_output_status =
new mavsdk::rpc::telemetry::ActuatorOutputStatus();
rpc_actuator_output_status->set_active(actuator_output_status.active);
for (unsigned i = 0; i < actuator_output_status.active; i++) {
rpc_actuator_output_status->add_actuator(actuator_output_status.actuator[i]);
}

mavsdk::rpc::telemetry::ActuatorOutputStatusResponse
rpc_actuator_output_status_response;
rpc_actuator_output_status_response.set_allocated_actuator_output_status(
rpc_actuator_output_status);

std::lock_guard<std::mutex> lock(actuator_output_status_mutex);
writer->Write(rpc_actuator_output_status_response);
});

_stop_future.wait();
return grpc::Status::OK;
}

void stop() { _stop_promise.set_value(); }

private:
Expand Down
Loading