device.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Eigen/Core>
4 
6 
8 
10 {
11 
13  {
14  std::vector<const SensorValue1DoFActuatorTorque*> torqueSensors;
15  std::vector<const SensorValue1DoFActuatorVelocity*> velocitySensors;
16  std::vector<const SensorValue1DoFActuatorPosition*> positionSensors;
17 
18  void
19  updateJointValues(Eigen::VectorXf& qpos, Eigen::VectorXf& qvel, Eigen::VectorXf& qtor)
20  {
21  for (size_t i = 0; i < positionSensors.size(); ++i)
22  {
23  qpos(i) = positionSensors[i]->position;
24  }
25  for (size_t i = 0; i < velocitySensors.size(); ++i)
26  {
27  qvel(i) = velocitySensors[i]->velocity;
28  }
29  for (size_t i = 0; i < torqueSensors.size(); ++i)
30  {
31  qtor(i) = torqueSensors[i]->torque;
32  }
33  };
34 
35  void
36  getJointAngles(Eigen::VectorXf& qpos)
37  {
38  for (size_t i = 0; i < positionSensors.size(); ++i)
39  {
40  if (positionSensors[i])
41  qpos(i) = positionSensors[i]->position;
42  }
43  };
44 
45  void
46  append(const SensorValueBase* sv, const std::string& jointName)
47  {
49 
50  const auto* torqueSensor = sv->asA<SensorValue1DoFActuatorTorque>();
51  const auto* velocitySensor = sv->asA<SensorValue1DoFActuatorVelocity>();
52  const auto* positionSensor = sv->asA<SensorValue1DoFActuatorPosition>();
53 
54  if (torqueSensor)
55  torqueSensors.push_back(torqueSensor);
56  if (velocitySensor)
57  velocitySensors.push_back(velocitySensor);
58  if (positionSensor)
59  positionSensors.push_back(positionSensor);
60  // if (torqueSensor == nullptr)
61  // {
62  // ARMARX_WARNING << "No Torque sensor available for " << jointName;
63  // }
64  // if (velocitySensor == nullptr)
65  // {
66  // ARMARX_WARNING << "No velocity sensor available for " << jointName;
67  // }
68  // if (positionSensor == nullptr)
69  // {
70  // ARMARX_WARNING << "No position sensor available for " << jointName;
71  // }
72  };
73  };
74 
75 } // namespace armarx::control::common
armarx::control::common::SensorDevicesForNJointTorqueController::append
void append(const SensorValueBase *sv, const std::string &jointName)
Definition: device.h:46
armarx::SensorValueBase::asA
const T * asA() const
Definition: SensorValueBase.h:82
armarx::SensorValueBase
The SensorValueBase class.
Definition: SensorValueBase.h:40
armarx::control::common::SensorDevicesForNJointTorqueController::getJointAngles
void getJointAngles(Eigen::VectorXf &qpos)
Definition: device.h:36
armarx::control::common::SensorDevicesForNJointTorqueController
Definition: device.h:12
armarx::control::common
This file is part of ArmarX.
Definition: aron_conversions.cpp:29
armarx::control::common::SensorDevicesForNJointTorqueController::updateJointValues
void updateJointValues(Eigen::VectorXf &qpos, Eigen::VectorXf &qvel, Eigen::VectorXf &qtor)
Definition: device.h:19
armarx::control::common::SensorDevicesForNJointTorqueController::positionSensors
std::vector< const SensorValue1DoFActuatorPosition * > positionSensors
Definition: device.h:16
armarx::control::common::SensorDevicesForNJointTorqueController::torqueSensors
std::vector< const SensorValue1DoFActuatorTorque * > torqueSensors
Definition: device.h:14
ARMARX_CHECK_EXPRESSION
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Definition: ExpressionException.h:73
Logging.h
armarx::control::common::SensorDevicesForNJointTorqueController::velocitySensors
std::vector< const SensorValue1DoFActuatorVelocity * > velocitySensors
Definition: device.h:15
SensorValue1DoFActuator.h