##

KeysToJointsPlugin.hh
Go to the documentation of this file.
/*
* Copyright (C) 2016 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 GAZEBO_PLUGINS_KEYSTOJOINTSPLUGIN_HH_
#define GAZEBO_PLUGINS_KEYSTOJOINTSPLUGIN_HH_
#include <string>
#include <vector>
#include <ignition/transport/Node.hh>
#include <gazebo/common/Plugin.hh>
#include <gazebo/transport/Node.hh>
namespace gazebo
{
struct KeyInfo
{
// cppcheck-suppress unusedStructMember
int key;
physics::JointPtr joint;
std::string type;
// cppcheck-suppress unusedStructMember
double scale;
};
class GAZEBO_VISIBLE KeysToJointsPlugin : public ModelPlugin
{
public: KeysToJointsPlugin();
public: ~KeysToJointsPlugin();
// Documentation inherited
public: virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf);
private: void OnKeyPress(ConstAnyPtr &_msg);
private: std::vector<KeyInfo> keys;
private: physics::ModelPtr model;
private: transport::NodePtr node;
private: transport::SubscriberPtr keyboardSub;
// Place ignition::transport objects at the end of this file to
// guarantee they are destructed first.
private: ignition::transport::Node nodeIgn;
};
}
#endif
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::physics::ModelPtr
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
gazebo::KeyInfo::joint
physics::JointPtr joint
Pointer to the joint controlled by this key.
Definition: KeysToJointsPlugin.hh:38
gazebo::KeyInfo::scale
double scale
Increments for position, absolute values for velocity and force.
Definition: KeysToJointsPlugin.hh:46
gazebo::transport::SubscriberPtr
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
gazebo::transport::NodePtr
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
Node.hh
gazebo::KeyInfo
Store information from SDF for each key.
Definition: KeysToJointsPlugin.hh:31
gazebo::KeyInfo::type
std::string type
Possible target types: position, velocity, force.
Definition: KeysToJointsPlugin.hh:41
gazebo::physics::JointPtr
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:117
gazebo::KeyInfo::key
int key
Key ASCII value (reference: http://ascii.cl/)
Definition: KeysToJointsPlugin.hh:35
gazebo::ModelPlugin
A plugin with access to physics::Model.
Definition: Plugin.hh:303
Plugin.hh
gazebo::KeysToJointsPlugin
Control joints in a model based on keypress messages received.
Definition: KeysToJointsPlugin.hh:107
GAZEBO_VISIBLE
#define GAZEBO_VISIBLE
Definition: system.hh:59