iCub-main
Loading...
Searching...
No Matches
messages.h
Go to the documentation of this file.
1// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2
3/*
4 * Copyright (C) 2006 Giorgio Metta, Lorenzo Natale
5 * CopyPolicy: Released under the terms of the GNU GPL v2.0.
6 *
7 */
8
9
10//
11// $Id: messages.h,v 1.5 2009/07/13 10:07:47 randaz Exp $
12//
13//
14
15#ifndef __canbusmessagesh__
16#define __canbusmessagesh__
17#include "stdint.h"
18#include "iCubCanProtocol.h"
19#include "iCubCanProto_types.h"
20
21
22#define CAN_PROTOCOL_MAJOR 1 //this must be an exact match with the firmware protocol, otherwise terminates.
23#define CAN_PROTOCOL_MINOR 6 //this must be smaller or equal than the firmware protocol, otherwise terminates.
24#define LAST_BLL_BUILD 87 //this value is used only to print "please update" message
25#define LAST_MC4_BUILD 87 //this value is used only to print "please update" message
26
27//#define MODE_IDLE icubCanProto_controlmode_idle
28//#define MODE_POSITION icubCanProto_controlmode_position
29//#define MODE_VELOCITY icubCanProto_controlmode_velocity
30//#define MODE_TORQUE icubCanProto_controlmode_torque
31//#define MODE_IMPEDANCE_POS icubCanProto_controlmode_impedance_pos
32//#define MODE_IMPEDANCE_VEL icubCanProto_controlmode_impedance_vel
33//#define MODE_CALIB_ABS_POS_SENS icubCanProto_controlmode_calib_abs_pos_sens
34//#define MODE_CALIB_HARD_STOPS icubCanProto_controlmode_calib_hard_stops
35//#define MODE_HANDLE_HARD_STOPS icubCanProto_controlmode_handle_hard_stops
36//#define MODE_MARGIN_REACHED icubCanProto_controlmode_margin_reached
37//
38//#define MODE_OPENLOOP icubCanProto_controlmode_openloop
39
40/*
41 * this is 8 bits long, MSB is the channel (0 or 1).
42 */
43//#define CAN_NO_MESSAGE ICUBCANPROTO_POL_MC_CMD__NO_MESSAGE
44//#define CAN_CONTROLLER_RUN ICUBCANPROTO_POL_MC_CMD__CONTROLLER_RUN
45//#define CAN_CONTROLLER_IDLE ICUBCANPROTO_POL_MC_CMD__CONTROLLER_IDLE
46//#define CAN_TOGGLE_VERBOSE ICUBCANPROTO_POL_MC_CMD__TOGGLE_VERBOSE
47//#define CAN_CALIBRATE_ENCODER ICUBCANPROTO_POL_MC_CMD__CALIBRATE_ENCODER
48//#define CAN_ENABLE_PWM_PAD ICUBCANPROTO_POL_MC_CMD__ENABLE_PWM_PAD
49//#define CAN_DISABLE_PWM_PAD ICUBCANPROTO_POL_MC_CMD__DISABLE_PWM_PAD
50//#define CAN_GET_CONTROL_MODE ICUBCANPROTO_POL_MC_CMD__GET_CONTROL_MODE
51//#define CAN_MOTION_DONE ICUBCANPROTO_POL_MC_CMD__MOTION_DONE
52//#define CAN_SET_CONTROL_MODE ICUBCANPROTO_POL_MC_CMD__SET_CONTROL_MODE
53
54//#define CAN_WRITE_FLASH_MEM ICUBCANPROTO_POL_MC_CMD__WRITE_FLASH_MEM
55//#define CAN_READ_FLASH_MEM ICUBCANPROTO_POL_MC_CMD__READ_FLASH_MEM
56//#define CAN_GET_ADDITIONAL_INFO ICUBCANPROTO_POL_MC_CMD__GET_ADDITIONAL_INFO
57//#define CAN_SET_ADDITIONAL_INFO ICUBCANPROTO_POL_MC_CMD__SET_ADDITIONAL_INFO
58//#define CAN_SET_SPEED_ESTIM_SHIFT ICUBCANPROTO_POL_MC_CMD__SET_SPEED_ESTIM_SHIFT
59//#define CAN_SET_DEBUG_PARAM ICUBCANPROTO_POL_MC_CMD__SET_DEBUG_PARAM
60//#define CAN_GET_DEBUG_PARAM ICUBCANPROTO_POL_MC_CMD__GET_DEBUG_PARAM
61
62//#define CAN_GET_ENCODER_POSITION ICUBCANPROTO_POL_MC_CMD__GET_ENCODER_POSITION
63//#define CAN_SET_DESIRED_POSITION ICUBCANPROTO_POL_MC_CMD__SET_DESIRED_POSITION
64//#define CAN_GET_DESIRED_POSITION ICUBCANPROTO_POL_MC_CMD__GET_DESIRED_POSITION
65//#define CAN_SET_DESIRED_VELOCITY ICUBCANPROTO_POL_MC_CMD__SET_DESIRED_VELOCITY
66//#define CAN_GET_DESIRED_VELOCITY ICUBCANPROTO_POL_MC_CMD__GET_DESIRED_VELOCITY
67//#define CAN_SET_DESIRED_ACCELER ICUBCANPROTO_POL_MC_CMD__SET_DESIRED_ACCELER
68//#define CAN_GET_DESIRED_ACCELER ICUBCANPROTO_POL_MC_CMD__GET_DESIRED_ACCELER
69//#define CAN_POSITION_MOVE ICUBCANPROTO_POL_MC_CMD__POSITION_MOVE
70//#define CAN_VELOCITY_MOVE ICUBCANPROTO_POL_MC_CMD__VELOCITY_MOVE
71//#define CAN_SET_ENCODER_POSITION ICUBCANPROTO_POL_MC_CMD__SET_ENCODER_POSITION
72//#define CAN_SET_P_GAIN ICUBCANPROTO_POL_MC_CMD__SET_P_GAIN
73//#define CAN_GET_P_GAIN ICUBCANPROTO_POL_MC_CMD__GET_P_GAIN
74//#define CAN_SET_D_GAIN ICUBCANPROTO_POL_MC_CMD__SET_D_GAIN
75//#define CAN_GET_D_GAIN ICUBCANPROTO_POL_MC_CMD__GET_D_GAIN
76//#define CAN_SET_I_GAIN ICUBCANPROTO_POL_MC_CMD__SET_I_GAIN
77//#define CAN_GET_I_GAIN ICUBCANPROTO_POL_MC_CMD__GET_I_GAIN
78//#define CAN_SET_ILIM_GAIN ICUBCANPROTO_POL_MC_CMD__SET_ILIM_GAIN
79//#define CAN_GET_ILIM_GAIN ICUBCANPROTO_POL_MC_CMD__GET_ILIM_GAIN
80//#define CAN_SET_OFFSET ICUBCANPROTO_POL_MC_CMD__SET_OFFSET
81//#define CAN_GET_OFFSET ICUBCANPROTO_POL_MC_CMD__GET_OFFSET
82//#define CAN_SET_SCALE ICUBCANPROTO_POL_MC_CMD__SET_SCALE
83//#define CAN_GET_SCALE ICUBCANPROTO_POL_MC_CMD__GET_SCALE
84//#define CAN_SET_TLIM ICUBCANPROTO_POL_MC_CMD__SET_TLIM
85//#define CAN_GET_TLIM ICUBCANPROTO_POL_MC_CMD__GET_TLIM
86//#define CAN_SET_DESIRED_TORQUE ICUBCANPROTO_POL_MC_CMD__SET_DESIRED_TORQUE
87//#define CAN_GET_DESIRED_TORQUE ICUBCANPROTO_POL_MC_CMD__GET_DESIRED_TORQUE
88//#define CAN_STOP_TRAJECTORY ICUBCANPROTO_POL_MC_CMD__STOP_TRAJECTORY
89//
90//#define CAN_SET_BOARD_ID ICUBCANPROTO_POL_MC_CMD__SET_BOARD_ID
91//#define CAN_GET_BOARD_ID ICUBCANPROTO_POL_MC_CMD__GET_BOARD_ID
92//#define CAN_SET_TORQUE_SOURCE 52
93//
94//#define CAN_GET_PID_ERROR 55
95//#define CAN_GET_ERROR_STATUS 60
96//#define CAN_GET_ENCODER_VELOCITY 61
97//#define CAN_SET_COMMAND_POSITION 62
98//#define CAN_GET_PID_OUTPUT 63
99//#define CAN_SET_MIN_POSITION 64
100//#define CAN_GET_MIN_POSITION 65
101//#define CAN_SET_MAX_POSITION 66
102//#define CAN_GET_MAX_POSITION 67
103//#define CAN_SET_MAX_VELOCITY 68
104//#define CAN_GET_MAX_VELOCITY 69
105//
109//
110//#define CAN_SET_CURRENT_LIMIT 72
111//#define CAN_SET_BCAST_POLICY 73
112//
113//#define CAN_SET_VEL_SHIFT 74
114//
115//#define CAN_SET_OFFSET_ABS_ENCODER 75
116//#define CAN_GET_OFFSET_ABS_ENCODER 76
117//
118//#define CAN_SET_SMOOTH_PID 77
119//#define CAN_SET_TORQUE_PID 78
120//#define CAN_GET_TORQUE_PID 79
121//#define CAN_SET_TORQUE_PIDLIMITS 80
122//#define CAN_GET_TORQUE_PIDLIMITS 81
123//#define CAN_SET_POS_PID 82
124//#define CAN_GET_POS_PID 83
125//#define CAN_SET_POS_PIDLIMITS 84
126//#define CAN_GET_POS_PIDLIMITS 85
127//
128//#define CAN_SET_VEL_TIMEOUT 86
129//
130//#define CAN_SET_IMPEDANCE_PARAMS 87
131//#define CAN_GET_IMPEDANCE_PARAMS 88
132//#define CAN_SET_IMPEDANCE_OFFSET 89
133//#define CAN_GET_IMPEDANCE_OFFSET 90
134//
135//#define CAN_GET_FIRMWARE_VERSION 91
136//#define CAN_SET_OPTICAL_ENC_RATIO 92
137//#define CAN_SET_POS_STICTION_PARAMS 93
138//#define CAN_GET_POS_STICTION_PARAMS 94
139//#define CAN_SET_TORQUE_STICTION_PARAMS 95
140//#define CAN_GET_TORQUE_STICTION_PARAMS 96
141//
142//#define CAN_SET_BACKEMF_PARAMS 97
143//#define CAN_GET_BACKEMF_PARAMS 98
144//
145//#define CAN_SET_MODEL_PARAMS 99
146//#define CAN_GET_MODEL_PARAMS 100
147//
148//#define CAN_SET_CURRENT_PID 101
149//#define CAN_GET_CURRENT_PID 102
150//#define CAN_SET_CURRENT_PIDLIMITS 103
151//#define CAN_GET_CURRENT_PIDLIMITS 104
152//#define CAN_SET_VELOCITY_PID 105
153//#define CAN_GET_VELOCITY_PID 106
154//#define CAN_SET_VELOCITY_PIDLIMITS 107
155//#define CAN_GET_VELOCITY_PIDLIMITS 108
156//#define CAN_SET_DESIRED_CURRENT 109
157//#define CAN_GET_DESIRED_CURRENT 110
158//#define CAN_SET_PERIODIC_MSG_CONTENTS 111 //this message is used only for 2foc boards
159//#define CAN_SET_I2T_PARAMS 112
160//#define CAN_GET_I2T_PARAMS 113
161//#define CAN_SET_OPENLOOP_PARAMS 114
162//#define CAN_GET_OPENLOOP_PARAMS 115
163//
164//#define CAN_SET_OPENLOOP_PARAMS 114
165//#define CAN_GET_OPENLOOP_PARAMS 115
166#define CAN_SET_INTERACTION_MODE 116
167#define CAN_GET_INTERACTION_MODE 117
168
169//#define NUM_OF_MESSAGES 116
170
171/* error status values */
172#define ERROR_NONE 0 /* no error, all ok */
173#define ERROR_UNSPECIFIED 1 /* generic error */
174#define ERROR_MODE 2 /* mode error, can't apply command in current mode */
175#define ERROR_FMT 3 /* format error, command in wrong format */
176#define ERROR_SEND 4 /* can't send answer back */
177
178/*
179 * class 1 messages, broadcast
180 * when in bcast mode, messages are sent periodically by the controller
181 *
182 */
183#define CAN_BCAST_NONE 0
184//#define CAN_BCAST_POSITION ICUBCANPROTO_PER_MC_MSG__POSITION
185//#define CAN_BCAST_PID_VAL ICUBCANPROTO_PER_MC_MSG__PID_VAL
186//#define CAN_BCAST_STATUS ICUBCANPROTO_PER_MC_MSG__STATUS
187//#define CAN_BCAST_CURRENT ICUBCANPROTO_PER_MC_MSG__CURRENT
188//#define CAN_BCAST_OVERFLOW ICUBCANPROTO_PER_MC_MSG__OVERFLOW
189//#define CAN_BCAST_PRINT ICUBCANPROTO_PER_MC_MSG__PRINT
190//#define CAN_BCAST_VELOCITY ICUBCANPROTO_PER_MC_MSG__VELOCITY
191//#define CAN_BCAST_PID_ERROR ICUBCANPROTO_PER_MC_MSG__PID_ERROR
192//#define CAN_BCAST_DEBUG ICUBCANPROTO_PER_MC_MSG__DEBUG
193//#define CAN_BCAST_MOTOR_POSITION ICUBCANPROTO_PER_MC_MSG__MOTOR_POSITION
194//#define CAN_BCAST_MOTOR_SPEED ICUBCANPROTO_PER_MC_MSG__MOTOR_SPEED
195//#define CAN_BCAST_MAX_MSGS ICUBCANPROTO_PER_MC_MSG_MAXNUM
196
197#endif