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
26void
31
32void
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}
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition Logging.cpp:75
void update(const SensorAndControl &sc, const JointAndNJointControllers &c) override
std::map< std::string, std::size_t > devs
InertialMeasurementUnitListenerPrx IMUTopicPrx
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
The SensorValueBase class.
const T * asA() const
Implements a Variant type for timestamps.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
detail::ControlThreadOutputBufferEntry SensorAndControl
IceInternal::Handle< TimestampVariant > TimestampVariantPtr
Structure used by the RobotUnit to swap lists of Joint and NJoint controllers.
std::vector< PropagateConst< SensorValueBase * > > sensors