Tested mc_att_control_m and mc_pos_control_m in jmavsim.OK.

This commit is contained in:
devbharat
2015-07-16 18:00:22 +02:00
parent 5a2ed4a476
commit 68e3c477ed
10 changed files with 86 additions and 69 deletions
@@ -62,7 +62,7 @@ static const int ERROR = -1;
}
MulticopterAttitudeControl::MulticopterAttitudeControl() :
MulticopterAttitudeControlMultiplatform::MulticopterAttitudeControlMultiplatform() :
MulticopterAttitudeControlBase(),
_task_should_exit(false),
_actuators_0_circuit_breaker_enabled(false),
@@ -104,23 +104,23 @@ MulticopterAttitudeControl::MulticopterAttitudeControl() :
/*
* do subscriptions
*/
_v_att = _n.subscribe<px4_vehicle_attitude>(&MulticopterAttitudeControl::handle_vehicle_attitude, this, 0);
_v_att = _n.subscribe<px4_vehicle_attitude>(&MulticopterAttitudeControlMultiplatform::handle_vehicle_attitude, this, 0);
_v_att_sp = _n.subscribe<px4_vehicle_attitude_setpoint>(0);
_v_rates_sp = _n.subscribe<px4_vehicle_rates_setpoint>(0);
_v_control_mode = _n.subscribe<px4_vehicle_control_mode>(0);
_parameter_update = _n.subscribe<px4_parameter_update>(
&MulticopterAttitudeControl::handle_parameter_update, this, 1000);
&MulticopterAttitudeControlMultiplatform::handle_parameter_update, this, 1000);
_manual_control_sp = _n.subscribe<px4_manual_control_setpoint>(0);
_armed = _n.subscribe<px4_actuator_armed>(0);
_v_status = _n.subscribe<px4_vehicle_status>(0);
}
MulticopterAttitudeControl::~MulticopterAttitudeControl()
MulticopterAttitudeControlMultiplatform::~MulticopterAttitudeControlMultiplatform()
{
}
int
MulticopterAttitudeControl::parameters_update()
MulticopterAttitudeControlMultiplatform::parameters_update()
{
/* roll gains */
_params.att_p(0) = _params_handles.roll_p.update();
@@ -153,12 +153,12 @@ MulticopterAttitudeControl::parameters_update()
return OK;
}
void MulticopterAttitudeControl::handle_parameter_update(const px4_parameter_update &msg)
void MulticopterAttitudeControlMultiplatform::handle_parameter_update(const px4_parameter_update &msg)
{
parameters_update();
}
void MulticopterAttitudeControl::handle_vehicle_attitude(const px4_vehicle_attitude &msg) {
void MulticopterAttitudeControlMultiplatform::handle_vehicle_attitude(const px4_vehicle_attitude &msg) {
perf_begin(_loop_perf);
@@ -64,19 +64,19 @@
#include "mc_att_control_base.h"
class MulticopterAttitudeControl :
class MulticopterAttitudeControlMultiplatform :
public MulticopterAttitudeControlBase
{
public:
/**
* Constructor
*/
MulticopterAttitudeControl();
MulticopterAttitudeControlMultiplatform();
/**
* Destructor, also kills the sensors task.
*/
~MulticopterAttitudeControl();
~MulticopterAttitudeControlMultiplatform();
/* Callbacks for topics */
void handle_vehicle_attitude(const px4_vehicle_attitude &msg);
@@ -54,19 +54,23 @@
#include "mc_att_control.h"
bool thread_running = false; /**< Deamon status flag */
bool mc_att_control_thread_running = false; /**< Deamon status flag */
#if defined(__PX4_ROS)
int main(int argc, char **argv)
#else
int mc_att_control_start_main(int argc, char **argv)
#endif
{
px4::init(argc, argv, "mc_att_control_m");
PX4_INFO("starting");
MulticopterAttitudeControl attctl;
thread_running = true;
MulticopterAttitudeControlMultiplatform attctl;
mc_att_control_thread_running = true;
attctl.spin();
PX4_INFO("exiting.");
thread_running = false;
mc_att_control_thread_running = false;
return 0;
}
@@ -41,57 +41,58 @@
#include <systemlib/err.h>
#include <systemlib/systemlib.h>
extern bool thread_running;
int daemon_task; /**< Handle of deamon task / thread */
extern bool mc_att_control_thread_running;
int mc_att_control_daemon_task; /**< Handle of deamon task / thread */
namespace px4
{
bool task_should_exit = false;
bool mc_att_control_task_should_exit = false;
}
using namespace px4;
extern int main(int argc, char **argv);
extern int mc_att_control_start_main(int argc, char **argv);
extern "C" __EXPORT int mc_att_control_m_main(int argc, char *argv[]);
int mc_att_control_m_main(int argc, char *argv[])
{
if (argc < 2) {
errx(1, "usage: mc_att_control_m {start|stop|status}");
warnx("usage: mc_att_control_m {start|stop|status}");
return 1;
}
if (!strcmp(argv[1], "start")) {
if (thread_running) {
if (mc_att_control_thread_running) {
warnx("already running");
/* this is not an error */
exit(0);
return 0;
}
task_should_exit = false;
daemon_task = px4_task_spawn_cmd("mc_att_control_m",
mc_att_control_task_should_exit = false;
warnx("ok now btak running");
mc_att_control_daemon_task = px4_task_spawn_cmd("mc_att_control_m",
SCHED_DEFAULT,
SCHED_PRIORITY_MAX - 5,
1900,
main,
mc_att_control_start_main,
(argv) ? (char* const*)&argv[2] : (char* const*)NULL);
exit(0);
return 0;
}
if (!strcmp(argv[1], "stop")) {
task_should_exit = true;
exit(0);
mc_att_control_task_should_exit = true;
return 0;
}
if (!strcmp(argv[1], "status")) {
if (thread_running) {
if (mc_att_control_thread_running) {
warnx("is running");
} else {
warnx("not started");
}
exit(0);
return 0;
}
warnx("unrecognized command");