Webots中Spot或SpotMini案例-焦 虑 腾 空-

2023-10-20 22:30
文章标签 案例 spot webots spotmini

本文主要是介绍Webots中Spot或SpotMini案例-焦 虑 腾 空-,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

"Spot "机器人,此前被称为 "SpotMini",是波士顿动力公司开发的一款四条腿的类似狗的机器人。

详细介绍的短视频在文末,如需简要了解,不必观看视频,个人一直觉得视频的时间成本很高,流量成本很高,制作成本也很高,这三高是相对于图文博客而言。

焦虑的Spot

这款敏捷的机器人身高83厘米,可以完成各种搜索、检查和运送任务。它能以前所未有的速度攀爬楼梯和穿越崎岖的地形,但它的体型却足够小,适合在室内使用。它是一个坚固耐用的(IP54防尘和防潮保护)和可定制的平台。Spot可以去轮式机器人无法去的地方,同时携带的有效载荷的耐力远超空中无人机。最大速度为1.6米/秒,续航时间为90分钟,电池可更换。Spot使用5个立体摄像头(360度视觉),在动态工作场所移动时,可以避开障碍物和人。

附上参考网址(非点击打开的链接,请复制打开)

教程说明:https://cyberbotics.com/doc/guide/spot模型网址:https://github.com/cyberbotics/webots/tree/master/projects/robots/boston_dynamics软件下载:https://cyberbotics.com/#download
腾空的spot

上图可以看到webots软件界面,腾空时前后摄像头的图像也在仿真窗口左上和右上显示。

如上运动效果的代码如下:

/** Copyright 1996-2020 Cyberbotics Ltd.** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**     http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*//** Description:   Simple controller to present the Spot robot.*/#include <webots/camera.h>
#include <webots/device.h>
#include <webots/led.h>
#include <webots/motor.h>
#include <webots/robot.h>#include <math.h>
#include <stdio.h>
#include <stdlib.h>#define NUMBER_OF_LEDS 8
#define NUMBER_OF_JOINTS 12
#define NUMBER_OF_CAMERAS 5// Initialize the robot's information
static WbDeviceTag motors[NUMBER_OF_JOINTS];
static const char *motor_names[NUMBER_OF_JOINTS] = {"front left shoulder abduction motor",  "front left shoulder rotation motor",  "front left elbow motor","front right shoulder abduction motor", "front right shoulder rotation motor", "front right elbow motor","rear left shoulder abduction motor",   "rear left shoulder rotation motor",   "rear left elbow motor","rear right shoulder abduction motor",  "rear right shoulder rotation motor",  "rear right elbow motor"};
static WbDeviceTag cameras[NUMBER_OF_CAMERAS];
static const char *camera_names[NUMBER_OF_CAMERAS] = {"left head camera", "right head camera", "left flank camera","right flank camera", "rear camera"};
static WbDeviceTag leds[NUMBER_OF_LEDS];
static const char *led_names[NUMBER_OF_LEDS] = {"left top led",          "left middle up led", "left middle down led","left bottom led",       "right top led",      "right middle up led","right middle down led", "right bottom led"};static void step() {const double time_step = wb_robot_get_basic_time_step();if (wb_robot_step(time_step) == -1) {wb_robot_cleanup();exit(0);}
}// Movement decomposition
static void movement_decomposition(const double *target, double duration) {const double time_step = wb_robot_get_basic_time_step();const int n_steps_to_achieve_target = duration * 1000 / time_step;double step_difference[NUMBER_OF_JOINTS];double current_position[NUMBER_OF_JOINTS];for (int i = 0; i < NUMBER_OF_JOINTS; ++i) {current_position[i] = wb_motor_get_target_position(motors[i]);step_difference[i] = (target[i] - current_position[i]) / n_steps_to_achieve_target;}for (int i = 0; i < n_steps_to_achieve_target; ++i) {for (int j = 0; j < NUMBER_OF_JOINTS; ++j) {current_position[j] += step_difference[j];wb_motor_set_position(motors[j], current_position[j]);}step();}
}static void lie_down(double duration) {const double motors_target_pos[NUMBER_OF_JOINTS] = {-0.40, -0.99, 1.59,   // Front left leg0.40,  -0.99, 1.59,   // Front right leg-0.40, -0.99, 1.59,   // Rear left leg0.40,  -0.99, 1.59};  // Rear right legmovement_decomposition(motors_target_pos, duration);
}static void stand_up(double duration) {const double motors_target_pos[NUMBER_OF_JOINTS] = {-0.1, 0.0, 0.0,   // Front left leg0.1,  0.0, 0.0,   // Front right leg-0.1, 0.0, 0.0,   // Rear left leg0.1,  0.0, 0.0};  // Rear right legmovement_decomposition(motors_target_pos, duration);
}static void sit_down(double duration) {const double motors_target_pos[NUMBER_OF_JOINTS] = {-0.20, -0.40, -0.19,  // Front left leg0.20,  -0.40, -0.19,  // Front right leg-0.40, -0.90, 1.18,   // Rear left leg0.40,  -0.90, 1.18};  // Rear right legmovement_decomposition(motors_target_pos, duration);
}static void give_paw() {// Stabilize postureconst double motors_target_pos_1[NUMBER_OF_JOINTS] = {-0.20, -0.30, 0.05,   // Front left leg0.20,  -0.40, -0.19,  // Front right leg-0.40, -0.90, 1.18,   // Rear left leg0.49,  -0.90, 0.80};  // Rear right legmovement_decomposition(motors_target_pos_1, 4);const double initial_time = wb_robot_get_time();while (wb_robot_get_time() - initial_time < 8) {wb_motor_set_position(motors[4], 0.2 * sin(2 * wb_robot_get_time()) + 0.6);  // Upperarm movementwb_motor_set_position(motors[5], 0.4 * sin(2 * wb_robot_get_time()));        // Forearm movementstep();}// Get back in sitting postureconst double motors_target_pos_2[NUMBER_OF_JOINTS] = {-0.20, -0.40, -0.19,  // Front left leg0.20,  -0.40, -0.19,  // Front right leg-0.40, -0.90, 1.18,   // Rear left leg0.40,  -0.90, 1.18};  // Rear right legmovement_decomposition(motors_target_pos_2, 4);
}int main(int argc, char **argv) {wb_robot_init();const double time_step = wb_robot_get_basic_time_step();// Get camerasfor (int i = 0; i < NUMBER_OF_CAMERAS; ++i)cameras[i] = wb_robot_get_device(camera_names[i]);// enable the two front cameraswb_camera_enable(cameras[0], 2 * time_step);wb_camera_enable(cameras[1], 2 * time_step);// Get the LEDs and turn them onfor (int i = 0; i < NUMBER_OF_LEDS; ++i) {leds[i] = wb_robot_get_device(led_names[i]);wb_led_set(leds[i], 1);}// Get the motors (joints) and set initial target position to 0for (int i = 0; i < NUMBER_OF_JOINTS; ++i)motors[i] = wb_robot_get_device(motor_names[i]);while (true) {
//    lie_down(4.0);
//    stand_up(4.0);
//    sit_down(4.0);
//    give_paw();
//    stand_up(4.0);
//    lie_down(3.0);
//    stand_up(3.0);
//    lie_down(2.0);
//    stand_up(2.0);
//    lie_down(1.0);
//    stand_up(1.0);
//    lie_down(0.75);
//    stand_up(0.75);lie_down(0.5);stand_up(0.5);lie_down(0.4);stand_up(0.4);lie_down(0.3);stand_up(0.3);lie_down(0.2);stand_up(0.2);lie_down(0.1);stand_up(0.1);               }wb_robot_cleanup();return EXIT_FAILURE;
}

可以自己编程实现更多复杂的运动。


在Webots中使用Spot或Spotmini说明

  • https://www.bilibili.com/video/bv1Dt4y1y72x

 

这篇关于Webots中Spot或SpotMini案例-焦 虑 腾 空-的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/250116

相关文章

MySql基本查询之表的增删查改+聚合函数案例详解

《MySql基本查询之表的增删查改+聚合函数案例详解》本文详解SQL的CURD操作INSERT用于数据插入(单行/多行及冲突处理),SELECT实现数据检索(列选择、条件过滤、排序分页),UPDATE... 目录一、Create1.1 单行数据 + 全列插入1.2 多行数据 + 指定列插入1.3 插入否则更

Python通用唯一标识符模块uuid使用案例详解

《Python通用唯一标识符模块uuid使用案例详解》Pythonuuid模块用于生成128位全局唯一标识符,支持UUID1-5版本,适用于分布式系统、数据库主键等场景,需注意隐私、碰撞概率及存储优... 目录简介核心功能1. UUID版本2. UUID属性3. 命名空间使用场景1. 生成唯一标识符2. 数

PostgreSQL的扩展dict_int应用案例解析

《PostgreSQL的扩展dict_int应用案例解析》dict_int扩展为PostgreSQL提供了专业的整数文本处理能力,特别适合需要精确处理数字内容的搜索场景,本文给大家介绍PostgreS... 目录PostgreSQL的扩展dict_int一、扩展概述二、核心功能三、安装与启用四、字典配置方法

Python中re模块结合正则表达式的实际应用案例

《Python中re模块结合正则表达式的实际应用案例》Python中的re模块是用于处理正则表达式的强大工具,正则表达式是一种用来匹配字符串的模式,它可以在文本中搜索和匹配特定的字符串模式,这篇文章主... 目录前言re模块常用函数一、查看文本中是否包含 A 或 B 字符串二、替换多个关键词为统一格式三、提

Python get()函数用法案例详解

《Pythonget()函数用法案例详解》在Python中,get()是字典(dict)类型的内置方法,用于安全地获取字典中指定键对应的值,它的核心作用是避免因访问不存在的键而引发KeyError错... 目录简介基本语法一、用法二、案例:安全访问未知键三、案例:配置参数默认值简介python是一种高级编

MySQL中的索引结构和分类实战案例详解

《MySQL中的索引结构和分类实战案例详解》本文详解MySQL索引结构与分类,涵盖B树、B+树、哈希及全文索引,分析其原理与优劣势,并结合实战案例探讨创建、管理及优化技巧,助力提升查询性能,感兴趣的朋... 目录一、索引概述1.1 索引的定义与作用1.2 索引的基本原理二、索引结构详解2.1 B树索引2.2

从入门到精通MySQL 数据库索引(实战案例)

《从入门到精通MySQL数据库索引(实战案例)》索引是数据库的目录,提升查询速度,主要类型包括BTree、Hash、全文、空间索引,需根据场景选择,建议用于高频查询、关联字段、排序等,避免重复率高或... 目录一、索引是什么?能干嘛?核心作用:二、索引的 4 种主要类型(附通俗例子)1. BTree 索引(

HTML中meta标签的常见使用案例(示例详解)

《HTML中meta标签的常见使用案例(示例详解)》HTMLmeta标签用于提供文档元数据,涵盖字符编码、SEO优化、社交媒体集成、移动设备适配、浏览器控制及安全隐私设置,优化页面显示与搜索引擎索引... 目录html中meta标签的常见使用案例一、基础功能二、搜索引擎优化(seo)三、社交媒体集成四、移动

六个案例搞懂mysql间隙锁

《六个案例搞懂mysql间隙锁》MySQL中的间隙是指索引中两个索引键之间的空间,间隙锁用于防止范围查询期间的幻读,本文主要介绍了六个案例搞懂mysql间隙锁,具有一定的参考价值,感兴趣的可以了解一下... 目录概念解释间隙锁详解间隙锁触发条件间隙锁加锁规则案例演示案例一:唯一索引等值锁定存在的数据案例二:

MySQL 表的内外连接案例详解

《MySQL表的内外连接案例详解》本文给大家介绍MySQL表的内外连接,结合实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录表的内外连接(重点)内连接外连接表的内外连接(重点)内连接内连接实际上就是利用where子句对两种表形成的笛卡儿积进行筛选,我