mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 21:33:34 +08:00
Merge branch 'cmake-2' into cmake-2-pthread
This commit is contained in:
@@ -20,17 +20,32 @@ for index,m in enumerate(raw_messages):
|
|||||||
temp_list = []
|
temp_list = []
|
||||||
f = open(m,'r')
|
f = open(m,'r')
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
if(line.split(' ')[0] == "float32"):
|
if ('float32[' in line.split(' ')[0]):
|
||||||
|
num_floats = int(line.split(" ")[0].split("[")[1].split("]")[0])
|
||||||
|
temp_list.append(("float_array",line.split(' ')[1].split('\t')[0].split('\n')[0],num_floats))
|
||||||
|
if ('uint64[' in line.split(' ')[0]):
|
||||||
|
num_floats = int(line.split(" ")[0].split("[")[1].split("]")[0])
|
||||||
|
temp_list.append(("uint64_array",line.split(' ')[1].split('\t')[0].split('\n')[0],num_floats))
|
||||||
|
elif(line.split(' ')[0] == "float32"):
|
||||||
temp_list.append(("float",line.split(' ')[1].split('\t')[0].split('\n')[0]))
|
temp_list.append(("float",line.split(' ')[1].split('\t')[0].split('\n')[0]))
|
||||||
elif(line.split(' ')[0] == "uint64"):
|
elif(line.split(' ')[0] == "uint64") and len(line.split('=')) == 1:
|
||||||
temp_list.append(("uint64",line.split(' ')[1].split('\t')[0].split('\n')[0]))
|
temp_list.append(("uint64",line.split(' ')[1].split('\t')[0].split('\n')[0]))
|
||||||
elif (line.split(' ')[0] == "bool"):
|
elif(line.split(' ')[0] == "uint32") and len(line.split('=')) == 1:
|
||||||
|
temp_list.append(("uint32",line.split(' ')[1].split('\t')[0].split('\n')[0]))
|
||||||
|
elif(line.split(' ')[0] == "uint16") and len(line.split('=')) == 1:
|
||||||
|
temp_list.append(("uint16",line.split(' ')[1].split('\t')[0].split('\n')[0]))
|
||||||
|
elif(line.split(' ')[0] == "int64") and len(line.split('=')) == 1:
|
||||||
|
temp_list.append(("int64",line.split(' ')[1].split('\t')[0].split('\n')[0]))
|
||||||
|
elif(line.split(' ')[0] == "int32") and len(line.split('=')) == 1:
|
||||||
|
temp_list.append(("int32",line.split(' ')[1].split('\t')[0].split('\n')[0]))
|
||||||
|
elif(line.split(' ')[0] == "int16") and len(line.split('=')) == 1:
|
||||||
|
temp_list.append(("int16",line.split(' ')[1].split('\t')[0].split('\n')[0]))
|
||||||
|
elif (line.split(' ')[0] == "bool") and len(line.split('=')) == 1:
|
||||||
temp_list.append(("bool",line.split(' ')[1].split('\t')[0].split('\n')[0]))
|
temp_list.append(("bool",line.split(' ')[1].split('\t')[0].split('\n')[0]))
|
||||||
elif (line.split(' ')[0] == "uint8") and len(line.split('=')) == 1:
|
elif (line.split(' ')[0] == "uint8") and len(line.split('=')) == 1:
|
||||||
temp_list.append(("uint8",line.split(' ')[1].split('\t')[0].split('\n')[0]))
|
temp_list.append(("uint8",line.split(' ')[1].split('\t')[0].split('\n')[0]))
|
||||||
elif ('float32[' in line.split(' ')[0]):
|
elif (line.split(' ')[0] == "int8") and len(line.split('=')) == 1:
|
||||||
num_floats = int(line.split(" ")[0].split("[")[1].split("]")[0])
|
temp_list.append(("int8",line.split(' ')[1].split('\t')[0].split('\n')[0]))
|
||||||
temp_list.append(("float_array",line.split(' ')[1].split('\t')[0].split('\n')[0],num_floats))
|
|
||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
messages.append(m.split('/')[-1].split('.')[0])
|
messages.append(m.split('/')[-1].split('.')[0])
|
||||||
@@ -131,12 +146,24 @@ for index,m in enumerate(messages[1:]):
|
|||||||
print("\t\t\tprintf(\"%s: %%f\\n \",(double)container.%s);" % (item[1], item[1]))
|
print("\t\t\tprintf(\"%s: %%f\\n \",(double)container.%s);" % (item[1], item[1]))
|
||||||
elif item[0] == "float_array":
|
elif item[0] == "float_array":
|
||||||
print("\t\t\tprintf(\"%s:\");" % item[1])
|
print("\t\t\tprintf(\"%s:\");" % item[1])
|
||||||
print("\t\t\tfor (int j=0;j<%d;j++) {" % item[2])
|
print("\t\t\tfor (int j = 0; j < %d; j++) {" % item[2])
|
||||||
print("\t\t\t\tprintf(\"%%f \",(double)container.%s[j]);" % item[1])
|
print("\t\t\t\tprintf(\"%%f \",(double)container.%s[j]);" % item[1])
|
||||||
print("\t\t\t}")
|
print("\t\t\t}")
|
||||||
print("\t\t\tprintf(\"\\n\");")
|
print("\t\t\tprintf(\"\\n\");")
|
||||||
elif item[0] == "uint64":
|
elif item[0] == "uint64":
|
||||||
print("\t\t\tprintf(\"%s: %%\" PRIu64 \"\\n \",container.%s);" % (item[1], item[1]))
|
print("\t\t\tprintf(\"%s: %%\" PRIu64 \"\\n \",container.%s);" % (item[1], item[1]))
|
||||||
|
elif item[0] == "uint64_array":
|
||||||
|
print("\t\t\tprintf(\"%s:\");" % item[1])
|
||||||
|
print("\t\t\tfor (int j = 0; j < %d; j++) {" % item[2])
|
||||||
|
print("\t\t\t\tprintf(\"%%\" PRIu64 \" \",container.%s[j]);" % item[1])
|
||||||
|
print("\t\t\t}")
|
||||||
|
print("\t\t\tprintf(\"\\n\");")
|
||||||
|
elif item[0] == "int64":
|
||||||
|
print("\t\t\tprintf(\"%s: %%\" PRI64 \"\\n \",container.%s);" % (item[1], item[1]))
|
||||||
|
elif item[0] == "int32":
|
||||||
|
print("\t\t\tprintf(\"%s: %%d\\n \",container.%s);" % (item[1], item[1]))
|
||||||
|
elif item[0] == "uint32":
|
||||||
|
print("\t\t\tprintf(\"%s: %%d\\n \",container.%s);" % (item[1], item[1]))
|
||||||
elif item[0] == "uint8":
|
elif item[0] == "uint8":
|
||||||
print("\t\t\tprintf(\"%s: %%u\\n \",container.%s);" % (item[1], item[1]))
|
print("\t\t\tprintf(\"%s: %%u\\n \",container.%s);" % (item[1], item[1]))
|
||||||
elif item[0] == "bool":
|
elif item[0] == "bool":
|
||||||
|
|||||||
@@ -370,19 +370,35 @@ void Simulator::send()
|
|||||||
|
|
||||||
void Simulator::initializeSensorData()
|
void Simulator::initializeSensorData()
|
||||||
{
|
{
|
||||||
struct baro_report baro = {};
|
// write sensor data to memory so that drivers can copy data from there
|
||||||
baro.pressure = 120000.0f;
|
RawMPUData mpu = {};
|
||||||
|
mpu.accel_z = 9.81f;
|
||||||
|
|
||||||
// acceleration report
|
write_MPU_data((void *)&mpu);
|
||||||
struct accel_report accel = {};
|
|
||||||
|
RawAccelData accel = {};
|
||||||
accel.z = 9.81f;
|
accel.z = 9.81f;
|
||||||
accel.range_m_s2 = 80.0f;
|
|
||||||
|
|
||||||
// gyro report
|
write_accel_data((void *)&accel);
|
||||||
struct gyro_report gyro = {};
|
|
||||||
|
|
||||||
// mag report
|
RawMagData mag = {};
|
||||||
struct mag_report mag = {};
|
mag.x = 0.4f;
|
||||||
|
mag.y = 0.0f;
|
||||||
|
mag.z = 0.6f;
|
||||||
|
|
||||||
|
write_mag_data((void *)&mag);
|
||||||
|
|
||||||
|
RawBaroData baro = {};
|
||||||
|
// calculate air pressure from altitude (valid for low altitude)
|
||||||
|
baro.pressure = 120000.0f;
|
||||||
|
baro.altitude = 0.0f;
|
||||||
|
baro.temperature = 25.0f;
|
||||||
|
|
||||||
|
write_baro_data((void *)&baro);
|
||||||
|
|
||||||
|
RawAirspeedData airspeed {};
|
||||||
|
|
||||||
|
write_airspeed_data((void *)&airspeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator::pollForMAVLinkMessages(bool publish)
|
void Simulator::pollForMAVLinkMessages(bool publish)
|
||||||
|
|||||||
@@ -448,6 +448,9 @@ ACCELSIM::init()
|
|||||||
{
|
{
|
||||||
int ret = ERROR;
|
int ret = ERROR;
|
||||||
|
|
||||||
|
struct mag_report mrp = {};
|
||||||
|
struct accel_report arp = {};
|
||||||
|
|
||||||
/* do SIM init first */
|
/* do SIM init first */
|
||||||
if (VDev::init() != OK) {
|
if (VDev::init() != OK) {
|
||||||
PX4_WARN("SIM init failed");
|
PX4_WARN("SIM init failed");
|
||||||
@@ -478,7 +481,6 @@ ACCELSIM::init()
|
|||||||
measure();
|
measure();
|
||||||
|
|
||||||
/* advertise sensor topic, measure manually to initialize valid report */
|
/* advertise sensor topic, measure manually to initialize valid report */
|
||||||
struct mag_report mrp;
|
|
||||||
_mag_reports->get(&mrp);
|
_mag_reports->get(&mrp);
|
||||||
|
|
||||||
/* measurement will have generated a report, publish */
|
/* measurement will have generated a report, publish */
|
||||||
@@ -493,7 +495,6 @@ ACCELSIM::init()
|
|||||||
_accel_class_instance = register_class_devname(ACCEL_BASE_DEVICE_PATH);
|
_accel_class_instance = register_class_devname(ACCEL_BASE_DEVICE_PATH);
|
||||||
|
|
||||||
/* advertise sensor topic, measure manually to initialize valid report */
|
/* advertise sensor topic, measure manually to initialize valid report */
|
||||||
struct accel_report arp = {};
|
|
||||||
_accel_reports->get(&arp);
|
_accel_reports->get(&arp);
|
||||||
|
|
||||||
/* measurement will have generated a report, publish */
|
/* measurement will have generated a report, publish */
|
||||||
@@ -1014,7 +1015,7 @@ ACCELSIM::measure()
|
|||||||
} raw_accel_report;
|
} raw_accel_report;
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
accel_report accel_report;
|
accel_report accel_report = {};
|
||||||
|
|
||||||
/* start the performance counter */
|
/* start the performance counter */
|
||||||
perf_begin(_accel_sample_perf);
|
perf_begin(_accel_sample_perf);
|
||||||
@@ -1023,7 +1024,7 @@ ACCELSIM::measure()
|
|||||||
memset(&raw_accel_report, 0, sizeof(raw_accel_report));
|
memset(&raw_accel_report, 0, sizeof(raw_accel_report));
|
||||||
raw_accel_report.cmd = DIR_READ | ACC_READ;
|
raw_accel_report.cmd = DIR_READ | ACC_READ;
|
||||||
|
|
||||||
if(OK != transfer((uint8_t *)&raw_accel_report, (uint8_t *)&raw_accel_report, sizeof(raw_accel_report))) {
|
if (OK != transfer((uint8_t *)&raw_accel_report, (uint8_t *)&raw_accel_report, sizeof(raw_accel_report))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -419,6 +419,9 @@ GYROSIM::init()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct accel_report arp = {};
|
||||||
|
struct gyro_report grp = {};
|
||||||
|
|
||||||
/* allocate basic report buffers */
|
/* allocate basic report buffers */
|
||||||
_accel_reports = new ringbuffer::RingBuffer(2, sizeof(accel_report));
|
_accel_reports = new ringbuffer::RingBuffer(2, sizeof(accel_report));
|
||||||
if (_accel_reports == nullptr) {
|
if (_accel_reports == nullptr) {
|
||||||
@@ -466,7 +469,6 @@ GYROSIM::init()
|
|||||||
measure();
|
measure();
|
||||||
|
|
||||||
/* advertise sensor topic, measure manually to initialize valid report */
|
/* advertise sensor topic, measure manually to initialize valid report */
|
||||||
struct accel_report arp = {};
|
|
||||||
_accel_reports->get(&arp);
|
_accel_reports->get(&arp);
|
||||||
|
|
||||||
/* measurement will have generated a report, publish */
|
/* measurement will have generated a report, publish */
|
||||||
@@ -482,7 +484,6 @@ GYROSIM::init()
|
|||||||
|
|
||||||
|
|
||||||
/* advertise sensor topic, measure manually to initialize valid report */
|
/* advertise sensor topic, measure manually to initialize valid report */
|
||||||
struct gyro_report grp = {};
|
|
||||||
_gyro_reports->get(&grp);
|
_gyro_reports->get(&grp);
|
||||||
|
|
||||||
_gyro->_gyro_topic = orb_advertise_multi(ORB_ID(sensor_gyro), &grp,
|
_gyro->_gyro_topic = orb_advertise_multi(ORB_ID(sensor_gyro), &grp,
|
||||||
@@ -511,8 +512,9 @@ GYROSIM::transfer(uint8_t *send, uint8_t *recv, unsigned len)
|
|||||||
if (cmd == MPUREAD) {
|
if (cmd == MPUREAD) {
|
||||||
// Get data from the simulator
|
// Get data from the simulator
|
||||||
Simulator *sim = Simulator::getInstance();
|
Simulator *sim = Simulator::getInstance();
|
||||||
if (sim == NULL)
|
if (sim == NULL) {
|
||||||
return ENODEV;
|
return ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME - not sure what interrupt status should be
|
// FIXME - not sure what interrupt status should be
|
||||||
recv[1] = 0;
|
recv[1] = 0;
|
||||||
@@ -1012,7 +1014,7 @@ GYROSIM::measure()
|
|||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
struct MPUReport mpu_report;
|
struct MPUReport mpu_report = {};
|
||||||
|
|
||||||
/* start measuring */
|
/* start measuring */
|
||||||
perf_begin(_sample_perf);
|
perf_begin(_sample_perf);
|
||||||
@@ -1031,8 +1033,8 @@ GYROSIM::measure()
|
|||||||
/*
|
/*
|
||||||
* Report buffers.
|
* Report buffers.
|
||||||
*/
|
*/
|
||||||
accel_report arb;
|
accel_report arb = {};
|
||||||
gyro_report grb;
|
gyro_report grb = {};
|
||||||
|
|
||||||
// for now use local time but this should be the timestamp of the simulator
|
// for now use local time but this should be the timestamp of the simulator
|
||||||
grb.timestamp = hrt_absolute_time();
|
grb.timestamp = hrt_absolute_time();
|
||||||
|
|||||||
@@ -31,23 +31,23 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
#add_custom_command(OUTPUT topic_listener.cpp
|
add_custom_command(OUTPUT topic_listener.cpp
|
||||||
# COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Tools/generate_listener.py ${CMAKE_SOURCE_DIR} > topic_listener.cpp
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Tools/generate_listener.py ${CMAKE_SOURCE_DIR} > topic_listener.cpp
|
||||||
# )
|
)
|
||||||
|
|
||||||
#add_custom_target(generate_topic_listener
|
add_custom_target(generate_topic_listener
|
||||||
# DEPENDS topic_listener.cpp)
|
DEPENDS topic_listener.cpp)
|
||||||
|
|
||||||
#px4_add_module(
|
px4_add_module(
|
||||||
# MODULE systemcmds__topic_listener
|
MODULE systemcmds__topic_listener
|
||||||
# MAIN listener
|
MAIN listener
|
||||||
# STACK 1800
|
STACK 1800
|
||||||
# COMPILE_FLAGS
|
COMPILE_FLAGS
|
||||||
# -Os
|
-Os
|
||||||
# SRCS
|
SRCS
|
||||||
# topic_listener.cpp
|
topic_listener.cpp
|
||||||
# DEPENDS
|
DEPENDS
|
||||||
# platforms__common
|
platforms__common
|
||||||
# generate_topic_listener
|
generate_topic_listener
|
||||||
# )
|
)
|
||||||
# vim: set noet ft=cmake fenc=utf-8 ff=unix :
|
# vim: set noet ft=cmake fenc=utf-8 ff=unix :
|
||||||
|
|||||||
Reference in New Issue
Block a user