KeysToJointsPlugin.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16*/
17
18#ifndef GAZEBO_PLUGINS_KEYSTOJOINTSPLUGIN_HH_
19#define GAZEBO_PLUGINS_KEYSTOJOINTSPLUGIN_HH_
20
21#include <string>
22#include <vector>
23#include <ignition/transport/Node.hh>
24
27
28namespace gazebo
29{
31 struct KeyInfo
32 {
34 // cppcheck-suppress unusedStructMember
35 int key;
36
39
41 std::string type;
42
45 // cppcheck-suppress unusedStructMember
46 double scale;
47 };
48
107 class GZ_PLUGIN_VISIBLE KeysToJointsPlugin : public ModelPlugin
108 {
111
114
115 // Documentation inherited
116 public: virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf);
117
120 private: void OnKeyPress(ConstAnyPtr &_msg);
121
123 private: std::vector<KeyInfo> keys;
124
126 private: physics::ModelPtr model;
127
129 private: transport::NodePtr node;
130
132 private: transport::SubscriberPtr keyboardSub;
133
134 // Place ignition::transport objects at the end of this file to
135 // guarantee they are destructed first.
136
138 private: ignition::transport::Node nodeIgn;
139 };
140}
141#endif
142
Control joints in a model based on keypress messages received.
Definition KeysToJointsPlugin.hh:108
~KeysToJointsPlugin()
Destructor.
KeysToJointsPlugin()
Constructor.
virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf)
Load function.
A plugin with access to physics::Model.
Definition Plugin.hh:304
boost::shared_ptr< Model > ModelPtr
Definition PhysicsTypes.hh:93
boost::shared_ptr< Joint > JointPtr
Definition PhysicsTypes.hh:117
boost::shared_ptr< Subscriber > SubscriberPtr
Definition TransportTypes.hh:53
boost::shared_ptr< Node > NodePtr
Definition TransportTypes.hh:57
Forward declarations for the common classes.
Definition Animation.hh:27
Store information from SDF for each key.
Definition KeysToJointsPlugin.hh:32
physics::JointPtr joint
Pointer to the joint controlled by this key.
Definition KeysToJointsPlugin.hh:38
int key
Key ASCII value (reference: http://ascii.cl/)
Definition KeysToJointsPlugin.hh:35
std::string type
Possible target types: position, velocity, force.
Definition KeysToJointsPlugin.hh:41
double scale
Increments for position, absolute values for velocity and force.
Definition KeysToJointsPlugin.hh:46