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 Gps Sensor to IGN-Sensors library #72

Closed
wants to merge 4 commits into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ build

# Version control generated files
*.orig
.vscode
135 changes: 135 additions & 0 deletions include/ignition/sensors/GpsSensor.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
* Copyright (C) 2020 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef IGNITION_SENSORS_GPS_HH_
#define IGNITION_SENSORS_GPS_HH_

#include <memory>

#include <sdf/sdf.hh>

#include <ignition/common/SuppressWarning.hh>
#include <ignition/common/Time.hh>

#include <ignition/sensors/config.hh>
#include <ignition/sensors/gps/Export.hh>

#include "ignition/sensors/Sensor.hh"

namespace ignition
{
namespace sensors
{
// Inline bracket to help doxygen filtering.
inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
//
/// \brief forward declarations
class GpsPrivate;

/// \brief Gps Sensor Class
///
/// An gps sensor that reports vertical position and velocity
/// readings over ign transport
class IGNITION_SENSORS_GPS_VISIBLE GpsSensor : public Sensor
{
/// \brief constructor
public: GpsSensor();

/// \brief destructor
public: virtual ~GpsSensor();

/// \brief Load the sensor based on data from an sdf::Sensor object.
/// \param[in] _sdf SDF Sensor parameters.
/// \return true if loading was successful
public: virtual bool Load(const sdf::Sensor &_sdf) override;

/// \brief Load the sensor with SDF parameters.
/// \param[in] _sdf SDF Sensor parameters.
/// \return true if loading was successful
public: virtual bool Load(sdf::ElementPtr _sdf) override;

/// \brief Initialize values in the sensor
/// \return True on success
public: virtual bool Init() override;

/// \brief Update the sensor and generate data
/// \param[in] _now The current time
/// \return true if the update was successfull
public: virtual bool IGN_DEPRECATED(4) Update(
const ignition::common::Time &_now) override;

/// \brief Update the sensor and generate data
/// \param[in] _now The current time
/// \return true if the update was successfull
public: virtual bool Update(
const std::chrono::steady_clock::duration &_now) override;



/// \brief Set the latitude of the GPS
/// \param[in] _latitude Latitude of GPS in degrees
public: void SetLatitude(double _latitude);

/// \brief Get the latitude of the GPS, wraped between +/- 180
/// \return Latitude in degrees.
public: double Latitude() const;


/// \brief Set the longitude of the GPS
/// \param[in] _longitude Longitude of GPS in degrees
public: void SetLongitude(double _longitude);

/// \brief Get the longitude of the GPS, wraped between +/- 180
/// \return Longitude in degrees.
public: double Longitude() const;


/// \brief Set the altitude of the GPS
/// \param[in] _altitude altitude of GPS in meters
public: void SetAltitude(double _altitude);

/// \brief GPS altitude is the GEOMETRIC altitude above sea level
/// \return Altitude in meters
public: double Altitude() const;


/// \brief Set the velocity of the GPS
/// \param[in] _vel vector3 of GPS in meters per second.
public: void SetVelocity(ignition::math::Vector3d &_vel);

/// \brief Get the velocity of the GPS sensor
/// \return velocity vector3 in meters per second
public: ignition::math::Vector3d Velocity() const;


/// \brief Easy short hand for setting the lat/long of the gps.
Comment on lines +115 to +118
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public: ignition::math::Vector3d Velocity() const;
/// \brief Easy short hand for setting the lat/long of the gps.
public: ignition::math::Vector3d Velocity() const;
/// \brief Easy short hand for setting the lat/long of the gps.

/// \param[in] _latitude in degrees
/// \param[in] _longitude in degrees
public: void SetPosition(double _latitude, double _longitude,
double _altitude = 0.0);


IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
/// \brief Data pointer for private data
/// \internal
private: std::unique_ptr<GpsPrivate> dataPtr;
IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
};
}
}
}

#endif
16 changes: 16 additions & 0 deletions include/ignition/sensors/SensorTypes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,22 @@ namespace ignition
/// \sa Lidar
LIDAR_NOISE = 14,

/// \brief Noise streams for the Gps position sensor
/// \sa Gps
GPS_HORIZONTAL_POSITION_NOISE = 15,

/// \brief Noise streams for the Gps position sensor
/// \sa Gps
GPS_VERTICAL_POSITION_NOISE = 16,

/// \brief Noise streams for the Gps velocity sensor
/// \sa Gps
GPS_HORIZONTAL_VELOCITY_NOISE = 17,

/// \brief Noise streams for the Gps velocity sensor
/// \sa Gps
GPS_VERTICAL_VELOCITY_NOISE = 18,

/// \internal
/// \brief Indicator used to create an iterator over the enum. Do not
/// use this.
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ ign_add_component(imu SOURCES ${imu_sources} GET_TARGET_NAME imu_target)
set(altimeter_sources AltimeterSensor.cc)
ign_add_component(altimeter SOURCES ${altimeter_sources} GET_TARGET_NAME altimeter_target)

set(gps_sources GpsSensor.cc)
ign_add_component(gps SOURCES ${gps_sources} GET_TARGET_NAME gps_target)

set(air_pressure_sources AirPressureSensor.cc)
ign_add_component(air_pressure SOURCES ${air_pressure_sources} GET_TARGET_NAME air_pressure_target)

Expand Down
Loading