view main/packages/common/can/can_messages.h @ 222:8170f8bde4d1 main

Specify packing to ensure the AVR compilation matches the Linux compilations.
author Bob Cook <bob@bobcookdev.com>
date Thu, 17 Apr 2014 21:59:49 -0700
parents 75c3c9c8868f
children 0639ad84827b
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-2013 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>

#pragma pack(push,1)

// ----------------------------------------------------------------------------------------
//  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
//
// ----------------------------------------------------------------------------------------

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

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

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_imu_roll  = 0x0020;
const uint16_t can_dataid_imu_pitch = 0x0021;
const uint16_t can_dataid_imu_yaw   = 0x0022;

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_utc_timestamp = 0x0100;

typedef struct
{
    uint8_t packed_time[ 6 ];

} can_data_utc_timestamp;

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

const uint16_t can_dataid_latitude  = 0x0101;
const uint16_t can_dataid_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_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;

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

#pragma pack(pop)

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