mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-31 20:38:27 +08:00
fixed remarks by Freek
This commit is contained in:
@@ -35,7 +35,7 @@
|
|||||||
<load name="bat_voltage_ardrone2.xml"/>
|
<load name="bat_voltage_ardrone2.xml"/>
|
||||||
<load name="uartrotation.xml">
|
<load name="uartrotation.xml">
|
||||||
<configure name="STEREO_UART" value="UART1"/>
|
<configure name="STEREO_UART" value="UART1"/>
|
||||||
<configure name="STEREO_BAUD" value="B115200"/>
|
<configure name="STEREO_BAUD" value="B1000000"/>
|
||||||
</load>
|
</load>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -2092,8 +2092,7 @@
|
|||||||
</message>
|
</message>
|
||||||
|
|
||||||
<!-- 245 is free -->
|
<!-- 245 is free -->
|
||||||
<message name="SERIALRMAT" id="246">
|
<!-- 246 is free -->
|
||||||
</message>
|
|
||||||
|
|
||||||
|
|
||||||
<message name="PPRZ_DEBUG" id="247">
|
<message name="PPRZ_DEBUG" id="247">
|
||||||
|
|||||||
@@ -2,33 +2,27 @@
|
|||||||
|
|
||||||
<module name="uartrotation">
|
<module name="uartrotation">
|
||||||
<doc>
|
<doc>
|
||||||
<description>Writes rotation to the uart bus</description>
|
<description>Writes rotation to the uart bus. Meant for sending the rotation
|
||||||
|
to the ODROID board or to the stereo camera boards.
|
||||||
|
Can be used to improve vision algorithms.
|
||||||
|
The protocol that is used is the stereocommunication protocol.
|
||||||
|
</description>
|
||||||
<configure name="STEREO_UART" value="UARTX" description="Sets the UART port number of the connected camera (required)"/>
|
<configure name="STEREO_UART" value="UARTX" description="Sets the UART port number of the connected camera (required)"/>
|
||||||
<configure name="STEREO_BAUD" value="BXXXXX" description="Sets the BAUD rate of the connected camera (required: must be same as camera)"/>
|
<configure name="STEREO_BAUD" value="BXXXXX" description="Sets the BAUD rate of the connected camera (required: must be same as camera)"/>
|
||||||
</doc>
|
</doc>
|
||||||
<header>
|
<header>
|
||||||
<file name="uartrotation.h"/>
|
<file name="uartrotation.h"/>
|
||||||
</header>
|
</header>
|
||||||
<init fun="uart_rotation_init()"/>
|
<periodic fun="write_serial_rot()" freq="512."/>
|
||||||
<makefile>
|
<makefile>
|
||||||
<file name="uartrotation.c"/>
|
<file name="uartrotation.c"/>
|
||||||
<file name="stereoprotocol.c" dir="subsystems"/>
|
<file name="stereoprotocol.c" dir="subsystems"/>
|
||||||
<!-- <define name="USE_$(STEREO_UART)"/>
|
|
||||||
<define name="UART_LINK" value="$(STEREO_UART_LOWER)"/>
|
|
||||||
<define name="$(STEREO_UART)_BAUD" value="$(STEREO_BAUD)"/>-->
|
|
||||||
<raw>
|
<raw>
|
||||||
STEREO_UART_LOWER=$(shell echo $(STEREO_UART) | tr A-Z a-z)
|
STEREO_UART_LOWER=$(shell echo $(STEREO_UART) | tr A-Z a-z)
|
||||||
ap.CFLAGS += -DUSE_$(STEREO_UART)
|
ap.CFLAGS += -DUSE_$(STEREO_UART)
|
||||||
ap.CFLAGS += -DUART_LINK=$(STEREO_UART_LOWER)
|
ap.CFLAGS += -DUART_LINK=$(STEREO_UART_LOWER)
|
||||||
ap.CFLAGS += -D$(STEREO_UART)_BAUD=$(STEREO_BAUD)
|
ap.CFLAGS += -D$(STEREO_UART)_BAUD=$(STEREO_BAUD)
|
||||||
</raw>
|
</raw>
|
||||||
<!--
|
|
||||||
|
|
||||||
ODROID_GPS_PORT_LOWER=$(shell echo $(GPS_PORT) | tr A-Z a-z)
|
|
||||||
ap.CFLAGS += -DUSE_$(GPS_PORT) -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
|
||||||
ap.CFLAGS += -DUSE_GPS -DGPS_LINK=$(ODROID_GPS_PORT_LOWER)
|
|
||||||
|
|
||||||
-->
|
|
||||||
</makefile>
|
</makefile>
|
||||||
|
|
||||||
</module>
|
</module>
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
<message name="AIR_DATA" period="1.3"/>
|
<message name="AIR_DATA" period="1.3"/>
|
||||||
<message name="SURVEY" period="2.5"/>
|
<message name="SURVEY" period="2.5"/>
|
||||||
<message name="OPTIC_FLOW_EST" period="0.25"/>
|
<message name="OPTIC_FLOW_EST" period="0.25"/>
|
||||||
<message name="SERIALRMAT" period="0.25"/>
|
|
||||||
<message name="VECTORNAV_INFO" period="0.5"/>
|
<message name="VECTORNAV_INFO" period="0.5"/>
|
||||||
</mode>
|
</mode>
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,6 @@ void guidance_h_module_run(bool_t in_flight)
|
|||||||
static void stabilization_opticflow_vel_cb(uint8_t sender_id __attribute__((unused)),
|
static void stabilization_opticflow_vel_cb(uint8_t sender_id __attribute__((unused)),
|
||||||
uint32_t stamp, float vel_x, float vel_y, float vel_z)
|
uint32_t stamp, float vel_x, float vel_y, float vel_z)
|
||||||
{
|
{
|
||||||
printf("Stabilisation before %f %f \n", vel_x, vel_y);
|
|
||||||
/* Check if we are in the correct AP_MODE before setting commands */
|
/* Check if we are in the correct AP_MODE before setting commands */
|
||||||
if (autopilot_mode != AP_MODE_MODULE) {
|
if (autopilot_mode != AP_MODE_MODULE) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -46,9 +46,8 @@ struct mavlink_msg_req req;
|
|||||||
static void decode_optical_flow_msg(struct mavlink_message *msg __attribute__((unused)))
|
static void decode_optical_flow_msg(struct mavlink_message *msg __attribute__((unused)))
|
||||||
{
|
{
|
||||||
optical_flow_available = TRUE;
|
optical_flow_available = TRUE;
|
||||||
// printf("Stabilisation decoded %d %d height: %f \n", optical_flow.flow_x, optical_flow.flow_y,optical_flow.ground_distance);
|
|
||||||
|
|
||||||
// X and Y negated to get to the body of the drone
|
// Y negated to get to the body of the drone
|
||||||
AbiSendMsgVELOCITY_ESTIMATE(PIX4FLOWSENDER_ID, 0,
|
AbiSendMsgVELOCITY_ESTIMATE(PIX4FLOWSENDER_ID, 0,
|
||||||
(optical_flow.flow_x/optical_flow.ground_distance),
|
(optical_flow.flow_x/optical_flow.ground_distance),
|
||||||
-1.0*(optical_flow.flow_y/optical_flow.ground_distance),
|
-1.0*(optical_flow.flow_y/optical_flow.ground_distance),
|
||||||
|
|||||||
@@ -37,12 +37,7 @@
|
|||||||
// define coms link for stereocam
|
// define coms link for stereocam
|
||||||
#define STEREO_PORT (&((UART_LINK).device))
|
#define STEREO_PORT (&((UART_LINK).device))
|
||||||
struct link_device *dev = STEREO_PORT;
|
struct link_device *dev = STEREO_PORT;
|
||||||
|
|
||||||
#define StereoGetch() STEREO_PORT ->get_byte(STEREO_PORT->periph)
|
#define StereoGetch() STEREO_PORT ->get_byte(STEREO_PORT->periph)
|
||||||
#define StereoSend1(c) STEREO_PORT->put_byte(STEREO_PORT->periph, c)
|
|
||||||
#define StereoUartSend1(c) StereoSend1(c)
|
|
||||||
#define StereoSend(_dat,_len) { for (uint8_t i = 0; i< (_len); i++) StereoSend1(_dat[i]); };
|
|
||||||
#define StereoUartSetBaudrate(_b) uart_periph_set_baudrate(STEREO_PORT, _b);
|
|
||||||
|
|
||||||
//typedef struct MsgProperties {
|
//typedef struct MsgProperties {
|
||||||
// uint16_t positionImageStart;
|
// uint16_t positionImageStart;
|
||||||
|
|||||||
@@ -19,47 +19,37 @@
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @file "modules/readlocationfromodroid/readlocationfromodroid.c"
|
* @file "modules/readlocationfromodroid/readlocationfromodroid.c"
|
||||||
* @author Roland
|
* @author Roland + Kirk
|
||||||
* reads from the odroid and sends information of the drone to the odroid using JSON messages
|
* Sends rotation using the stereoboard protocol over the UART.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "modules/uartrotation/uartrotation.h"
|
#include "modules/uartrotation/uartrotation.h"
|
||||||
#include "subsystems/abi.h"
|
#include "subsystems/abi.h"
|
||||||
#include <serial_port.h>
|
#include <serial_port.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <errno.h>
|
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "subsystems/gps.h"
|
#include "subsystems/gps.h"
|
||||||
#include "subsystems/ins/ins_int.h"
|
#include "subsystems/ins/ins_int.h"
|
||||||
#include "firmwares/rotorcraft/autopilot.h"
|
#include "firmwares/rotorcraft/autopilot.h"
|
||||||
#include "mcu_periph/uart.h"
|
#include "mcu_periph/uart.h"
|
||||||
#include "subsystems/gps.h"
|
|
||||||
#include "subsystems/datalink/telemetry.h"
|
|
||||||
#include "subsystems/stereoprotocol.h"
|
#include "subsystems/stereoprotocol.h"
|
||||||
#include "navdata.h"
|
#include "navdata.h"
|
||||||
int frameNumberSending=0;
|
static int frame_number_sending=0;
|
||||||
static abi_event odroid_agl_ev;
|
static abi_event odroid_agl_ev;
|
||||||
float lastKnownHeight = 0.0;
|
float lastKnownHeight = 0.0;
|
||||||
int pleaseResetOdroid = 0;
|
int pleaseResetOdroid = 0;
|
||||||
|
|
||||||
|
//uart_periph_set_baudrate(UART_LINK, B115200);
|
||||||
|
|
||||||
static void write_serial_rot(struct transport_tx *trans, struct link_device *devasdf) {
|
void write_serial_rot() {
|
||||||
struct Int32RMat *ltp_to_body_mat = stateGetNedToBodyRMat_i();
|
struct Int32RMat *ltp_to_body_mat = stateGetNedToBodyRMat_i();
|
||||||
int32_t lengthArrayInformation = 11*sizeof(int32_t);
|
static int32_t lengthArrayInformation = 11*sizeof(int32_t);
|
||||||
uint8_t ar[lengthArrayInformation];
|
uint8_t ar[lengthArrayInformation];
|
||||||
int32_t *pointer = (int32_t*)ar;
|
int32_t *pointer = (int32_t*)ar;
|
||||||
for(int indexRot = 0; indexRot < 9; indexRot++){
|
for(int indexRot = 0; indexRot < 9; indexRot++){
|
||||||
pointer[indexRot]=ltp_to_body_mat->m[indexRot];
|
pointer[indexRot]=ltp_to_body_mat->m[indexRot];
|
||||||
}
|
}
|
||||||
pointer[9]=(int32_t)(state.alt_agl_f*100); //height above ground level in CM.
|
pointer[9]=(int32_t)(state.alt_agl_f*100); //height above ground level in CM.
|
||||||
pointer[10]=frameNumberSending++;
|
pointer[10]=frame_number_sending++;
|
||||||
printf("Whoo sending serial\n");
|
|
||||||
stereoprot_sendArray( &((UART_LINK).device),ar, lengthArrayInformation, 1);
|
stereoprot_sendArray( &((UART_LINK).device),ar, lengthArrayInformation, 1);
|
||||||
printf("Whoo sending serial2\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void uart_rotation_init() {
|
|
||||||
register_periodic_telemetry(DefaultPeriodic, "SERIALRMAT", write_serial_rot);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,15 +18,14 @@
|
|||||||
* <http://www.gnu.org/licenses/>.
|
* <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @file "modules/readlocationfromodroid/readlocationfromodroid.h"
|
* @file "modules/uartrotation/uartrotation.h"
|
||||||
* @author Roland
|
* @author Roland
|
||||||
* reads from the odroid
|
* Sends rotation using the stereoboard protocol over the UART.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef READLOCATIONFROMODROID_H
|
#ifndef UARTROTATION_H
|
||||||
#define READLOCATIONFROMODROID_H
|
#define UARTROTATION_H
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
extern void odroid_loc_init(void);
|
extern void write_serial_rot(void);
|
||||||
extern void odroid_loc_periodic(void);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user