view main/packages/common/can/can_messages.h @ 277:773f6e8a5842 main

PixyCam commands and node definitions.
author Bob Cook <bob@bobcookdev.com>
date Mon, 30 May 2016 19:03:03 -0700
parents 71ff00c4bae6
children
line wrap: on
line source

// ----------------------------------------------------------------------------------------
//
//  common/can/can_messages.h
//    
//  Bob Cook Development, Robotics Library
//  http://www.bobcookdev.com/rl/
// 
//  Identifiers for Controller Area Network messages.
//
//  Copyright (c) 2010-2016 Bob Cook
//
//  Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
//
// ----------------------------------------------------------------------------------------

#if !defined( BCDRL_COMMON_CAN_CAN_MESSAGES_H )
#define BCDRL_COMMON_CAN_CAN_MESSAGES_H

#include <stdint.h>

#if !defined( __AVR__ )
#pragma pack(push,1)
#endif

// ----------------------------------------------------------------------------------------
//  Overall scheme (lower is higher priority):
// 
//      Emergency messages:     0x0001 to 0x000f
//      General messages:       0x0010 to 0x001f
//      IMU sensor:             0x0020 to 0x002f
//      GPS sensor:             0x0100 to 0x010f
//      Wheels (front & rear):  0x0110 to 0x011f
//      Sonar (front):          0x0130 to 0x013f
//      PixyCam sensor:         0x0140 to 0x014f
//
// ----------------------------------------------------------------------------------------

const uint16_t can_dataid_emergency = 0x0001;
const uint16_t can_dataid_all_clear = 0x0002;

const uint16_t can_dataid_estop_off = 0x0003;

// ----------------------------------------------------------------------------------------

const uint16_t can_dataid_heartbeat = 0x0010;
const uint32_t can_heartbeat_data   = 0x54414542;

// ----------------------------------------------------------------------------------------

const uint16_t can_dataid_odrmgr_update = 0x0011;

typedef struct
{
    char msg[ 8 ];

}   can_data_odrmgr_update;

const uint16_t can_dataid_odrctl_update = 0x0012;

typedef struct
{
    bool estop : 1;
    bool motorctl : 1;

}   can_data_odrctl_update;

const uint16_t can_dataid_odrctl_button = 0x0013;

typedef struct
{
    bool button_1 : 1;
    bool button_2 : 1;

}   can_data_odrctl_button;

const uint16_t can_dataid_odr_start_pgm = 0x0014;

const uint8_t odr_pgm_stop          = 0x00;
const uint8_t odr_pgm_wander        = 0x01;
const uint8_t odr_pgm_straight_line = 0x02;
const uint8_t odr_pgm_small_box     = 0x03;
const uint8_t odr_pgm_go_to_waypt   = 0x04;
const uint8_t odr_pgm_robothon      = 0x05;

typedef struct
{
    uint8_t pgm_id;

}   can_data_pgm_selection;

// ----------------------------------------------------------------------------------------

const uint16_t can_dataid_imu_roll    = 0x0020;
const uint16_t can_dataid_imu_pitch   = 0x0021;
const uint16_t can_dataid_imu_yaw     = 0x0022;
const uint16_t can_dataid_imu_yaw_adj = 0x0023;   // magnetic declination compensation

const int32_t  can_data_imu_multiplier = 10000;

typedef struct
{
    int32_t data; // imu value * 10,000 (can_data_imu_multiplier)

}   can_data_imu_data;

const uint16_t can_dataid_imu_zero_gyros = 0x0024;

const uint16_t can_dataid_imu_health = 0x0025;

typedef struct
{
    uint32_t health; // raw health bits from the IMU module
    
} can_data_imu_health;

// ----------------------------------------------------------------------------------------

const uint16_t can_dataid_utc_timestamp = 0x0100;

typedef struct
{
    uint8_t packed_time[ 6 ];

}   can_data_utc_timestamp;

// ----------------------------------------------------------------------------------------

const uint16_t can_dataid_gps_latitude  = 0x0101;
const uint16_t can_dataid_gps_longitude = 0x0102;

const int32_t  can_data_gps_min_multiplier = 1000;

typedef struct
{
    int16_t degrees;
    int32_t min_thousandths;  // fractional minutes * 1,000 (can_data_gps_min_multiplier)

} can_data_gps_data;

// ----------------------------------------------------------------------------------------

const uint16_t can_dataid_gps_fix = 0x0103;

typedef struct
{
    uint8_t satellites; // zero indicates no fix

} can_data_gps_fix;

// ----------------------------------------------------------------------------------------

const uint16_t can_dataid_origin_lat  = 0x0104;
const uint16_t can_dataid_origin_long = 0x0105;

const uint16_t can_dataid_target_lat  = 0x0106;
const uint16_t can_dataid_target_long = 0x0107;

// these messages use the same structure can_data_gps_data

// ----------------------------------------------------------------------------------------

const uint16_t can_dataid_navigation = 0x0108;

const uint32_t can_data_nav_multiplier = 10000;

typedef struct
{
    uint16_t distance; // meters away from target
    int32_t  heading;  // angle * 10,000 (can_data_nav_multiplier)

} can_data_navigation;

// ----------------------------------------------------------------------------------------

const uint16_t can_dataid_wheel_position = 0x0110;

typedef struct
{
    int8_t angle_front;
    int8_t angle_rear;

} can_data_wheel_position;

// ----------------------------------------------------------------------------------------

const uint16_t can_dataid_wheel_speed = 0x0111;

typedef struct
{
    int8_t rpm_front;   // positive values indicate forward, negative reverse
    int8_t rpm_rear;

} can_data_wheel_speed;

// ----------------------------------------------------------------------------------------

const uint16_t can_dataid_wheel_status = 0x0112;

typedef struct
{
    int8_t actual_rpm_front;
    int8_t actual_rpm_rear;
    int8_t actual_motor_front;
    int8_t actual_motor_rear;
    int8_t angle_front;
    int8_t angle_rear;

} can_data_wheel_status;

// ----------------------------------------------------------------------------------------

const uint16_t can_dataid_sonar_front_state_enabled  = 0x0130;
const uint16_t can_dataid_sonar_front_state_disabled = 0x0131;

const uint16_t can_dataid_sonar_front_enable  = 0x0132;
const uint16_t can_dataid_sonar_front_disable = 0x0133;

const uint16_t can_dataid_sonar_front = 0x0134;

typedef struct
{
    uint8_t left;
    uint8_t center_left;
    uint8_t center_right;
    uint8_t right;

} can_data_sonar_front;

// ----------------------------------------------------------------------------------------

const uint16_t can_dataid_pixy_start_tracking = 0x0140;
const uint16_t can_dataid_pixy_stop_tracking  = 0x0141;

const uint16_t can_dataid_pixy_grabframe = 0x0143;

// ----------------------------------------------------------------------------------------

#if !defined( __AVR__ )
#pragma pack(pop)
#endif

// ----------------------------------------------------------------------------------------
#endif  // #if !defined( BCDRL_COMMON_CAN_CAN_MESSAGES_H )
// ----------------------------------------------------------------------------------------