Skip to content

Commit

Permalink
Renaming twist_2d (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayrton04 authored Aug 14, 2019
1 parent cc3dda2 commit c135c20
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 34 deletions.
2 changes: 1 addition & 1 deletion fuse_models/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ add_library(
src/odometry_2d.cpp
src/odometry_2d_publisher.cpp
src/pose_2d.cpp
src/twist_2d/model.cpp
src/twist_2d.cpp
src/unicycle_2d/state_kinematic_constraint.cpp
src/unicycle_2d/ignition.cpp
src/unicycle_2d/model.cpp
Expand Down
2 changes: 1 addition & 1 deletion fuse_models/fuse_plugins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
An adapter-type sensor that produces absolute velocity constraints from information published by another node
</description>
</class>
<class type="fuse_models::twist_2d::Model" base_class_type="fuse_core::SensorModel">
<class type="fuse_models::Twist2D" base_class_type="fuse_core::SensorModel">
<description>
An adapter-type sensor that produces absolute velocity constraints from information published by another node
</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef FUSE_MODELS_PARAMETERS_TWIST_2D_MODEL_PARAMS_H
#define FUSE_MODELS_PARAMETERS_TWIST_2D_MODEL_PARAMS_H
#ifndef FUSE_MODELS_PARAMETERS_TWIST_2D_PARAMS_H
#define FUSE_MODELS_PARAMETERS_TWIST_2D_PARAMS_H

#include <fuse_models/parameters/parameter_base.h>

Expand All @@ -51,9 +51,9 @@ namespace parameters
{

/**
* @brief Defines the set of parameters required by the twist_2d::Model class
* @brief Defines the set of parameters required by the Twist2D class
*/
struct Twist2DModelParams : public ParameterBase
struct Twist2DParams : public ParameterBase
{
public:
/**
Expand Down Expand Up @@ -82,4 +82,4 @@ struct Twist2DModelParams : public ParameterBase

} // namespace fuse_models

#endif // FUSE_MODELS_PARAMETERS_TWIST_2D_MODEL_PARAMS_H
#endif // FUSE_MODELS_PARAMETERS_TWIST_2D_PARAMS_H
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef FUSE_MODELS_TWIST_2D_MODEL_H
#define FUSE_MODELS_TWIST_2D_MODEL_H
#ifndef FUSE_MODELS_TWIST_2D_H
#define FUSE_MODELS_TWIST_2D_H

#include <fuse_models/parameters/twist_2d_model_params.h>
#include <fuse_models/parameters/twist_2d_params.h>

#include <fuse_core/async_sensor_model.h>
#include <fuse_core/uuid.h>
Expand All @@ -47,9 +47,6 @@
namespace fuse_models
{

namespace twist_2d
{

/**
* @brief An adapter-type sensor that produces absolute velocity constraints from information published by another node
*
Expand All @@ -65,21 +62,21 @@ namespace twist_2d
* Subscribes:
* - \p topic (geometry_msgs::TwistWithCovarianceStamped) Absolute velocity information at a given timestamp
*/
class Model : public fuse_core::AsyncSensorModel
class Twist2D : public fuse_core::AsyncSensorModel
{
public:
SMART_PTR_DEFINITIONS(Model);
using ParameterType = parameters::Twist2DModelParams;
SMART_PTR_DEFINITIONS(Twist2D);
using ParameterType = parameters::Twist2DParams;

/**
* @brief Default constructor
*/
Model();
Twist2D();

/**
* @brief Destructor
*/
virtual ~Model() = default;
virtual ~Twist2D() = default;

/**
* @brief Callback for twist messages
Expand Down Expand Up @@ -114,8 +111,6 @@ class Model : public fuse_core::AsyncSensorModel
ros::Subscriber subscriber_;
};

} // namespace twist_2d

} // namespace fuse_models

#endif // FUSE_MODELS_TWIST_2D_MODEL_H
#endif // FUSE_MODELS_TWIST_2D_H
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <fuse_models/common/sensor_proc.h>
#include <fuse_models/twist_2d/model.h>
#include <fuse_models/twist_2d.h>

#include <fuse_core/transaction.h>
#include <fuse_core/uuid.h>
Expand All @@ -43,22 +43,19 @@


// Register this sensor model with ROS as a plugin.
PLUGINLIB_EXPORT_CLASS(fuse_models::twist_2d::Model, fuse_core::SensorModel)
PLUGINLIB_EXPORT_CLASS(fuse_models::Twist2D, fuse_core::SensorModel)

namespace fuse_models
{

namespace twist_2d
{

Model::Model() :
Twist2D::Twist2D() :
fuse_core::AsyncSensorModel(1),
device_id_(fuse_core::uuid::NIL),
tf_listener_(tf_buffer_)
{
}

void Model::onInit()
void Twist2D::onInit()
{
// Read settings from the parameter sever
device_id_ = fuse_variables::loadDeviceId(private_node_handle_);
Expand All @@ -73,21 +70,22 @@ void Model::onInit()
}
}

void Model::onStart()
void Twist2D::onStart()
{
if (!params_.linear_indices.empty() ||
!params_.angular_indices.empty())
{
subscriber_ = node_handle_.subscribe(ros::names::resolve(params_.topic), params_.queue_size, &Model::process, this);
subscriber_ =
node_handle_.subscribe(ros::names::resolve(params_.topic), params_.queue_size, &Twist2D::process, this);
}
}

void Model::onStop()
void Twist2D::onStop()
{
subscriber_.shutdown();
}

void Model::process(const geometry_msgs::TwistWithCovarianceStamped::ConstPtr& msg)
void Twist2D::process(const geometry_msgs::TwistWithCovarianceStamped::ConstPtr& msg)
{
// Create a transaction object
auto transaction = fuse_core::Transaction::make_shared();
Expand All @@ -106,6 +104,4 @@ void Model::process(const geometry_msgs::TwistWithCovarianceStamped::ConstPtr& m
sendTransaction(transaction);
}

} // namespace twist_2d

} // namespace fuse_models

0 comments on commit c135c20

Please sign in to comment.