gobot.io/x/gobot@v1.16.0/platforms/sphero/sphero_packets.go (about) 1 package sphero 2 3 // DefaultLocatorConfig returns a LocatorConfig with defaults 4 func DefaultLocatorConfig() LocatorConfig { 5 return LocatorConfig{ 6 Flags: 0x01, 7 X: 0x00, 8 Y: 0x00, 9 YawTare: 0x00, 10 } 11 } 12 13 // LocatorConfig provides configuration for the Location api. 14 // https://github.com/orbotix/DeveloperResources/blob/master/docs/Sphero_API_1.50.pdf 15 // The current (X,Y) coordinates of Sphero on the ground plane in centimeters. 16 type LocatorConfig struct { 17 // Determines whether calibrate commands automatically correct the yaw tare value 18 Flags uint8 19 // Controls how the X-plane is aligned with Sphero’s heading coordinate system. 20 X int16 21 // Controls how the Y-plane is aligned with Sphero’s heading coordinate system. 22 Y int16 23 // Controls how the X,Y-plane is aligned with Sphero’s heading coordinate system. 24 YawTare int16 25 } 26 27 // DefaultCollisionConfig returns a CollisionConfig with sensible collision defaults 28 func DefaultCollisionConfig() CollisionConfig { 29 return CollisionConfig{ 30 Method: 0x01, 31 Xt: 0x80, 32 Yt: 0x80, 33 Xs: 0x80, 34 Ys: 0x80, 35 Dead: 0x60, 36 } 37 } 38 39 // CollisionConfig provides configuration for the collision detection alogorithm. 40 // For more information refer to the official api specification https://github.com/orbotix/DeveloperResources/blob/master/docs/Collision%20detection%201.2.pdf. 41 type CollisionConfig struct { 42 // Detection method type to use. Methods 01h and 02h are supported as 43 // of FW ver 1.42. Use 00h to completely disable this service. 44 Method uint8 45 // An 8-bit settable threshold for the X (left/right) axes of Sphero. 46 // A value of 00h disables the contribution of that axis. 47 Xt uint8 48 // An 8-bit settable threshold for the Y (front/back) axes of Sphero. 49 // A value of 00h disables the contribution of that axis. 50 Yt uint8 51 // An 8-bit settable speed value for the X axes. This setting is ranged 52 // by the speed, then added to Xt to generate the final threshold value. 53 Xs uint8 54 // An 8-bit settable speed value for the Y axes. This setting is ranged 55 // by the speed, then added to Yt to generate the final threshold value. 56 Ys uint8 57 // An 8-bit post-collision dead time to prevent retriggering; specified 58 // in 10ms increments. 59 Dead uint8 60 } 61 62 // CollisionPacket represents the response from a Collision event 63 type CollisionPacket struct { 64 // Normalized impact components (direction of the collision event): 65 X, Y, Z int16 66 // Thresholds exceeded by X (1h) and/or Y (2h) axis (bitmask): 67 Axis byte 68 // Power that cross threshold Xt + Xs: 69 XMagnitude, YMagnitude int16 70 // Sphero's speed when impact detected: 71 Speed uint8 72 // Millisecond timer 73 Timestamp uint32 74 } 75 76 // DefaultDataStreamingConfig returns a DataStreamingConfig with a sampling rate of 40hz, 1 sample frame per package, unlimited streaming, and will stream all available sensor information 77 func DefaultDataStreamingConfig() DataStreamingConfig { 78 return DataStreamingConfig{ 79 N: 10, 80 M: 1, 81 Mask: 4294967295, 82 Pcnt: 0, 83 Mask2: 4294967295, 84 } 85 } 86 87 // DataStreamingConfig provides configuration for Sensor Data Streaming. 88 // For more information refer to the official api specification https://github.com/orbotix/DeveloperResources/blob/master/docs/Sphero_API_1.50.pdf page 28 89 type DataStreamingConfig struct { 90 // Divisor of the maximum sensor sampling rate 91 N uint16 92 // Number of sample frames emitted per packet 93 M uint16 94 // Bitwise selector of data sources to stream 95 Mask uint32 96 // Packet count 1-255 (or 0 for unlimited streaming) 97 Pcnt uint8 98 // Bitwise selector of more data sources to stream (optional) 99 Mask2 uint32 100 } 101 102 // DataStreamingPacket represents the response from a Data Streaming event 103 type DataStreamingPacket struct { 104 // 8000 0000h accelerometer axis X, raw -2048 to 2047 4mG 105 RawAccX int16 106 // 4000 0000h accelerometer axis Y, raw -2048 to 2047 4mG 107 RawAccY int16 108 // 2000 0000h accelerometer axis Z, raw -2048 to 2047 4mG 109 RawAccZ int16 110 // 1000 0000h gyro axis X, raw -32768 to 32767 0.068 degrees 111 RawGyroX int16 112 // 0800 0000h gyro axis Y, raw -32768 to 32767 0.068 degrees 113 RawGyroY int16 114 // 0400 0000h gyro axis Z, raw -32768 to 32767 0.068 degrees 115 RawGyroZ int16 116 // 0200 0000h Reserved 117 Rsrv1 int16 118 // 0100 0000h Reserved 119 Rsrv2 int16 120 // 0080 0000h Reserved 121 Rsrv3 int16 122 // 0040 0000h right motor back EMF, raw -32768 to 32767 22.5 cm 123 RawRMotorBack int16 124 // 0020 0000h left motor back EMF, raw -32768 to 32767 22.5 cm 125 RawLMotorBack int16 126 // 0010 0000h left motor, PWM, raw -2048 to 2047 duty cycle 127 RawLMotor int16 128 // 0008 0000h right motor, PWM raw -2048 to 2047 duty cycle 129 RawRMotor int16 130 // 0004 0000h IMU pitch angle, filtered -179 to 180 degrees 131 FiltPitch int16 132 // 0002 0000h IMU roll angle, filtered -179 to 180 degrees 133 FiltRoll int16 134 // 0001 0000h IMU yaw angle, filtered -179 to 180 degrees 135 FiltYaw int16 136 // 0000 8000h accelerometer axis X, filtered -32768 to 32767 1/4096 G 137 FiltAccX int16 138 // 0000 4000h accelerometer axis Y, filtered -32768 to 32767 1/4096 G 139 FiltAccY int16 140 // 0000 2000h accelerometer axis Z, filtered -32768 to 32767 1/4096 G 141 FiltAccZ int16 142 // 0000 1000h gyro axis X, filtered -20000 to 20000 0.1 dps 143 FiltGyroX int16 144 // 0000 0800h gyro axis Y, filtered -20000 to 20000 0.1 dps 145 FiltGyroY int16 146 // 0000 0400h gyro axis Z, filtered -20000 to 20000 0.1 dps 147 FiltGyroZ int16 148 // 0000 0200h Reserved 149 Rsrv4 int16 150 // 0000 0100h Reserved 151 Rsrv5 int16 152 // 0000 0080h Reserved 153 Rsrv6 int16 154 // 0000 0040h right motor back EMF, filtered -32768 to 32767 22.5 cm 155 FiltRMotorBack int16 156 // 0000 0020h left motor back EMF, filtered -32768 to 32767 22.5 cm 157 FiltLMotorBack int16 158 // 0000 0010h Reserved 1 159 Rsrv7 int16 160 // 0000 0008h Reserved 2 161 Rsrv8 int16 162 // 0000 0004h Reserved 3 163 Rsrv9 int16 164 // 0000 0002h Reserved 4 165 Rsrv10 int16 166 // 0000 0001h Reserved 5 167 Rsrv11 int16 168 // 8000 0000h Quaternion Q0 -10000 to 10000 1/10000 Q 169 Quat0 int16 170 // 4000 0000h Quaternion Q1 -10000 to 10000 1/10000 Q 171 Quat1 int16 172 // 2000 0000h Quaternion Q2 -10000 to 10000 1/10000 Q 173 Quat2 int16 174 // 1000 0000h Quaternion Q3 -10000 to 10000 1/10000 Q 175 Quat3 int16 176 // 0800 0000h Odometer X -32768 to 32767 cm 177 OdomX int16 178 // 0400 0000h Odometer Y -32768 to 32767 cm 179 OdomY int16 180 // 0200 0000h AccelOne 0 to 8000 1 mG 181 AccelOne int16 182 // 0100 0000h Velocity X -32768 to 32767 mm/s 183 VeloX int16 184 // 0080 0000h Velocity Y -32768 to 32767 mm/s 185 VeloY int16 186 }