├── .gitignore
├── Anki.Vector.Samples.sln
├── Anki.Vector.Samples.sln.licenseheader
├── LICENSE
├── README.md
├── ReserveControl
├── Program.cs
└── ReserveControl.csproj
├── Tutorial_01_HelloWorld
├── Program.cs
└── Tutorial_01_HelloWorld.csproj
├── Tutorial_02_DriveSquare
├── Program.cs
└── Tutorial_02_DriveSquare.csproj
├── Tutorial_03_Motors
├── Program.cs
└── Tutorial_03_Motors.csproj
├── Tutorial_04_Animation
├── Program.cs
└── Tutorial_04_Animation.csproj
├── Tutorial_05_DriveOnOffCharger
├── Program.cs
└── Tutorial_05_DriveOnOffCharger.csproj
├── Tutorial_06_FaceImage
├── Program.cs
├── Tutorial_06_FaceImage.csproj
└── cozmo_image.jpg
├── Tutorial_07_DockWithCube
├── Program.cs
└── Tutorial_07_DockWithCube.csproj
├── Tutorial_08_DownloadPhoto
├── Program.cs
└── Tutorial_08_DownloadPhoto.csproj
├── Tutorial_09_EyeColor
├── Program.cs
└── Tutorial_09_EyeColor.csproj
├── Tutorial_10_PlayAudio
├── Program.cs
├── Tutorial_10_PlayAudio.csproj
├── bensound-summer.mp3
├── vector_alert.wav
└── vector_bell_whistle.wav
├── Tutorial_11_DriveToCliffAndBackUp
├── Program.cs
└── Tutorial_11_DriveToCliffAndBackUp.csproj
├── Tutorial_12_ControlPriorityLevel
├── Program.cs
└── Tutorial_12_ControlPriorityLevel.csproj
├── Tutorial_13_UserIntent
├── Program.cs
└── Tutorial_13_UserIntent.csproj
├── Tutorial_14_FaceEvent
├── Program.cs
└── Tutorial_14_FaceEvent.csproj
├── Tutorial_15_FaceFollower
├── Program.cs
└── Tutorial_15_FaceFollower.csproj
├── Tutorial_16_FeatureStatus
├── Program.cs
└── Tutorial_16_FeatureStatus.csproj
├── Tutorial_17_AppIntent
├── Program.cs
└── Tutorial_17_AppIntent.csproj
├── Tutorial_18_XboxDrive
├── Program.cs
├── Tutorial_18_XboxDrive.csproj
└── XBoxController.cs
└── VectorConfigure
├── AddCommand.cs
├── DeleteCommand.cs
├── ListCommand.cs
├── Program.cs
├── Settings.StyleCop
└── VectorConfigure.csproj
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015/2017 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # Visual Studio 2017 auto generated files
33 | Generated\ Files/
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 | # NUNIT
40 | *.VisualState.xml
41 | TestResult.xml
42 |
43 | # Build Results of an ATL Project
44 | [Dd]ebugPS/
45 | [Rr]eleasePS/
46 | dlldata.c
47 |
48 | # Benchmark Results
49 | BenchmarkDotNet.Artifacts/
50 |
51 | # .NET Core
52 | project.lock.json
53 | project.fragment.lock.json
54 | artifacts/
55 | **/Properties/launchSettings.json
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_i.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *.log
81 | *.vspscc
82 | *.vssscc
83 | .builds
84 | *.pidb
85 | *.svclog
86 | *.scc
87 |
88 | # Chutzpah Test files
89 | _Chutzpah*
90 |
91 | # Visual C++ cache files
92 | ipch/
93 | *.aps
94 | *.ncb
95 | *.opendb
96 | *.opensdf
97 | *.sdf
98 | *.cachefile
99 | *.VC.db
100 | *.VC.VC.opendb
101 |
102 | # Visual Studio profiler
103 | *.psess
104 | *.vsp
105 | *.vspx
106 | *.sap
107 |
108 | # Visual Studio Trace Files
109 | *.e2e
110 |
111 | # TFS 2012 Local Workspace
112 | $tf/
113 |
114 | # Guidance Automation Toolkit
115 | *.gpState
116 |
117 | # ReSharper is a .NET coding add-in
118 | _ReSharper*/
119 | *.[Rr]e[Ss]harper
120 | *.DotSettings.user
121 |
122 | # JustCode is a .NET coding add-in
123 | .JustCode
124 |
125 | # TeamCity is a build add-in
126 | _TeamCity*
127 |
128 | # DotCover is a Code Coverage Tool
129 | *.dotCover
130 |
131 | # AxoCover is a Code Coverage Tool
132 | .axoCover/*
133 | !.axoCover/settings.json
134 |
135 | # Visual Studio code coverage results
136 | *.coverage
137 | *.coveragexml
138 |
139 | # NCrunch
140 | _NCrunch_*
141 | .*crunch*.local.xml
142 | nCrunchTemp_*
143 |
144 | # MightyMoose
145 | *.mm.*
146 | AutoTest.Net/
147 |
148 | # Web workbench (sass)
149 | .sass-cache/
150 |
151 | # Installshield output folder
152 | [Ee]xpress/
153 |
154 | # DocProject is a documentation generator add-in
155 | DocProject/buildhelp/
156 | DocProject/Help/*.HxT
157 | DocProject/Help/*.HxC
158 | DocProject/Help/*.hhc
159 | DocProject/Help/*.hhk
160 | DocProject/Help/*.hhp
161 | DocProject/Help/Html2
162 | DocProject/Help/html
163 |
164 | # Click-Once directory
165 | publish/
166 |
167 | # Publish Web Output
168 | *.[Pp]ublish.xml
169 | *.azurePubxml
170 | # Note: Comment the next line if you want to checkin your web deploy settings,
171 | # but database connection strings (with potential passwords) will be unencrypted
172 | *.pubxml
173 | *.publishproj
174 |
175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
176 | # checkin your Azure Web App publish settings, but sensitive information contained
177 | # in these scripts will be unencrypted
178 | PublishScripts/
179 |
180 | # NuGet Packages
181 | *.nupkg
182 | # The packages folder can be ignored because of Package Restore
183 | **/[Pp]ackages/*
184 | # except build/, which is used as an MSBuild target.
185 | !**/[Pp]ackages/build/
186 | # Uncomment if necessary however generally it will be regenerated when needed
187 | #!**/[Pp]ackages/repositories.config
188 | # NuGet v3's project.json files produces more ignorable files
189 | *.nuget.props
190 | *.nuget.targets
191 |
192 | # Microsoft Azure Build Output
193 | csx/
194 | *.build.csdef
195 |
196 | # Microsoft Azure Emulator
197 | ecf/
198 | rcf/
199 |
200 | # Windows Store app package directories and files
201 | AppPackages/
202 | BundleArtifacts/
203 | Package.StoreAssociation.xml
204 | _pkginfo.txt
205 | *.appx
206 |
207 | # Visual Studio cache files
208 | # files ending in .cache can be ignored
209 | *.[Cc]ache
210 | # but keep track of directories ending in .cache
211 | !*.[Cc]ache/
212 |
213 | # Others
214 | ClientBin/
215 | ~$*
216 | *~
217 | *.dbmdl
218 | *.dbproj.schemaview
219 | *.jfm
220 | *.pfx
221 | *.publishsettings
222 | orleans.codegen.cs
223 |
224 | # Including strong name files can present a security risk
225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
226 | #*.snk
227 |
228 | # Since there are multiple workflows, uncomment next line to ignore bower_components
229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
230 | #bower_components/
231 |
232 | # RIA/Silverlight projects
233 | Generated_Code/
234 |
235 | # Backup & report files from converting an old project file
236 | # to a newer Visual Studio version. Backup files are not needed,
237 | # because we have git ;-)
238 | _UpgradeReport_Files/
239 | Backup*/
240 | UpgradeLog*.XML
241 | UpgradeLog*.htm
242 | ServiceFabricBackup/
243 | *.rptproj.bak
244 |
245 | # SQL Server files
246 | *.mdf
247 | *.ldf
248 | *.ndf
249 |
250 | # Business Intelligence projects
251 | *.rdl.data
252 | *.bim.layout
253 | *.bim_*.settings
254 | *.rptproj.rsuser
255 |
256 | # Microsoft Fakes
257 | FakesAssemblies/
258 |
259 | # GhostDoc plugin setting file
260 | *.GhostDoc.xml
261 |
262 | # Node.js Tools for Visual Studio
263 | .ntvs_analysis.dat
264 | node_modules/
265 |
266 | # Visual Studio 6 build log
267 | *.plg
268 |
269 | # Visual Studio 6 workspace options file
270 | *.opt
271 |
272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
273 | *.vbw
274 |
275 | # Visual Studio LightSwitch build output
276 | **/*.HTMLClient/GeneratedArtifacts
277 | **/*.DesktopClient/GeneratedArtifacts
278 | **/*.DesktopClient/ModelManifest.xml
279 | **/*.Server/GeneratedArtifacts
280 | **/*.Server/ModelManifest.xml
281 | _Pvt_Extensions
282 |
283 | # Paket dependency manager
284 | .paket/paket.exe
285 | paket-files/
286 |
287 | # FAKE - F# Make
288 | .fake/
289 |
290 | # JetBrains Rider
291 | .idea/
292 | *.sln.iml
293 |
294 | # CodeRush
295 | .cr/
296 |
297 | # Python Tools for Visual Studio (PTVS)
298 | __pycache__/
299 | *.pyc
300 |
301 | # Cake - Uncomment if you are using it
302 | # tools/**
303 | # !tools/packages.config
304 |
305 | # Tabs Studio
306 | *.tss
307 |
308 | # Telerik's JustMock configuration file
309 | *.jmconfig
310 |
311 | # BizTalk build output
312 | *.btp.cs
313 | *.btm.cs
314 | *.odx.cs
315 | *.xsd.cs
316 |
317 | # OpenCover UI analysis results
318 | OpenCover/
319 |
320 | # Azure Stream Analytics local run output
321 | ASALocalRun/
322 |
323 | # MSBuild Binary and Structured Log
324 | *.binlog
325 |
326 | # NVidia Nsight GPU debugger configuration file
327 | *.nvuser
328 |
329 | # MFractors (Xamarin productivity tool) working folder
330 | .mfractor/
331 | /.svn
332 | /Anki.Vector.Samples.Dev.sln
333 |
--------------------------------------------------------------------------------
/Anki.Vector.Samples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29102.190
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_02_DriveSquare", "Tutorial_02_DriveSquare\Tutorial_02_DriveSquare.csproj", "{440B50B4-DD81-447E-A852-065E5C5D6D0A}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_03_Motors", "Tutorial_03_Motors\Tutorial_03_Motors.csproj", "{6F8AE87F-53F5-48BD-85D0-B56B56096BDB}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_04_Animation", "Tutorial_04_Animation\Tutorial_04_Animation.csproj", "{919D801E-E63F-47FB-ACC1-3F5343C6492C}"
11 | EndProject
12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_05_DriveOnOffCharger", "Tutorial_05_DriveOnOffCharger\Tutorial_05_DriveOnOffCharger.csproj", "{BD4E478A-12E8-4485-A91D-BFBF82911D96}"
13 | EndProject
14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_06_FaceImage", "Tutorial_06_FaceImage\Tutorial_06_FaceImage.csproj", "{1FC6652B-40BD-4F74-9A44-4892C712D7DC}"
15 | EndProject
16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_07_DockWithCube", "Tutorial_07_DockWithCube\Tutorial_07_DockWithCube.csproj", "{41EBF12F-992D-4B34-8680-298685048674}"
17 | EndProject
18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_10_PlayAudio", "Tutorial_10_PlayAudio\Tutorial_10_PlayAudio.csproj", "{DFF44694-C260-41DF-8644-174011DB7108}"
19 | EndProject
20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_11_DriveToCliffAndBackUp", "Tutorial_11_DriveToCliffAndBackUp\Tutorial_11_DriveToCliffAndBackUp.csproj", "{DDCAB080-1942-4698-A9A3-C2D23B4BCF8D}"
21 | EndProject
22 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_01_HelloWorld", "Tutorial_01_HelloWorld\Tutorial_01_HelloWorld.csproj", "{AC9228D9-034B-4EB4-A3C5-332279715518}"
23 | EndProject
24 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VectorConfigure", "VectorConfigure\VectorConfigure.csproj", "{BA4B39FC-256E-4C35-B3CF-92008715894D}"
25 | EndProject
26 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReserveControl", "ReserveControl\ReserveControl.csproj", "{4DE8DBC1-E395-4FC4-A59A-8118A7F7279D}"
27 | EndProject
28 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_08_DownloadPhoto", "Tutorial_08_DownloadPhoto\Tutorial_08_DownloadPhoto.csproj", "{242A8F07-AC2E-4D53-9DFD-2CE9DADEAE68}"
29 | EndProject
30 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_09_EyeColor", "Tutorial_09_EyeColor\Tutorial_09_EyeColor.csproj", "{733CBE56-3291-4D50-A490-A3631D06DB3E}"
31 | EndProject
32 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_12_ControlPriorityLevel", "Tutorial_12_ControlPriorityLevel\Tutorial_12_ControlPriorityLevel.csproj", "{7E4AB4AD-BFAF-423A-8D82-16F585C6A58E}"
33 | EndProject
34 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_13_UserIntent", "Tutorial_13_UserIntent\Tutorial_13_UserIntent.csproj", "{47D0BC5F-794C-4917-A3DF-C5DA65EFD798}"
35 | EndProject
36 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_14_FaceEvent", "Tutorial_14_FaceEvent\Tutorial_14_FaceEvent.csproj", "{A1108EE2-BF4B-405C-9D2F-3CDA1FDCE6C6}"
37 | EndProject
38 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_15_FaceFollower", "Tutorial_15_FaceFollower\Tutorial_15_FaceFollower.csproj", "{7504FB09-4D54-4FC3-8C71-78A3079CAD74}"
39 | EndProject
40 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_16_FeatureStatus", "Tutorial_16_FeatureStatus\Tutorial_16_FeatureStatus.csproj", "{B22099AE-65B3-4D2B-9C26-DAE1E01F1394}"
41 | EndProject
42 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_17_AppIntent", "Tutorial_17_AppIntent\Tutorial_17_AppIntent.csproj", "{094723D9-BAAC-4AE0-9AE5-1FFA13DA5010}"
43 | EndProject
44 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tutorial_18_XboxDrive", "Tutorial_18_XboxDrive\Tutorial_18_XboxDrive.csproj", "{58D34D54-BE6A-4BB5-BAF4-D3D7A0520F0A}"
45 | EndProject
46 | Global
47 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
48 | Debug|Any CPU = Debug|Any CPU
49 | Release|Any CPU = Release|Any CPU
50 | EndGlobalSection
51 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
52 | {440B50B4-DD81-447E-A852-065E5C5D6D0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53 | {440B50B4-DD81-447E-A852-065E5C5D6D0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
54 | {440B50B4-DD81-447E-A852-065E5C5D6D0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
55 | {440B50B4-DD81-447E-A852-065E5C5D6D0A}.Release|Any CPU.Build.0 = Release|Any CPU
56 | {6F8AE87F-53F5-48BD-85D0-B56B56096BDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57 | {6F8AE87F-53F5-48BD-85D0-B56B56096BDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
58 | {6F8AE87F-53F5-48BD-85D0-B56B56096BDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
59 | {6F8AE87F-53F5-48BD-85D0-B56B56096BDB}.Release|Any CPU.Build.0 = Release|Any CPU
60 | {919D801E-E63F-47FB-ACC1-3F5343C6492C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
61 | {919D801E-E63F-47FB-ACC1-3F5343C6492C}.Debug|Any CPU.Build.0 = Debug|Any CPU
62 | {919D801E-E63F-47FB-ACC1-3F5343C6492C}.Release|Any CPU.ActiveCfg = Release|Any CPU
63 | {919D801E-E63F-47FB-ACC1-3F5343C6492C}.Release|Any CPU.Build.0 = Release|Any CPU
64 | {BD4E478A-12E8-4485-A91D-BFBF82911D96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
65 | {BD4E478A-12E8-4485-A91D-BFBF82911D96}.Debug|Any CPU.Build.0 = Debug|Any CPU
66 | {BD4E478A-12E8-4485-A91D-BFBF82911D96}.Release|Any CPU.ActiveCfg = Release|Any CPU
67 | {BD4E478A-12E8-4485-A91D-BFBF82911D96}.Release|Any CPU.Build.0 = Release|Any CPU
68 | {1FC6652B-40BD-4F74-9A44-4892C712D7DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
69 | {1FC6652B-40BD-4F74-9A44-4892C712D7DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
70 | {1FC6652B-40BD-4F74-9A44-4892C712D7DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
71 | {1FC6652B-40BD-4F74-9A44-4892C712D7DC}.Release|Any CPU.Build.0 = Release|Any CPU
72 | {41EBF12F-992D-4B34-8680-298685048674}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
73 | {41EBF12F-992D-4B34-8680-298685048674}.Debug|Any CPU.Build.0 = Debug|Any CPU
74 | {41EBF12F-992D-4B34-8680-298685048674}.Release|Any CPU.ActiveCfg = Release|Any CPU
75 | {41EBF12F-992D-4B34-8680-298685048674}.Release|Any CPU.Build.0 = Release|Any CPU
76 | {DFF44694-C260-41DF-8644-174011DB7108}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
77 | {DFF44694-C260-41DF-8644-174011DB7108}.Debug|Any CPU.Build.0 = Debug|Any CPU
78 | {DFF44694-C260-41DF-8644-174011DB7108}.Release|Any CPU.ActiveCfg = Release|Any CPU
79 | {DFF44694-C260-41DF-8644-174011DB7108}.Release|Any CPU.Build.0 = Release|Any CPU
80 | {DDCAB080-1942-4698-A9A3-C2D23B4BCF8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
81 | {DDCAB080-1942-4698-A9A3-C2D23B4BCF8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
82 | {DDCAB080-1942-4698-A9A3-C2D23B4BCF8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
83 | {DDCAB080-1942-4698-A9A3-C2D23B4BCF8D}.Release|Any CPU.Build.0 = Release|Any CPU
84 | {AC9228D9-034B-4EB4-A3C5-332279715518}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
85 | {AC9228D9-034B-4EB4-A3C5-332279715518}.Debug|Any CPU.Build.0 = Debug|Any CPU
86 | {AC9228D9-034B-4EB4-A3C5-332279715518}.Release|Any CPU.ActiveCfg = Release|Any CPU
87 | {AC9228D9-034B-4EB4-A3C5-332279715518}.Release|Any CPU.Build.0 = Release|Any CPU
88 | {BA4B39FC-256E-4C35-B3CF-92008715894D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
89 | {BA4B39FC-256E-4C35-B3CF-92008715894D}.Debug|Any CPU.Build.0 = Debug|Any CPU
90 | {BA4B39FC-256E-4C35-B3CF-92008715894D}.Release|Any CPU.ActiveCfg = Release|Any CPU
91 | {BA4B39FC-256E-4C35-B3CF-92008715894D}.Release|Any CPU.Build.0 = Release|Any CPU
92 | {4DE8DBC1-E395-4FC4-A59A-8118A7F7279D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
93 | {4DE8DBC1-E395-4FC4-A59A-8118A7F7279D}.Debug|Any CPU.Build.0 = Debug|Any CPU
94 | {4DE8DBC1-E395-4FC4-A59A-8118A7F7279D}.Release|Any CPU.ActiveCfg = Release|Any CPU
95 | {4DE8DBC1-E395-4FC4-A59A-8118A7F7279D}.Release|Any CPU.Build.0 = Release|Any CPU
96 | {242A8F07-AC2E-4D53-9DFD-2CE9DADEAE68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
97 | {242A8F07-AC2E-4D53-9DFD-2CE9DADEAE68}.Debug|Any CPU.Build.0 = Debug|Any CPU
98 | {242A8F07-AC2E-4D53-9DFD-2CE9DADEAE68}.Release|Any CPU.ActiveCfg = Release|Any CPU
99 | {242A8F07-AC2E-4D53-9DFD-2CE9DADEAE68}.Release|Any CPU.Build.0 = Release|Any CPU
100 | {733CBE56-3291-4D50-A490-A3631D06DB3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
101 | {733CBE56-3291-4D50-A490-A3631D06DB3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
102 | {733CBE56-3291-4D50-A490-A3631D06DB3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
103 | {733CBE56-3291-4D50-A490-A3631D06DB3E}.Release|Any CPU.Build.0 = Release|Any CPU
104 | {7E4AB4AD-BFAF-423A-8D82-16F585C6A58E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
105 | {7E4AB4AD-BFAF-423A-8D82-16F585C6A58E}.Debug|Any CPU.Build.0 = Debug|Any CPU
106 | {7E4AB4AD-BFAF-423A-8D82-16F585C6A58E}.Release|Any CPU.ActiveCfg = Release|Any CPU
107 | {7E4AB4AD-BFAF-423A-8D82-16F585C6A58E}.Release|Any CPU.Build.0 = Release|Any CPU
108 | {47D0BC5F-794C-4917-A3DF-C5DA65EFD798}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
109 | {47D0BC5F-794C-4917-A3DF-C5DA65EFD798}.Debug|Any CPU.Build.0 = Debug|Any CPU
110 | {47D0BC5F-794C-4917-A3DF-C5DA65EFD798}.Release|Any CPU.ActiveCfg = Release|Any CPU
111 | {47D0BC5F-794C-4917-A3DF-C5DA65EFD798}.Release|Any CPU.Build.0 = Release|Any CPU
112 | {A1108EE2-BF4B-405C-9D2F-3CDA1FDCE6C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
113 | {A1108EE2-BF4B-405C-9D2F-3CDA1FDCE6C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
114 | {A1108EE2-BF4B-405C-9D2F-3CDA1FDCE6C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
115 | {A1108EE2-BF4B-405C-9D2F-3CDA1FDCE6C6}.Release|Any CPU.Build.0 = Release|Any CPU
116 | {7504FB09-4D54-4FC3-8C71-78A3079CAD74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
117 | {7504FB09-4D54-4FC3-8C71-78A3079CAD74}.Debug|Any CPU.Build.0 = Debug|Any CPU
118 | {7504FB09-4D54-4FC3-8C71-78A3079CAD74}.Release|Any CPU.ActiveCfg = Release|Any CPU
119 | {7504FB09-4D54-4FC3-8C71-78A3079CAD74}.Release|Any CPU.Build.0 = Release|Any CPU
120 | {B22099AE-65B3-4D2B-9C26-DAE1E01F1394}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
121 | {B22099AE-65B3-4D2B-9C26-DAE1E01F1394}.Debug|Any CPU.Build.0 = Debug|Any CPU
122 | {B22099AE-65B3-4D2B-9C26-DAE1E01F1394}.Release|Any CPU.ActiveCfg = Release|Any CPU
123 | {B22099AE-65B3-4D2B-9C26-DAE1E01F1394}.Release|Any CPU.Build.0 = Release|Any CPU
124 | {094723D9-BAAC-4AE0-9AE5-1FFA13DA5010}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
125 | {094723D9-BAAC-4AE0-9AE5-1FFA13DA5010}.Debug|Any CPU.Build.0 = Debug|Any CPU
126 | {094723D9-BAAC-4AE0-9AE5-1FFA13DA5010}.Release|Any CPU.ActiveCfg = Release|Any CPU
127 | {094723D9-BAAC-4AE0-9AE5-1FFA13DA5010}.Release|Any CPU.Build.0 = Release|Any CPU
128 | {58D34D54-BE6A-4BB5-BAF4-D3D7A0520F0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
129 | {58D34D54-BE6A-4BB5-BAF4-D3D7A0520F0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
130 | {58D34D54-BE6A-4BB5-BAF4-D3D7A0520F0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
131 | {58D34D54-BE6A-4BB5-BAF4-D3D7A0520F0A}.Release|Any CPU.Build.0 = Release|Any CPU
132 | EndGlobalSection
133 | GlobalSection(SolutionProperties) = preSolution
134 | HideSolutionNode = FALSE
135 | EndGlobalSection
136 | GlobalSection(ExtensibilityGlobals) = postSolution
137 | SolutionGuid = {8680C591-3A63-43D7-8B22-CFECCA0F7EB2}
138 | EndGlobalSection
139 | EndGlobal
140 |
--------------------------------------------------------------------------------
/Anki.Vector.Samples.sln.licenseheader:
--------------------------------------------------------------------------------
1 | extensions: designer.cs generated.cs
2 | extensions: .cs
3 | //
4 | // Copyright (c) %CurrentYear% Wayne Venables. All rights reserved.
5 | //
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Anki Vector .NET SDK Sample applications
2 |
3 | This solution contains 2 applications and 15 tutorial applications for the Anki Vector SDK.
4 |
5 | ## Getting Started
6 |
7 | ### Documentation
8 |
9 | * [Anki Vector .NET SDK Documentation](https://codaris.github.io/Anki.Vector.SDK/)
10 |
11 | * [Anki Vector .NET SDK GitHub Project](https://github.com/codaris/Anki.Vector.SDK)
12 |
13 |
14 | ### Vector SDK Configuration and Authentication
15 |
16 | In order to run these samples, you will need authenticate with the robot and create a configuration file
17 | that is stored in your user profile. This SDK uses the same configuration file as the Python SDK
18 | and the [Vector Explorer](https://www.weekendrobot.com/vectorexplorer) application.
19 |
20 | The easiest way to get setup with Vector on you Windows PC is to install [Vector Explorer](https://www.weekendrobot.com/vectorexplorer) and configure your robot through that application. However, you
21 | can also use the `VectorConfigure` command line tool located in this solution.
22 |
23 | ## Sample Projects
24 |
25 | ### `VectorConfigure`
26 |
27 | This is a command line tool for configuring and authenticating the SDK with your Vector robot. You will need to run this
28 | command to create a configuration file in your profile to run the remaining SDK sample applications in this solution.
29 |
30 | You will be prompted for your robot’s name, ip address and serial number. You will also be asked for your Anki login and password. Make sure to use the same account that was used to set up your Vector. These credentials give full access to your robot, including camera stream, audio stream and data. *Do not share these credentials*.
31 |
32 | ### `ReserveControl`
33 |
34 | Command line tool for reserving control of Vector. Reserving control will keep Vector still during development so he doesn't drive off in-between runs of your code. It's also useful to keep Vector still when you need some peace and quiet.
35 |
36 | ### `Tutorial_01_HelloWorld`
37 |
38 | Everyone's first project, Vector will speak "Hello World".
39 |
40 | ### `Tutorial_02_DriveSquare`
41 |
42 | Make Vector drive in a square by going forward and turning left 4 times in a row.
43 |
44 | ### `Tutorial_03_Motors`
45 |
46 | Drive Vector's wheels, lift and head motors directly. This is an example of how you can also have low-level control of Vector's motors (wheels, lift and head) for fine-grained control and ease of controlling multiple things at once.
47 |
48 | ### `Tutorial_04_Animation`
49 |
50 | Play a few of Vector's animations. Play an animation using a trigger, and then another animation by name.
51 |
52 | ### `Tutorial_05_DriveOnOffCharger`
53 |
54 | Tell Vector to return to his charger and then drive off.
55 |
56 | ### `Tutorial_06_FaceImage`
57 |
58 | Display an JPEG image on Vector's face.
59 |
60 | ### `Tutorial_07_DockWithCube`
61 |
62 | Tell Vector to drive up to a seen cube. This example demonstrates Vector driving to and docking with a cube, without picking it up. Vector will line his arm hooks up with the cube so that they are inserted into the cube's corners. You must place a cube in front of Vector so that he can see it.
63 |
64 | ### `Tutorial_08_DownloadPhoto`
65 |
66 | Downloads all the photos stored in Vector. Before running this script, please make sure you have successfully had Vector take a photo by saying, "Hey Vector! Take a photo."
67 |
68 | ### `Tutorial_09_EyeColor`
69 |
70 | Set Vector's eye color. Note that Vector's eye color will return to normal when the connection terminates.
71 |
72 | ### `Tutorial_10_PlayAudio`
73 |
74 | Play audio files through Vector's speaker. This will play an embedded MP3 music file through Vector's speakers.
75 |
76 | ### `Tutorial_11_DriveToCliffAndBackUp`
77 |
78 | Make Vector drive to a cliff and back up. Place the robot about a foot from a "cliff" (such as a tabletop edge), then run this script.
79 |
80 | ### `Tutorial_12_ControlPriorityLevel`
81 |
82 | Vector maintains SDK behavior control after being picked up. During normal operation, SDK programs cannot maintain control over Vector when he is at a cliff, stuck on an edge or obstacle, tilted or inclined, picked up, in darkness, etc. This script demonstrates how to use the highest level SDK behavior control to make Vector perform actions that normally take priority over the SDK.
83 |
84 | ### `Tutorial_13_UserIntent`
85 |
86 | Return information about a voice commands given to Vector. The user_intent event is only dispatched when the SDK program has requested behavior control and Vector gets a voice command. After the robot hears "Hey Vector! ..." and a valid voice command is given for example "...what time is it?") the event will be dispatched and displayed.
87 |
88 | ### `Tutorial_14_FaceEvent`
89 |
90 | Wait for Vector to see a face, and then print output to the console. This script demonstrates how to set up a listener for an event. It subscribes to event `ObservedFace`. When that event is dispatched, the lambda is called, which prints text to the console. Vector will also say "I see a face" one time, and the program will exit when he finishes speaking.
91 |
92 | ### `Tutorial_15_FaceFollower`
93 |
94 | Make Vector turn toward a face. This script shows off the turn towards face behavior. It will wait for a face and then constantly turn towards it to keep it in frame.
95 |
96 | ### `Tutorial_16_FeatureStatus`
97 |
98 | Demonstration of the FeatureStatus event that shows which features Vector's AI is used to perform operations. This sample was contributed by [Randall Maas](https://github.com/randym32).
99 |
100 | ### `Tutorial_17_AppIntent`
101 |
102 | Demonstration of submitting AppIntents to Vector for processing. This sample was contributed by [Randall Maas](https://github.com/randym32).
103 |
104 | ### `Tutorial_18_XboxDrive`
105 |
106 | Drive Vector around with an XBox Controller. This sample was contributed by [Randall Maas](https://github.com/randym32).
107 |
108 | ## Getting Help
109 |
110 | There are numerous places to get help with programming Vector using the .NET SDK:
111 |
112 | * **Official Anki developer forums**: https://forums.anki.com/
113 |
114 | * **Anki Vector developer subreddit**: https://www.reddit.com/r/ankivectordevelopers
115 |
116 | * **Anki robots Discord chat**: https://discord.gg/FT8EYwu
117 |
118 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/ReserveControl/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using Anki.Vector;
7 |
8 | namespace ReserveControl
9 | {
10 | class Program
11 | {
12 | ///
13 | /// Reserve SDK Behavior Control
14 | /// While this script runs, other SDK scripts may run and Vector will not perform most default behaviors before/after they complete.This will keep Vector still.
15 | /// High priority behaviors like returning to the charger in a low battery situation, or retreating from a cliff will still take precedence.
16 | ///
17 | static void Main()
18 | {
19 | using var behaviorControl = new ReserveBehaviorControl();
20 | Console.WriteLine("Vector behavior control reserved for SDK. Hit 'Enter' to release control.");
21 | while (Console.ReadKey().Key != ConsoleKey.Enter) ;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ReserveControl/ReserveControl.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Tutorial_01_HelloWorld/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Threading.Tasks;
7 | using Anki.Vector;
8 |
9 | namespace Tutorial_01_HelloWorld
10 | {
11 | class Program
12 | {
13 | ///
14 | /// Hello World
15 | /// Make Vector say 'Hello World' in this simple Vector SDK example program.
16 | ///
17 | public static async Task Main()
18 | {
19 | // Create a new connection to the first configured Vector
20 | using var robot = await Robot.NewConnection();
21 |
22 | Console.WriteLine("Requesting control of Vector...");
23 | await robot.Control.RequestControl();
24 |
25 | Console.WriteLine("Saying 'Hello World'...");
26 | await robot.Behavior.SayText("Hello World");
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/Tutorial_01_HelloWorld/Tutorial_01_HelloWorld.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tutorial_02_DriveSquare/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Threading.Tasks;
7 | using Anki.Vector;
8 | using Anki.Vector.Types;
9 |
10 | namespace Tutorial_02_DriveSquare
11 | {
12 | class Program
13 | {
14 | ///
15 | /// Make Vector drive in a square.
16 | /// Make Vector drive in a square by going forward and turning left 4 times in a row.
17 | ///
18 | ///
19 | public static async Task Main()
20 | {
21 | // Create a new connection to the first configured Vector
22 | using var robot = await Robot.NewConnection();
23 |
24 | Console.WriteLine("Requesting control of Vector...");
25 | await robot.Control.RequestControl();
26 |
27 | // If Vector is on the charger, drive him off the charger
28 | if (robot.Status.IsOnCharger)
29 | {
30 | Console.WriteLine("Drive Vector off charger...");
31 | await robot.Behavior.DriveOffCharger();
32 | }
33 |
34 | // Loop 4 times
35 | for (int i = 0; i < 4; i++)
36 | {
37 | Console.WriteLine("Drive Vector straight...");
38 | await robot.Behavior.DriveStraight(200, 50);
39 | Console.WriteLine("Turn Vector in place...");
40 | await robot.Behavior.TurnInPlace(90.Degrees());
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Tutorial_02_DriveSquare/Tutorial_02_DriveSquare.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tutorial_03_Motors/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Threading.Tasks;
7 | using Anki.Vector;
8 |
9 | namespace Tutorial_03_Motors
10 | {
11 | class Program
12 | {
13 | ///
14 | /// Drive Vector's wheels, lift and head motors directly.
15 | /// This is an example of how you can also have low-level control of Vector's motors
16 | /// (wheels, lift and head) for fine-grained control and ease of controlling multiple things at once.
17 | ///
18 | public static async Task Main()
19 | {
20 | // Create a new connection to the first configured Vector
21 | using var robot = await Robot.NewConnection();
22 |
23 | Console.WriteLine("Requesting control of Vector...");
24 | await robot.Control.RequestControl();
25 |
26 | // If Vector is on the charger, drive him off the charger
27 | if (robot.Status.IsOnCharger)
28 | {
29 | Console.WriteLine("Drive Vector off charger...");
30 | await robot.Behavior.DriveOffCharger();
31 | }
32 |
33 | // Tell the head motor to start lowering the head (at 5 radians per second)
34 | Console.WriteLine("Lower Vector's head...");
35 | await robot.Motors.SetHeadMotor(-5.0f);
36 |
37 | // Tell the lift motor to start lowering the lift (at 5 radians per second)
38 | Console.WriteLine("Lower Vector's lift...");
39 | await robot.Motors.SetLiftMotor(-5.0f);
40 |
41 | // Tell Vector to drive the left wheel at 25 mmps (millimeters per second),
42 | // and the right wheel at 50 mmps (so Vector will drive Forwards while also
43 | // turning to the left.
44 | Console.WriteLine("Set Vector's wheel motors...");
45 | await robot.Motors.SetWheelMotors(25, 50);
46 |
47 | // Wait 3 seconds
48 | await Task.Delay(3000);
49 |
50 | // Tell the head motor to start raising the head (at 5 radians per second)
51 | Console.WriteLine("Raise Vector's head...");
52 | await robot.Motors.SetHeadMotor(5);
53 |
54 | // Tell the lift motor to start raising the lift (at 5 radians per second)
55 | Console.WriteLine("Raise Vector's lift...");
56 | await robot.Motors.SetLiftMotor(5);
57 |
58 | // Tell Vector to drive the left wheel at 50 mmps (millimeters per second),
59 | // and the right wheel at -50 mmps (so Vector will turn in-place to the right)
60 | Console.WriteLine("Set Vector's wheel motors...");
61 | await robot.Motors.SetWheelMotors(50, -50);
62 |
63 | // Wait for 3 seconds (the head, lift and wheels will move while we wait)
64 | await Task.Delay(3000);
65 |
66 | // Stop the motors, which unlocks the tracks
67 | await robot.Motors.StopAllMotors();
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Tutorial_03_Motors/Tutorial_03_Motors.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tutorial_04_Animation/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Threading.Tasks;
7 | using Anki.Vector;
8 |
9 | namespace Tutorial_04_Animation
10 | {
11 | class Program
12 | {
13 | ///
14 | /// Play animations on Vector.
15 | /// Play an animation using a trigger, and then another animation by name.
16 | ///
17 | static async Task Main()
18 | {
19 | // Create a new connection to the first configured Vector
20 | using var robot = await Robot.NewConnection();
21 |
22 | Console.WriteLine("Requesting control of Vector...");
23 | await robot.Control.RequestControl();
24 |
25 | // If Vector is on the charger, drive him off the charger
26 | if (robot.Status.IsOnCharger)
27 | {
28 | Console.WriteLine("Drive Vector off charger...");
29 | await robot.Behavior.DriveOffCharger();
30 | }
31 |
32 | // Play an animation via a trigger.
33 | // A trigger can pick from several appropriate animations for variety.
34 | Console.WriteLine("Playing Animation Trigger 1:");
35 | await robot.Animation.PlayAnimationTrigger("GreetAfterLongTime");
36 |
37 | // Play the same trigger, but this time ignore the track that plays on the
38 | // body (i.e. don't move the wheels). See the play_animation_trigger documentation
39 | // for other available settings.
40 | Console.WriteLine("Playing Animation Trigger 2: (Ignoring the body track)");
41 | await robot.Animation.PlayAnimationTrigger("GreetAfterLongTime", ignoreBodyTrack: true);
42 |
43 | // Play an animation via its name.
44 | var animation = "anim_pounce_success_02";
45 | Console.WriteLine("Playing animation by name: " + animation);
46 | await robot.Animation.PlayAnimation(animation);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Tutorial_04_Animation/Tutorial_04_Animation.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tutorial_05_DriveOnOffCharger/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Threading.Tasks;
7 | using Anki.Vector;
8 |
9 | namespace Tutorial_05_DriveOnOffCharger
10 | {
11 | class Program
12 | {
13 | ///
14 | /// Tell Vector to drive on and off the charger.
15 | ///
16 | public static async Task Main()
17 | {
18 | // Create a new connection to the first configured Vector
19 | using var robot = await Robot.NewConnection();
20 |
21 | Console.WriteLine("Requesting control of Vector...");
22 | await robot.Control.RequestControl();
23 |
24 | Console.WriteLine("Drive Vector on charger...");
25 | await robot.Behavior.DriveOnCharger();
26 |
27 | Console.WriteLine("Drive Vector off charger...");
28 | await robot.Behavior.DriveOffCharger();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Tutorial_05_DriveOnOffCharger/Tutorial_05_DriveOnOffCharger.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tutorial_06_FaceImage/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Reflection;
7 | using System.Runtime.InteropServices;
8 | using System.Threading;
9 | using System.Threading.Tasks;
10 | using Anki.Vector;
11 | using Anki.Vector.Types;
12 | using SixLabors.ImageSharp;
13 | using SixLabors.ImageSharp.Advanced;
14 | using SixLabors.ImageSharp.PixelFormats;
15 |
16 | namespace Tutorial_06_FaceImage
17 | {
18 | class Program
19 | {
20 | ///
21 | /// Display an image on Vector's face.
22 | ///
23 | public static async Task Main()
24 | {
25 | // Get image
26 | using var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Tutorial_06_FaceImage.cozmo_image.jpg");
27 | using var image = SixLabors.ImageSharp.Image.Load(resourceStream);
28 |
29 | // Create a new connection to the first configured Vector
30 | using var robot = await Robot.NewConnection();
31 |
32 | var data = ConvertImageToByteArray(image);
33 |
34 | Console.WriteLine("Requesting control of Vector...");
35 | await robot.Control.RequestControl();
36 |
37 | Console.WriteLine("Setting head angle and lift height...");
38 | await robot.Behavior.SetHeadAngle(45.Degrees());
39 | await robot.Behavior.SetLiftHeight(0);
40 |
41 | Console.WriteLine("Displaying image for 5 seconds...");
42 | await robot.Screen.DisplayImageRgb24(data, 5000);
43 | await Task.Delay(5000);
44 | }
45 |
46 | ///
47 | /// Converts the image data to a byte array
48 | ///
49 | /// The image.
50 | ///
51 | /// Cannot extract pixel data from image.
52 | private static byte[] ConvertImageToByteArray(Image image)
53 | {
54 | if (image.TryGetSinglePixelSpan(out var pixelSpan))
55 | {
56 | return MemoryMarshal.AsBytes(pixelSpan).ToArray();
57 | }
58 | throw new NotSupportedException("Cannot extract pixel data from image.");
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Tutorial_06_FaceImage/Tutorial_06_FaceImage.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Tutorial_06_FaceImage/cozmo_image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codaris/Anki.Vector.Samples/7e66328398cfa2b3101b6ec23b0764a9db46d650/Tutorial_06_FaceImage/cozmo_image.jpg
--------------------------------------------------------------------------------
/Tutorial_07_DockWithCube/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Threading.Tasks;
7 | using Anki.Vector;
8 | using Anki.Vector.Types;
9 |
10 | namespace Tutorial_07_DockWithCube
11 | {
12 | class Program
13 | {
14 | ///
15 | /// Tell Vector to drive up to a seen cube.
16 | /// This example demonstrates Vector driving to and docking with a cube, without picking it up.
17 | /// Vector will line his arm hooks up with the cube so that they are inserted into the cube's corners.
18 | /// You must place a cube in front of Vector so that he can see it.
19 | ///
20 | public static async Task Main()
21 | {
22 | // Create a new connection to the first configured Vector
23 | using var robot = await Robot.NewConnection();
24 |
25 | Console.WriteLine("Requesting control of Vector...");
26 | await robot.Control.RequestControl();
27 |
28 | // If Vector is on the charger, drive him off the charger
29 | if (robot.Status.IsOnCharger)
30 | {
31 | Console.WriteLine("Drive Vector off charger...");
32 | await robot.Behavior.DriveOffCharger();
33 | }
34 |
35 | Console.WriteLine("Setting head angle and lift height...");
36 | await robot.Behavior.SetHeadAngle(-5.Degrees());
37 | await robot.Behavior.SetLiftHeight(0);
38 |
39 | Console.WriteLine("Connecting to a cube...");
40 | await robot.World.ConnectCube();
41 |
42 | ActionResult dockingResult = null;
43 |
44 | if (robot.World.LightCube != null)
45 | {
46 | Console.WriteLine("Begin cube docking...");
47 | dockingResult = await robot.Behavior.DockWithCube(robot.World.LightCube, numRetries: 3);
48 | Console.WriteLine("Disconnect the cube...");
49 | await robot.World.DisconnectCube();
50 |
51 | if (!dockingResult.IsSuccess)
52 | {
53 | Console.WriteLine($"Cube docking failed with code '{dockingResult.Result}'");
54 | }
55 | }
56 | else
57 | {
58 | Console.WriteLine("Could not connect to light cube");
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Tutorial_07_DockWithCube/Tutorial_07_DockWithCube.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tutorial_08_DownloadPhoto/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Threading.Tasks;
9 | using Anki.Vector;
10 |
11 | namespace Tutorial_08_DownloadPhoto
12 | {
13 | class Program
14 | {
15 | ///
16 | /// Downloads all the photos stored in Vector
17 | /// Before running this script, please make sure you have successfully had Vector take a photo by saying, "Hey Vector! Take a photo."
18 | ///
19 | static async Task Main()
20 | {
21 | // Create a new connection to the first configured Vector
22 | using var robot = await Robot.NewConnection();
23 |
24 | var photos = (await robot.Photos.GetPhotoInfo()).ToList();
25 | if (photos.Count == 0)
26 | {
27 | Console.WriteLine("No photos found on Vector. Ask him to take a photo first by saying, 'Hey Vector! Take a photo.'");
28 | return;
29 | }
30 | foreach (var photo in photos)
31 | {
32 | string fileName = $"photo{photo.PhotoId}.jpg";
33 | Console.WriteLine($"Writing photo {fileName}");
34 | var data = await robot.Photos.GetPhoto(photo);
35 | File.WriteAllBytes(fileName, data);
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Tutorial_08_DownloadPhoto/Tutorial_08_DownloadPhoto.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tutorial_09_EyeColor/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Threading.Tasks;
7 | using Anki.Vector;
8 |
9 | namespace Tutorial_09_EyeColor
10 | {
11 | class Program
12 | {
13 | ///
14 | /// Set Vector's eye color.
15 | /// Note that Vector's eye color will return to normal when the connection terminates.
16 | ///
17 | static async Task Main()
18 | {
19 | // Create a new connection to the first configured Vector
20 | using var robot = await Robot.NewConnection();
21 |
22 | Console.WriteLine("Set Vector's eye color to purple...");
23 | await robot.Behavior.SetEyeColor(0.83f, 0.76f);
24 |
25 | Console.WriteLine("Press any key to exit...");
26 | await Task.Run(() => Console.ReadKey(true));
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Tutorial_09_EyeColor/Tutorial_09_EyeColor.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tutorial_10_PlayAudio/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Reflection;
7 | using System.Threading.Tasks;
8 | using Anki.Vector;
9 | using NAudio.Wave;
10 |
11 | namespace Tutorial_10_PlayAudio
12 | {
13 | class Program
14 | {
15 | ///
16 | /// Play audio files through Vector's speaker.
17 | ///
18 | public static async Task Main()
19 | {
20 | // Vector's supported sound format
21 | var outFormat = new WaveFormat(16000, 16, 1);
22 |
23 | // Music: https://www.bensound.com
24 | using var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Tutorial_10_PlayAudio.bensound-summer.mp3");
25 | using var source = new Mp3FileReader(resourceStream);
26 | using var reader = new WaveFormatConversionStream(outFormat, source);
27 |
28 | // Create a new connection to the first configured Vector
29 | using var robot = await Robot.NewConnection();
30 |
31 | // Calculate the framerate
32 | uint frameRate = (uint)(reader.Length / reader.TotalTime.TotalSeconds / 2);
33 |
34 | // Run the audiostream in the background.
35 | var playback = robot.Audio.PlayStream(reader, frameRate, 50);
36 |
37 | Console.WriteLine("Press a key to stop playback");
38 | await Task.Run(() => Console.ReadKey(true));
39 |
40 | await robot.Audio.CancelPlayback();
41 |
42 | var result = await playback;
43 |
44 | Console.WriteLine($"Playback result: {result}");
45 |
46 | Console.WriteLine("Press a key to end.");
47 | await Task.Run(() => Console.ReadKey(true));
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Tutorial_10_PlayAudio/Tutorial_10_PlayAudio.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Tutorial_10_PlayAudio/bensound-summer.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codaris/Anki.Vector.Samples/7e66328398cfa2b3101b6ec23b0764a9db46d650/Tutorial_10_PlayAudio/bensound-summer.mp3
--------------------------------------------------------------------------------
/Tutorial_10_PlayAudio/vector_alert.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codaris/Anki.Vector.Samples/7e66328398cfa2b3101b6ec23b0764a9db46d650/Tutorial_10_PlayAudio/vector_alert.wav
--------------------------------------------------------------------------------
/Tutorial_10_PlayAudio/vector_bell_whistle.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codaris/Anki.Vector.Samples/7e66328398cfa2b3101b6ec23b0764a9db46d650/Tutorial_10_PlayAudio/vector_bell_whistle.wav
--------------------------------------------------------------------------------
/Tutorial_11_DriveToCliffAndBackUp/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Threading.Tasks;
7 | using Anki.Vector;
8 |
9 | namespace Tutorial_11_DriveToCliffAndBackUp
10 | {
11 | class Program
12 | {
13 | ///
14 | /// Make Vector drive to a cliff and back up.
15 | /// Place the robot about a foot from a "cliff" (such as a tabletop edge), then run this script.
16 | ///
17 | public static async Task Main()
18 | {
19 | // Create a new connection to the first configured Vector
20 | using var robot = await Robot.NewConnection();
21 |
22 | Console.WriteLine("Requesting control of Vector...");
23 | await robot.Control.RequestControl();
24 |
25 | // If Vector is on the charger, drive him off the charger
26 | if (robot.Status.IsOnCharger)
27 | {
28 | Console.WriteLine("Drive Vector off charger...");
29 | await robot.Behavior.DriveOffCharger();
30 | }
31 |
32 | Console.WriteLine("Drive Vector straight until he reaches cliff...");
33 | await robot.Behavior.DriveStraight(5000, 100);
34 |
35 | // Wait for control to be lost
36 | Console.WriteLine("Wait for control to be lost...");
37 | await robot.Control.WaitForControlChange();
38 | Console.WriteLine("Requesting control of Vector...");
39 | await robot.Control.RequestControl();
40 | Console.WriteLine("Drive Vector backward away from the cliff...");
41 | await robot.Behavior.DriveStraight(-300, 100);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Tutorial_11_DriveToCliffAndBackUp/Tutorial_11_DriveToCliffAndBackUp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tutorial_12_ControlPriorityLevel/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Threading.Tasks;
7 | using Anki.Vector;
8 |
9 | namespace Tutorial_12_ControlPriorityLevel
10 | {
11 | class Program
12 | {
13 | ///
14 | /// Vector maintains SDK behavior control after being picked up
15 | /// During normal operation, SDK programs cannot maintain control over Vector when he is at a cliff, stuck on an edge or obstacle, tilted or inclined, picked up, in darkness, etc.
16 | /// This script demonstrates how to use the highest level SDK behavior control to make Vector perform actions that
17 | /// normally take priority over the SDK. These commands will not succeed at .
18 | ///
19 | static async Task Main()
20 | {
21 | // Create a new connection to the first configured Vector
22 | using var robot = await Robot.NewConnection();
23 |
24 | Console.WriteLine("Requesting override control of Vector...");
25 | await robot.Control.RequestControl(ControlPriority.OverrideBehaviors);
26 |
27 | // Say pick me up and wait for a key press to exit
28 | await robot.Behavior.SayText("Pick me up!");
29 | Console.WriteLine("Waiting for Vector to be picked up, press any key to exit...");
30 |
31 | // Wait for vector to be picked up or key press
32 | while (!robot.Status.IsPickedUp && !Console.KeyAvailable)
33 | {
34 | // Wait 0.5 seconds
35 | await Task.Delay(500);
36 | }
37 |
38 | // Exit if key pressed
39 | if (Console.KeyAvailable) return;
40 |
41 | // If Vector is picked up move him around
42 | Console.WriteLine("Vector is picked up...");
43 | await robot.Behavior.SayText("Hold on tight");
44 | Console.WriteLine("Setting wheel motors...");
45 | await robot.Motors.SetWheelMotors(75, -75);
46 | await Task.Delay(500);
47 | await robot.Motors.SetWheelMotors(-75, 75);
48 | await Task.Delay(500);
49 | await robot.Motors.StopAllMotors();
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Tutorial_12_ControlPriorityLevel/Tutorial_12_ControlPriorityLevel.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tutorial_13_UserIntent/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Threading.Tasks;
7 | using Anki.Vector;
8 |
9 | namespace Tutorial_13_UserIntent
10 | {
11 | class Program
12 | {
13 | ///
14 | /// Return information about a voice commands given to Vector
15 | /// The user_intent event is only dispatched when the SDK program has requested behavior control and Vector gets a voice command.
16 | /// After the robot hears "Hey Vector! ..." and a valid voice command is given for example "...what time is it?") the event will be dispatched and displayed.
17 | ///
18 | static async Task Main()
19 | {
20 | using var robot = await Robot.NewConnection();
21 | Console.WriteLine("Requesting control of Vector...");
22 | await robot.Control.RequestControl();
23 |
24 | robot.Events.UserIntent += (sender, e) =>
25 | {
26 | Console.WriteLine($"Received {e.Intent}");
27 | Console.WriteLine(e.IntentData);
28 | };
29 |
30 | Console.WriteLine("Vector is waiting for a voice command like 'Hey Vector! What time is it?' Press any key to exit...");
31 | await Task.Run(() => Console.ReadKey(true));
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Tutorial_13_UserIntent/Tutorial_13_UserIntent.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tutorial_14_FaceEvent/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Threading.Tasks;
7 | using Anki.Vector;
8 | using Anki.Vector.Types;
9 |
10 | namespace Tutorial_14_FaceEvent
11 | {
12 | class Program
13 | {
14 | ///
15 | /// Wait for Vector to see a face, and then print output to the console.
16 | /// This script demonstrates how to set up a listener for an event. It subscribes to event ObservedFace. When that event is dispatched,
17 | /// the lambda is called, which prints text to the console. Vector will also say "I see a face" one time, and the program will exit when
18 | /// he finishes speaking.
19 | ///
20 | static async Task Main()
21 | {
22 | // Create a new connection to the first configured Vector
23 | using var robot = await Robot.NewConnection();
24 |
25 | Console.WriteLine("Requesting control of Vector...");
26 | await robot.Control.RequestControl();
27 |
28 | Console.WriteLine("Enabling face detection...");
29 | await robot.Vision.EnableFaceDetection();
30 |
31 | Console.WriteLine("Move Vector's Head and Lift to make it easy to see a face.");
32 | await robot.Behavior.SetHeadAngle(45.Degrees());
33 | await robot.Behavior.SetLiftHeight(0);
34 |
35 | bool sawFace = false;
36 | bool exit = false;
37 |
38 | robot.Events.ObservedFace += async (sender, e) =>
39 | {
40 | if (sawFace) return;
41 | sawFace = true;
42 | Console.WriteLine("Vector sees a face");
43 | await robot.Behavior.SayText("I see a face");
44 | exit = true;
45 | };
46 |
47 | Console.WriteLine("Press a key to exit before Vector sees a face...");
48 | while (!exit && !Console.KeyAvailable)
49 | {
50 | await Task.Delay(500);
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Tutorial_14_FaceEvent/Tutorial_14_FaceEvent.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tutorial_15_FaceFollower/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Threading.Tasks;
7 | using Anki.Vector;
8 | using Anki.Vector.Objects;
9 | using Anki.Vector.Types;
10 |
11 | namespace Tutorial_15_FaceFollower
12 | {
13 | class Program
14 | {
15 | ///
16 | /// Make Vector turn toward a face.
17 | /// This script shows off the turn_towards_face behavior. It will wait for a face and then constantly turn towards it to keep it in frame.
18 | ///
19 | static async Task Main()
20 | {
21 | // Create a new connection to the first configured Vector
22 | using var robot = await Robot.NewConnection();
23 |
24 | Console.WriteLine("Requesting control of Vector...");
25 | await robot.Control.RequestControl();
26 |
27 | Console.WriteLine("Enabling face detection...");
28 | await robot.Vision.EnableFaceDetection();
29 |
30 | // If Vector is on the charger, drive him off the charger
31 | if (robot.Status.IsOnCharger)
32 | {
33 | Console.WriteLine("Drive Vector off charger...");
34 | await robot.Behavior.DriveOffCharger();
35 | }
36 |
37 | Console.WriteLine("Move Vector's Head and Lift to make it easy to see a face.");
38 | await robot.Behavior.SetHeadAngle(45.Degrees());
39 | await robot.Behavior.SetLiftHeight(0);
40 |
41 | // The face to follow
42 | Face faceToFollow = null;
43 |
44 | // Observe objects and save the first face found
45 | robot.World.ObjectObserved += (sender, e) =>
46 | {
47 | if (e.Object is Face && faceToFollow == null)
48 | {
49 | Console.WriteLine("Found a face to track.");
50 | faceToFollow = (Face)e.Object;
51 | }
52 | };
53 |
54 | Console.WriteLine("Press any key to exit...");
55 | while (!Console.KeyAvailable)
56 | {
57 | if (faceToFollow != null) await robot.Behavior.TurnTowardsFace(faceToFollow);
58 | await Task.Delay(100);
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Tutorial_15_FaceFollower/Tutorial_15_FaceFollower.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tutorial_16_FeatureStatus/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Threading.Tasks;
8 | using Anki.Vector;
9 |
10 | namespace Tutorial_16_FeatureStatus
11 | {
12 | class Program
13 | {
14 | ///
15 | /// Return information about the features that Vector's AI is using
16 | ///
17 | static async Task Main()
18 | {
19 | using var robot = await Robot.NewConnection();
20 |
21 | robot.Events.FeatureStatus += (sender, e) =>
22 | {
23 | Console.WriteLine($"FeatureStatus: intent {e.FeatureName}");
24 | Console.WriteLine(e.Source);
25 | };
26 |
27 | Console.WriteLine("Vector is waiting for a voice command like 'Hey Vector! What time is it?' Press any key to exit...");
28 | await Task.Run(() => Console.ReadKey(true));
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Tutorial_16_FeatureStatus/Tutorial_16_FeatureStatus.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tutorial_17_AppIntent/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Threading.Tasks;
8 | using Anki.Vector;
9 |
10 | namespace Tutorial_17_AppIntent
11 | {
12 | class Program
13 | {
14 | ///
15 | /// Inject an intent into Vector's AI
16 | ///
17 | static async Task Main()
18 | {
19 | using var robot = await Robot.NewConnection();
20 |
21 | Console.WriteLine($"Asked Vector to go to sleep...");
22 | await robot.Behavior.Sleep();
23 |
24 | Console.WriteLine("Press any key to exit...");
25 | await Task.Run(() => Console.ReadKey(true));
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Tutorial_17_AppIntent/Tutorial_17_AppIntent.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Tutorial_18_XboxDrive/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using Anki.Vector;
5 | using Anki.Vector.Types;
6 |
7 | namespace Tutorial_18_XboxDrive
8 | {
9 | class Program
10 | {
11 | ///
12 | /// This is held here so that it doesn't get garbage collected
13 | ///
14 | static Task taskXboxController;
15 |
16 | ///
17 | /// Make Vector drive around based on an Xbox controller
18 | ///
19 | ///
20 | public static async Task Main()
21 | {
22 | // Create a new connection to the first configured Vector
23 | using var robot = await Robot.NewConnection();
24 |
25 | Console.WriteLine("Requesting control of Vector...");
26 | await robot.Control.RequestControl();
27 |
28 | // If Vector is on the charger, drive him off the charger
29 | if (robot.Status.IsOnCharger)
30 | {
31 | Console.WriteLine("Drive Vector off charger...");
32 | await robot.Behavior.DriveOffCharger();
33 | }
34 |
35 | // Create a task that will receive input from the game controller
36 | taskXboxController = new Task(() =>
37 | {
38 | // Enable the game controller
39 | XBoxController.XInputEnable(true);
40 |
41 | // a structure to hold the state of the game controller
42 | XBoxController.XInputState state = new XBoxController.XInputState();
43 |
44 | int prevPacketNumber = 0;
45 | for (; ; )
46 | {
47 | // try to get input; if no game controller, it will error out
48 | var err = XBoxController.XInputGetState(0, ref state);
49 | if (0 != err)
50 | {
51 | Thread.Sleep(500);
52 | continue;
53 | }
54 |
55 | // skip if the packet number has not changed
56 | // (this is unlikely to be needed code)
57 | if (prevPacketNumber == state.PacketNumber)
58 | {
59 | Thread.Sleep(100);
60 | continue;
61 | }
62 |
63 | // Save the packet number
64 | prevPacketNumber = state.PacketNumber;
65 |
66 | // Get the left-right percentage and use that for an angle
67 | var turnAngle = state.Gamepad.sThumbRX *-90.0/ 32768.0;
68 | var turnAngle2 = turnAngle * turnAngle;
69 | if (turnAngle2 > 10.0)
70 | {
71 | // Send a command to turn by that amount
72 | robot.Behavior.TurnInPlace(((float)turnAngle).Degrees());
73 | }
74 |
75 | // Get the forward/back amount
76 | var fwd = state.Gamepad.sThumbRY * 200.0 / 32768.0;
77 | var fwd2 = fwd * fwd;
78 | if (fwd2 > 10.0)
79 | {
80 | robot.Behavior.DriveStraight((float) fwd, 50);
81 | }
82 | }
83 | });
84 | // Start communicating
85 | taskXboxController.Start();
86 |
87 | Console.WriteLine("Press any key to exit...");
88 | await Task.Run(() => Console.ReadKey(true));
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/Tutorial_18_XboxDrive/Tutorial_18_XboxDrive.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tutorial_18_XboxDrive/XBoxController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | public partial class XBoxController
5 | {
6 | // Uncomment to support whichever version of the dll you have
7 | // [DllImport("xinput1_3.dll")]
8 | [DllImport("xinput1_4.dll")]
9 | public static extern void XInputEnable([MarshalAs(UnmanagedType.U1)] bool enable);
10 |
11 | [StructLayout(LayoutKind.Explicit)]
12 | public struct XInputGamepad
13 | {
14 | [MarshalAs(UnmanagedType.I2)]
15 | [FieldOffset(0)]
16 | public short wButtons;
17 |
18 | [MarshalAs(UnmanagedType.I1)]
19 | [FieldOffset(2)]
20 | public byte bLeftTrigger;
21 |
22 | [MarshalAs(UnmanagedType.I1)]
23 | [FieldOffset(3)]
24 | public byte bRightTrigger;
25 |
26 | [MarshalAs(UnmanagedType.I2)]
27 | [FieldOffset(4)]
28 | public short sThumbLX;
29 |
30 | [MarshalAs(UnmanagedType.I2)]
31 | [FieldOffset(6)]
32 | public short sThumbLY;
33 |
34 | [MarshalAs(UnmanagedType.I2)]
35 | [FieldOffset(8)]
36 | public short sThumbRX;
37 |
38 | [MarshalAs(UnmanagedType.I2)]
39 | [FieldOffset(10)]
40 | public short sThumbRY;
41 | };
42 |
43 | [StructLayout(LayoutKind.Explicit)]
44 | public struct XInputState
45 | {
46 | [FieldOffset(0)]
47 | public int PacketNumber;
48 |
49 | [FieldOffset(4)]
50 | public XInputGamepad Gamepad;
51 | }
52 |
53 | // Uncomment to support whichever version of the dll you have
54 | // [DllImport("xinput1_3.dll")]
55 | [DllImport("xinput1_4.dll")]
56 | public static extern int XInputGetState
57 | (
58 | int dwUserIndex, // [in] Index of the gamer associated with the device
59 | ref XInputState state // [out] Receives the current state
60 | );
61 |
62 | [StructLayout(LayoutKind.Sequential)]
63 | public struct XInputVibration
64 | {
65 | [MarshalAs(UnmanagedType.I2)]
66 | public ushort LeftMotorSpeed;
67 |
68 | [MarshalAs(UnmanagedType.I2)]
69 | public ushort RightMotorSpeed;
70 | }
71 |
72 | // Uncomment to support whichever version of the dll you have
73 | // [DllImport("xinput1_3.dll")]
74 | [DllImport("xinput1_4.dll")]
75 | public static extern int XInputSetState
76 | (
77 | int dwUserIndex, // [in] Index of the gamer associated with the device
78 | ref XInputVibration pVibration // [in, out] The vibration information to send to the controller
79 | );
80 | }
81 |
--------------------------------------------------------------------------------
/VectorConfigure/AddCommand.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Net;
7 | using System.Threading.Tasks;
8 | using Anki.Vector;
9 | using Anki.Vector.Exceptions;
10 | using CommandLine;
11 |
12 | namespace VectorConfigure
13 | {
14 | ///
15 | /// Command to add new robot configuration to the SDK
16 | ///
17 | [Verb("add", HelpText = "Add a new robot configuration to the SDK.")]
18 | public class AddCommand
19 | {
20 | ///
21 | /// The robot configuration to build
22 | ///
23 | private readonly RobotConfiguration robot = new RobotConfiguration();
24 |
25 | ///
26 | /// Gets or sets the name of the robot.
27 | ///
28 | [Option('n', "name", HelpText = "The robot name (ex. Vector-A1B2).")]
29 | public string RobotName { get; set; }
30 |
31 | ///
32 | /// Gets or sets the serial number.
33 | ///
34 | [Option('s', "serial", HelpText = "The robot serial number (ex. 00e20100).")]
35 | public string SerialNumber { get; set; }
36 |
37 | ///
38 | /// Gets or sets the email.
39 | ///
40 | [Option('e', "email", HelpText = "The email used by your Anki account.")]
41 | public string Email { get; set; }
42 |
43 | ///
44 | /// Gets or sets the ip address string.
45 | ///
46 | [Option('i', "ip", HelpText = "The robot IP address (ex. 192.168.42.42).")]
47 | public string IPString { get; set; }
48 |
49 | ///
50 | /// Runs this instance.
51 | ///
52 | /// Return code for the command
53 | public int Run()
54 | {
55 | Program.DisplayHeader();
56 | Program.WriteLineWordWrap("Vector requires all requests be authorized by an authenticated Anki user. This application will enable this device to authenticate with your Vector robot for use with a Vector SDK program.");
57 | Console.WriteLine();
58 | if (!AddSerialNumberAndCertificate()) return -1;
59 | if (!AddRobotName()) return -1;
60 | if (!AddIPAddress()) return -1;
61 | if (!AddGuid()) return -1;
62 |
63 | RobotConfiguration.AddOrUpdate(robot);
64 | Console.WriteLine("Success.");
65 | return 0;
66 | }
67 |
68 | ///
69 | /// Adds the serial number and certificate.
70 | ///
71 | /// True if successful
72 | private bool AddSerialNumberAndCertificate()
73 | {
74 | string serialNumber = SerialNumber;
75 | bool useInput = string.IsNullOrEmpty(SerialNumber);
76 |
77 | if (useInput)
78 | {
79 | Program.WriteLineWordWrap("Please find your robot serial number (ex. 00e20100) located on the underside of Vector, or accessible from Vector's debug screen.");
80 | Console.WriteLine();
81 | }
82 |
83 | while (true)
84 | {
85 | // If using input, request from user
86 | if (useInput)
87 | {
88 | Console.Write("Enter robot serial number: ");
89 | serialNumber = Console.ReadLine();
90 | if (serialNumber == null) return false;
91 | }
92 | // Verify serial number is in correct format
93 | if (!Authentication.SerialNumberIsValid(serialNumber))
94 | {
95 | Console.WriteLine("Serial number is not in the correct format (ex. 00e20100).");
96 | Console.WriteLine();
97 | if (useInput) continue;
98 | return false;
99 | }
100 | // Update the robot serial number
101 | robot.SerialNumber = serialNumber;
102 | // Attempt to get certificate.
103 | try
104 | {
105 | Console.WriteLine("Retreiving Vector's security certificate from Anki's servers...");
106 | robot.Certificate = GetResult(Authentication.GetCertificate(robot.SerialNumber));
107 | }
108 | catch (VectorAuthenticationException ex)
109 | {
110 | Console.WriteLine("Error: " + ex.Message);
111 | Console.WriteLine();
112 | if (useInput) continue;
113 | return false;
114 | }
115 | return true;
116 | }
117 | }
118 |
119 | ///
120 | /// Adds the name of the robot.
121 | ///
122 | /// True if successful
123 | private bool AddRobotName()
124 | {
125 | string robotName = RobotName;
126 | bool useInput = string.IsNullOrEmpty(robotName);
127 | if (useInput)
128 | {
129 | Program.WriteLineWordWrap("Find your robot name (ex. Vector-A1B2) by placing Vector on the charger and double-clicking Vector's backpack button.");
130 | Console.WriteLine();
131 | }
132 |
133 | while (true)
134 | {
135 | // If using input, request from user
136 | if (useInput)
137 | {
138 | Console.Write("Enter robot name: ");
139 | robotName = Console.ReadLine();
140 | if (robotName == null) return false;
141 | }
142 | robotName = Authentication.StandardizeRobotName(robotName);
143 | // Verify serial number is in correct format
144 | if (!Authentication.RobotNameIsValid(robotName))
145 | {
146 | Console.WriteLine("Robot name is not in the correct format. (ex. Vector-A1B2).");
147 | Console.WriteLine();
148 | if (useInput) continue;
149 | return false;
150 | }
151 | // Update the robot name
152 | robot.RobotName = robotName;
153 | return true;
154 | }
155 | }
156 |
157 | ///
158 | /// Adds the ip address.
159 | ///
160 | /// True if successful
161 | private bool AddIPAddress()
162 | {
163 | string ipString = IPString;
164 | bool useInput = string.IsNullOrEmpty(ipString);
165 | IPAddress ipAddress;
166 | if (useInput)
167 | {
168 | Console.WriteLine("Attempting to determine your Vector's IP address automatically...");
169 | ipAddress = GetResult(Authentication.FindRobotAddress(robot.RobotName));
170 | if (ipAddress != null)
171 | {
172 | Console.WriteLine($"Found Vector at {ipAddress}");
173 | Console.WriteLine();
174 | robot.IPAddress = ipAddress;
175 | return true;
176 | }
177 | Program.WriteLineWordWrap("Find your robot ip address (ex. 192.168.42.12) by placing Vector on the charger, double-clicking Vector's backpack button, then raising and lowering his arms. If you see XX.XX.XX.XX on his face, reconnect Vector to your WiFi using the Vector Companion App.");
178 | Console.WriteLine();
179 | }
180 |
181 | while (true)
182 | {
183 | // If using input, request from user
184 | if (useInput)
185 | {
186 | Console.Write("Enter robot ip: ");
187 | ipString = Console.ReadLine();
188 | if (ipString == null) return false;
189 | }
190 | if (!IPAddress.TryParse(ipString, out ipAddress))
191 | {
192 | Program.WriteLineWordWrap("IP Address is not in the correct format. It must be 4 numbers separated by dots (ex. 192.168.42.12).");
193 | Console.WriteLine();
194 | if (useInput) continue;
195 | return false;
196 | }
197 |
198 | robot.IPAddress = ipAddress;
199 | return true;
200 | }
201 | }
202 |
203 | ///
204 | /// Adds the unique identifier.
205 | ///
206 | /// True if successful
207 | private bool AddGuid()
208 | {
209 | string email = Email;
210 | bool useInput = string.IsNullOrEmpty(email);
211 | if (useInput)
212 | {
213 | Program.WriteLineWordWrap("Enter your email and password. Make sure to use the same account that was used to set up your Vector on the companion app.");
214 | Console.WriteLine();
215 | }
216 |
217 | while (true)
218 | {
219 | // If using input, request from user
220 | if (useInput)
221 | {
222 | Console.Write("Enter email: ");
223 | email = Console.ReadLine();
224 | if (email == null) return false;
225 | }
226 | Console.Write("Enter password: ");
227 | string password = Program.ReadPassword();
228 | if (string.IsNullOrWhiteSpace(password)) continue;
229 | Console.WriteLine();
230 | Console.WriteLine("Authenticating with Anki's servers...");
231 | try
232 | {
233 | var sessionId = GetResult(Authentication.GetSessionToken(email, password));
234 | robot.Guid = GetResult(Authentication.GetTokenGuid(sessionId, robot.Certificate, robot.RobotName, robot.IPAddress));
235 | }
236 | catch (VectorAuthenticationException ex)
237 | {
238 | Console.WriteLine("Error: " + ex.Message);
239 | Console.WriteLine();
240 | useInput = true;
241 | continue;
242 | }
243 | return true;
244 | }
245 | }
246 |
247 | ///
248 | /// Gets the result of a task and unpacks aggregate exceptions
249 | ///
250 | /// The result type.
251 | /// The task.
252 | /// A task that represents the asynchronous operation; the task result contains the result of the command.
253 | private static T GetResult(Task task)
254 | {
255 | try
256 | {
257 | return task.Result;
258 | }
259 | catch (AggregateException ex)
260 | {
261 | if (ex.InnerException is VectorAuthenticationException) throw ex.InnerException;
262 | throw;
263 | }
264 | }
265 | }
266 | }
267 |
--------------------------------------------------------------------------------
/VectorConfigure/DeleteCommand.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Linq;
7 | using Anki.Vector;
8 | using CommandLine;
9 |
10 | namespace VectorConfigure
11 | {
12 | ///
13 | /// Command to delete a robot configuration.
14 | ///
15 | [Verb("delete", HelpText = "Delete a robot configuration.")]
16 | public class DeleteCommand
17 | {
18 | ///
19 | /// Gets or sets the robot name or serial number.
20 | ///
21 | [Value(0, HelpText = "Robot name or serial number to delete", Required = true, MetaName = "Name or Serial")]
22 | public string NameOrSerial { get; set; }
23 |
24 | ///
25 | /// Runs this command.
26 | ///
27 | /// Return code for the command
28 | public int Run()
29 | {
30 | Program.DisplayHeader();
31 | var robots = RobotConfiguration.Load().ToList();
32 | if (robots.Count == 0)
33 | {
34 | Console.WriteLine("There are no Vector robots configured.");
35 | return -1;
36 | }
37 |
38 | string robotName = Authentication.StandardizeRobotName(NameOrSerial);
39 | string serial = NameOrSerial.ToLower();
40 |
41 | var robot = robots.FirstOrDefault(r => r.RobotName == robotName || r.SerialNumber.ToLower() == serial);
42 | if (robot == null)
43 | {
44 | Console.WriteLine($"Robot '{NameOrSerial}' was not found.");
45 | return -1;
46 | }
47 | robots.RemoveAt(robots.IndexOf(robot));
48 | RobotConfiguration.Save(robots);
49 | Console.WriteLine($"Removed {robot.RobotName} ({robot.SerialNumber}).");
50 | return 0;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/VectorConfigure/ListCommand.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using Anki.Vector;
9 | using CommandLine;
10 |
11 | namespace VectorConfigure
12 | {
13 | ///
14 | /// Command to list all the configured robots.
15 | ///
16 | [Verb("list", HelpText = "List all the configured robots.")]
17 | public class ListCommand
18 | {
19 | ///
20 | /// Gets or sets a value indicating whether the results of this are verbose.
21 | ///
22 | [Option(HelpText = "Display verbose information about configured robots.")]
23 | public bool Verbose { get; set; }
24 |
25 | ///
26 | /// Runs this command.
27 | ///
28 | /// Return code for the command
29 | public int Run()
30 | {
31 | Program.DisplayHeader();
32 | var robots = RobotConfiguration.Load().ToList();
33 | if (robots.Count == 0)
34 | {
35 | Console.WriteLine("There are no Vector robots configured.");
36 | return 0;
37 | }
38 |
39 | Console.WriteLine("Configured Vector Robots:");
40 | if (Verbose) DisplayRobotsVerbose(robots);
41 | else DisplayRobotsNormal(robots);
42 | return 0;
43 | }
44 |
45 | ///
46 | /// Displays the robot normally.
47 | ///
48 | /// The robots.
49 | private void DisplayRobotsNormal(IEnumerable robots)
50 | {
51 | foreach (var robot in robots)
52 | {
53 | Console.WriteLine($" {robot.RobotName} ({robot.SerialNumber})");
54 | }
55 | }
56 |
57 | ///
58 | /// Displays the robots verbose.
59 | ///
60 | /// The robots.
61 | private void DisplayRobotsVerbose(IEnumerable robots)
62 | {
63 | foreach (var robot in robots)
64 | {
65 | Console.WriteLine();
66 | Console.WriteLine($" Robot Name: {robot.RobotName}");
67 | Console.WriteLine($"Serial Number: {robot.SerialNumber}");
68 | Console.WriteLine($" IP Address: {robot.IPAddress}");
69 | Console.WriteLine($" GUID: {robot.Guid}");
70 | Console.WriteLine($"{robot.Certificate}");
71 | }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/VectorConfigure/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Wayne Venables. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using CommandLine;
8 |
9 | namespace VectorConfigure
10 | {
11 | public static class Program
12 | {
13 | ///
14 | /// Mains the specified arguments.
15 | ///
16 | /// The arguments.
17 | /// Return code from the command
18 | public static int Main(string[] args)
19 | {
20 | Console.CancelKeyPress += (sender, e) =>
21 | {
22 | Environment.Exit(-1);
23 | };
24 |
25 | var result = Parser.Default.ParseArguments(args);
26 | return result.MapResult(
27 | (ListCommand list) => ((ListCommand)list).Run(),
28 | (AddCommand add) => ((AddCommand)add).Run(),
29 | (DeleteCommand delete) => ((DeleteCommand)delete).Run(),
30 | errs => 1);
31 | }
32 |
33 | ///
34 | /// Reads the password.
35 | ///
36 | /// The password
37 | public static string ReadPassword()
38 | {
39 | string pass = string.Empty;
40 | do
41 | {
42 | ConsoleKeyInfo key = Console.ReadKey(true);
43 | // Backspace Should Not Work
44 | if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
45 | {
46 | pass += key.KeyChar;
47 | Console.Write("*");
48 | }
49 | else
50 | {
51 | if (key.Key == ConsoleKey.Backspace && pass.Length > 0)
52 | {
53 | pass = pass.Substring(0, pass.Length - 1);
54 | Console.Write("\b \b");
55 | }
56 | else if (key.Key == ConsoleKey.Enter)
57 | {
58 | Console.WriteLine();
59 | break;
60 | }
61 | }
62 | }
63 | while (true);
64 | return pass;
65 | }
66 |
67 | ///
68 | /// Writes the line word wrap.
69 | ///
70 | /// The paragraph.
71 | /// Size of the tab.
72 | public static void WriteLineWordWrap(string paragraph, int tabSize = 8)
73 | {
74 | if (string.IsNullOrEmpty(paragraph)) return;
75 |
76 | string[] lines = paragraph
77 | .Replace("\t", new string(' ', tabSize))
78 | .Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
79 |
80 | for (int i = 0; i < lines.Length; i++)
81 | {
82 | string process = lines[i];
83 | List wrapped = new List();
84 |
85 | while (process.Length > Console.WindowWidth)
86 | {
87 | int wrapAt = process.LastIndexOf(' ', Math.Min(Console.WindowWidth - 1, process.Length));
88 | if (wrapAt <= 0) break;
89 |
90 | wrapped.Add(process.Substring(0, wrapAt));
91 | process = process.Remove(0, wrapAt + 1);
92 | }
93 |
94 | foreach (string wrap in wrapped)
95 | {
96 | Console.WriteLine(wrap);
97 | }
98 |
99 | Console.WriteLine(process);
100 | }
101 | }
102 |
103 | ///
104 | /// Displays the header.
105 | ///
106 | public static void DisplayHeader()
107 | {
108 | Console.WriteLine(CommandLine.Text.HeadingInfo.Default);
109 | Console.WriteLine(CommandLine.Text.CopyrightInfo.Default);
110 | Console.WriteLine();
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/VectorConfigure/Settings.StyleCop:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | anki
5 | anki's
6 | bytepair
7 | deg
8 | ip
9 | nav
10 | navmap
11 | png
12 | rgb
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | False
21 |
22 |
23 |
24 |
25 | False
26 |
27 |
28 |
29 |
30 | False
31 |
32 |
33 |
34 |
35 | False
36 |
37 |
38 |
39 |
40 | False
41 |
42 |
43 |
44 |
45 | False
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | False
56 |
57 |
58 |
59 |
60 | False
61 |
62 |
63 |
64 |
65 | False
66 |
67 |
68 |
69 |
70 | False
71 |
72 |
73 |
74 |
75 | False
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 | False
86 |
87 |
88 |
89 |
90 | False
91 |
92 |
93 |
94 |
95 | False
96 |
97 |
98 |
99 |
100 | False
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 | False
111 |
112 |
113 |
114 |
115 | False
116 |
117 |
118 |
119 |
120 | False
121 |
122 |
123 |
124 |
125 | False
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 | False
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 | False
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 | False
156 |
157 |
158 |
159 |
160 |
161 | up
162 |
163 |
164 |
165 |
166 |
--------------------------------------------------------------------------------
/VectorConfigure/VectorConfigure.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 | Wayne Venables
7 | Codaris Consulting
8 | Anki.Vector.SDK.Configure
9 | Anki Vector SDK Configure
10 | Copyright (c) 2019 Wayne Venables
11 |
12 | win10-x64
13 | true
14 |
15 | false
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------