InertialMeasurementSubUnit.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package RobotAPI::ArmarXObjects::InertialMeasurementSubUnit
17  * @author Raphael ( raphael dot grimm at kit dot edu )
18  * @date 2017
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
23 
25 
26 void
28 {
29  ARMARX_IMPORTANT << "Devices with IMUs: " << devs;
30 }
31 
32 void
35 {
36  if (!getProxy())
37  {
38  //this unit is not initialized yet
39  return;
40  }
41  if (!IMUTopicPrx)
42  {
43  ARMARX_IMPORTANT << deactivateSpam(1) << "listener is not set";
44  return;
45  }
47  InertialMeasurementUnitListenerPrx batchPrx = IMUTopicPrx->ice_batchOneway();
48  for (auto nam2idx : devs)
49  {
50  const auto devidx = nam2idx.second;
51  const auto& dev = nam2idx.first;
52  const SensorValueBase* sv = sc.sensors.at(devidx).get();
54  const SensorValueIMU* s = sv->asA<SensorValueIMU>();
55  IMUData data;
56  data.acceleration =
57  Ice::FloatSeq(s->linearAcceleration.data(),
58  s->linearAcceleration.data() +
59  s->linearAcceleration.rows() * s->linearAcceleration.cols());
60  data.gyroscopeRotation = Ice::FloatSeq(
61  s->angularVelocity.data(),
62  s->angularVelocity.data() + s->angularVelocity.rows() * s->angularVelocity.cols());
63  ;
64  data.orientationQuaternion = {
65  s->orientation.w(), s->orientation.x(), s->orientation.y(), s->orientation.z()};
66  auto frame = dev;
67  batchPrx->reportSensorValues(dev, frame, data, t);
68  }
69  batchPrx->ice_flushBatchRequests();
70 }
armarx::InertialMeasurementSubUnit::update
void update(const SensorAndControl &sc, const JointAndNJointControllers &c) override
Definition: InertialMeasurementSubUnit.cpp:33
armarx::JointAndNJointControllers
Structure used by the RobotUnit to swap lists of Joint and NJoint controllers.
Definition: JointAndNJointControllers.h:32
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:183
armarx::SensorValueBase::asA
const T * asA() const
Definition: SensorValueBase.h:82
armarx::SensorValueBase
The SensorValueBase class.
Definition: SensorValueBase.h:40
armarx::detail::ControlThreadOutputBufferEntry::sensors
std::vector< PropagateConst< SensorValueBase * > > sensors
Definition: ControlThreadOutputBuffer.h:203
armarx::TimestampVariant
Definition: TimestampVariant.h:54
IceInternal::Handle< TimestampVariant >
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:177
deactivateSpam
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition: Logging.cpp:72
armarx::InertialMeasurementSubUnit::onStartIMU
void onStartIMU() override
Definition: InertialMeasurementSubUnit.cpp:27
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::InertialMeasurementSubUnit::devs
std::map< std::string, std::size_t > devs
Definition: InertialMeasurementSubUnit.h:58
ExpressionException.h
armarx::detail::ControlThreadOutputBufferEntry::sensorValuesTimestamp
IceUtil::Time sensorValuesTimestamp
Definition: ControlThreadOutputBuffer.h:201
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
InertialMeasurementSubUnit.h
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx::SensorValueBase::isA
bool isA() const
Definition: SensorValueBase.h:75
armarx::SensorValueIMU
Definition: SensorValueIMU.h:35