class ugcs::vsm::Vehicle

Overview

Base class for user-defined vehicles. More…

#include <vehicle.h>

class Vehicle: public ugcs::vsm::Device
{
public:
    // typedefs

    typedef std::shared_ptr<Vehicle> Ptr;
    typedef std::weak_ptr<Vehicle> Weak_ptr;

    // classes

    class Command_map;
    class Hasher;

    // construction

    Vehicle(
        proto::Device_type type = proto::DEVICE_TYPE_VEHICLE,
        Request_processor::Ptr processor = nullptr,
        Request_completion_context::Ptr completion_ctx = nullptr
        );

    Vehicle(const Vehicle&);

    // methods

    template <typename... Args>
    static Ptr Create(Args&&... args);

    void Process_requests();
    void Set_serial_number(const std::string&);
    const std::string& Get_serial_number() const;
    const std::string& Get_model_name() const;
    void Set_model_name(const std::string&);
    void Set_port_name(const std::string&);
    const std::string& Get_port_name() const;
    const std::string& Get_frame_type() const;
    void Set_frame_type(const std::string&);
    proto::Vehicle_type Get_vehicle_type() const;
    void Set_vehicle_type(proto::Vehicle_type);
    bool Is_vehicle_type(proto::Vehicle_type type);
    bool Is_copter();
};

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<Device> Ptr;
    typedef std::weak_ptr<Device> Weak_ptr;
    typedef Callback_proxy<void, std::vector<Property::Ptr>> Command_handler;
    typedef Callback_proxy<void, uint32_t, Proto_msg_ptr> Response_sender;

    // classes

    class Commit_scope;

    // methods

    template <typename... Args>
    static Ptr Create(Args&&... args);

    static void Set_failsafe_actions(Property::Ptr p, std::initializer_list<proto::Failsafe_action> actions);
    void Enable();
    void Disable();
    bool Is_enabled();

    void On_ucs_message(
        ugcs::vsm::proto::Vsm_message message,
        Response_sender completion_handler = Response_sender(),
        ugcs::vsm::Request_completion_context::Ptr completion_ctx = nullptr
        );

    void Register(ugcs::vsm::proto::Vsm_message&);

    template <typename Type>
    Property::Ptr Set_property(
        const std::string& name,
        Type value,
        proto::Field_semantic semantic = proto::FIELD_SEMANTIC_DEFAULT
        );

    uint32_t Get_session_id();
    Request_completion_context::Ptr Get_completion_ctx();
    void Register();
    void Unregister();
    bool Is_registered();
    std::string Dump_command(const ugcs::vsm::proto::Device_command&);
    Subsystem::Ptr Add_subsystem(proto::Subsystem_type);
    Request_processor::Ptr Get_processing_ctx();
    virtual void Handle_ucs_info(std::vector<Ucs_info>);

Detailed Documentation

Base class for user-defined vehicles.

It contains interface to SDK services which can be used as base class methods calls, and abstract interface which must be implemented by the device. Instance creation should be done by Vehicle::Create() method.

Typedefs

typedef std::shared_ptr<Vehicle> Ptr

Pointer type.

typedef std::weak_ptr<Vehicle> Weak_ptr

Pointer type.

Construction

Vehicle(
    proto::Device_type type = proto::DEVICE_TYPE_VEHICLE,
    Request_processor::Ptr processor = nullptr,
    Request_completion_context::Ptr completion_ctx = nullptr
    )

Constructor for a base class.

Create common telemetry fields and commands.

Parameters:

create_thread

If true, then separate thread is automatically created for vehicle instance which allows to using blocking methods in the context of this vehicle without blocking other vehicles, otherwise vehicle instance thread is not created and user is supposed to call Vehicle::Process_requests method to process requests pending for this vehicle. It is recommended to leave this value as default, i.e. “true”.

Vehicle(const Vehicle&)

Disable copying.

Methods

template <typename... Args>
static Ptr Create(Args&&... args)

Create an instance.

void Process_requests()

Process requests assigned to vehicle in user thread, i.e.

the thread which calls this method. Supposed to be called only when vehicle is created without its own thread.

void Set_serial_number(const std::string&)

Set serial number.

const std::string& Get_serial_number() const

Get serial number of the vehicle.

const std::string& Get_model_name() const

Get model name of the vehicle.

void Set_model_name(const std::string&)

Set model name of the vehicle.

void Set_port_name(const std::string&)

Set port name.

const std::string& Get_port_name() const

Get port name the vehicle is connected to.

const std::string& Get_frame_type() const

Get frame type of the vehicle.

void Set_frame_type(const std::string&)

Set frame type of the vehicle.