Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPM message simulator (dummy publisher) #14545

Merged
merged 25 commits into from
Apr 25, 2020
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c44e9f1
Prepare simple RPM simulator
roman-dvorak Mar 31, 2020
e20c6a2
Input check
roman-dvorak Mar 31, 2020
f1ace78
Update description
roman-dvorak Mar 31, 2020
acf5a0c
fix typo
roman-dvorak Mar 31, 2020
cf8c428
fix format
roman-dvorak Mar 31, 2020
a590704
Update src/drivers/rpm/rpm_simulator/rpm_simulator.c
roman-dvorak Apr 2, 2020
83061c0
Update src/drivers/rpm/rpm_simulator/rpm_simulator.c
roman-dvorak Apr 2, 2020
32ecf36
Update src/drivers/rpm/rpm_simulator/rpm_simulator.c
roman-dvorak Apr 2, 2020
bd40243
Update src/drivers/rpm/rpm_simulator/rpm_simulator.c
roman-dvorak Apr 2, 2020
0f3b4fd
Update src/drivers/rpm/rpm_simulator/CMakeLists.txt
roman-dvorak Apr 2, 2020
8674ad9
fix PR issues
roman-dvorak Apr 2, 2020
abfdcca
Merge remote-tracking branch 'upstream/master'
roman-dvorak Apr 2, 2020
d1dfa41
Merge remote-tracking branch 'upstream/master'
roman-dvorak Apr 3, 2020
c9c7609
Updated mavlink
roman-dvorak Apr 3, 2020
250db53
Merge remote-tracking branch 'upstream/master'
roman-dvorak Apr 7, 2020
89a714c
Merge branch 'master' into upstream/master
roman-dvorak Apr 7, 2020
a9634d8
Merge remote-tracking branch 'upstream/master'
roman-dvorak Apr 7, 2020
80416d4
Update src/drivers/rpm/rpm_simulator/rpm_simulator.cpp
roman-dvorak Apr 8, 2020
9b204c7
Merge remote-tracking branch 'upstream/master'
roman-dvorak Apr 8, 2020
873af57
Merge remote-tracking branch 'upstream/master'
roman-dvorak Apr 8, 2020
d8598b5
sync submodules
roman-dvorak Apr 8, 2020
79862f1
Merge remote-tracking branch 'upstream/master'
roman-dvorak Apr 9, 2020
9b001f7
Merge remote-tracking branch 'upstream/master'
roman-dvorak Apr 10, 2020
021d468
sync submodule
roman-dvorak Apr 10, 2020
f1bb622
Update src/modules/mavlink/mavlink_messages.cpp
roman-dvorak Apr 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boards/px4/sitl/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ px4_add_board(
#imu # all available imu drivers
#magnetometer # all available magnetometer drivers
pwm_out_sim
rpm/rpm_simulator
#telemetry # all available telemetry drivers
tone_alarm
#uavcan
Expand Down
39 changes: 39 additions & 0 deletions src/drivers/rpm/rpm_simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
############################################################################
#
# Copyright (c) 2020 PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name PX4 nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
px4_add_module(
MODULE examples__rpm_simulator
MAIN rpm_simulator
SRCS
rpm_simulator.cpp
DEPENDS
)
78 changes: 78 additions & 0 deletions src/drivers/rpm/rpm_simulator/rpm_simulator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/****************************************************************************
*
* Copyright (c) 2020 PX4 Development Team. All rights reserved.
* Copyright (c) 2020 ThunderFly s.r.o. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/

/**
* @file rpm_simulator.c
* Simple app for publishing RPM messages with custom value.
*
* Usage: rpm_simulator <rpm_value>
* rpm_simulator 344.2
*
* @author ThunderFly s.r.o., Roman Dvorak <[email protected]>
*/

#include <px4_platform_common/px4_config.h>
#include <drivers/drv_hrt.h>

#include <uORB/Publication.hpp>
#include <uORB/topics/rpm.h>

extern "C" __EXPORT int rpm_simulator_main(int argc, char *argv[]);
int rpm_simulator_main(int argc, char *argv[])
{

// check input
if (argc != 2) {
PX4_INFO("Usage: rpm_simulator <published RPM>");
PX4_INFO("Exit. Without publishing any message.");
return 0;
}

rpm_s rpm{};

uORB::Publication<rpm_s> rpm_pub{ORB_ID(rpm)};
uint64_t timestamp_us = hrt_absolute_time();
float frequency = atof(argv[1]);

// prpepare RPM data message
rpm.timestamp = timestamp_us;
rpm.indicated_frequency_rpm = frequency;
rpm.estimated_accurancy_rpm = frequency / 100.0f;

// Publish data and let the user know what was published
rpm_pub.publish(rpm);
print_message(rpm);

return 0;
}
1 change: 1 addition & 0 deletions src/modules/mavlink/mavlink_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
#include <uORB/topics/sensor_combined.h>
#include <uORB/topics/sensor_gyro_integrated.h>
#include <uORB/topics/sensor_gyro_status.h>
#include <uORB/topics/rpm.h>
#include <uORB/topics/sensor_mag.h>
#include <uORB/topics/sensor_selection.h>
#include <uORB/topics/tecs_status.h>
Expand Down