##

JointState.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 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_PHYSICS_JOINTSTATE_HH_
#define GAZEBO_PHYSICS_JOINTSTATE_HH_
#include <vector>
#include <string>
#include <ignition/math/Angle.hh>
#include "gazebo/physics/State.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace physics
{
class GZ_PHYSICS_VISIBLE JointState : public State
{
public: JointState();
public: JointState(JointPtr _joint, const common::Time &_realTime,
const common::Time &_simTime, const uint64_t _iterations);
public: explicit JointState(JointPtr _joint);
public: explicit JointState(const sdf::ElementPtr _sdf);
public: virtual ~JointState();
public: void Load(JointPtr _joint, const common::Time &_realTime,
const common::Time &_simTime);
public: virtual void Load(const sdf::ElementPtr _elem);
public: unsigned int GetAngleCount() const;
public: double Position(const unsigned int _axis = 0) const;
public: const std::vector<double> &Positions() const;
public: bool IsZero() const;
public: void FillSDF(sdf::ElementPtr _sdf);
public: JointState &operator=(const JointState &_state);
public: JointState operator-(const JointState &_state) const;
public: JointState operator+(const JointState &_state) const;
public: inline friend std::ostream &operator<<(std::ostream &_out,
const gazebo::physics::JointState &_state)
{
if (_state.GetAngleCount() > 0)
{
_out << "<joint name='" << _state.GetName() << "'>";
int i = 0;
for (std::vector<double>::const_iterator iter =
_state.positions.begin(); iter != _state.positions.end(); ++iter)
{
_out << "<angle axis='" << i << "'>" << (*iter) << "</angle>";
i++;
}
_out << "</joint>";
}
return _out;
}
private: std::vector<double> positions;
};
}
}
#endif
gazebo::physics::JointState::FillSDF
void FillSDF(sdf::ElementPtr _sdf)
Populate a state SDF element with data from the object.
gazebo::physics::JointState::IsZero
bool IsZero() const
Return true if the values in the state are zero.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::common::Time
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: Time.hh:47
gazebo::physics::JointState::~JointState
virtual ~JointState()
Destructor.
gazebo::physics::JointState
keeps track of state of a physics::Joint
Definition: JointState.hh:36
gazebo::physics::JointState::operator=
JointState & operator=(const JointState &_state)
Assignment operator.
gazebo::physics::JointState::JointState
JointState()
Default constructor.
system.hh
gazebo::physics::JointState::operator<<
friend std::ostream & operator<<(std::ostream &_out, const gazebo::physics::JointState &_state)
Stream insertion operator.
Definition: JointState.hh:124
State.hh
gazebo::physics::JointState::Positions
const std::vector< double > & Positions() const
Get the joint positions.
gazebo::physics::State::GetName
std::string GetName() const
Get the name associated with this State.
gazebo::physics::JointState::Position
double Position(const unsigned int _axis=0) const
Get the joint position.
gazebo::physics::JointState::GetAngleCount
unsigned int GetAngleCount() const
Get the number of angles.
gazebo::physics::JointState::Load
void Load(JointPtr _joint, const common::Time &_realTime, const common::Time &_simTime)
Load.
gazebo::physics::JointState::operator+
JointState operator+(const JointState &_state) const
Addition operator.
gazebo::physics::JointState::operator-
JointState operator-(const JointState &_state) const
Subtraction operator.
gazebo::physics::State
State of an entity.
Definition: State.hh:43
gazebo::physics::JointPtr
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:117