Skip to content

Commit 66cc1c7

Browse files
authored
Add files via upload
Add something new.
1 parent 5adc4c3 commit 66cc1c7

17 files changed

+6011
-31
lines changed

CallPython.cpp

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include<iostream>
2+
#include <Python.h>
3+
4+
using namespace std;
5+
6+
void CallPython(int times, double high, double**& ori) {
7+
Py_Initialize(); // 初始化python模块
8+
if (!Py_IsInitialized()) // 检查初始化是否成功
9+
{
10+
cout << "初始化失败!" << endl;
11+
Py_Finalize();
12+
}
13+
PyRun_SimpleString("import sys");
14+
PyRun_SimpleString("sys.path.append('./')"); // 设置python模块,搜寻位置,文件放在.cpp文件一起
15+
PyObject* pModule = PyImport_ImportModule("ToBeCalled"); // Python文件名
16+
if (!pModule) {
17+
cout << "py文件导入失败!" << endl;
18+
Py_Finalize();
19+
}
20+
else {
21+
PyObject* pDict = PyModule_GetDict(pModule);
22+
if (!pDict) {
23+
cout << "内容获取失败!" << endl;
24+
Py_Finalize();
25+
}
26+
PyObject* pFunc = PyObject_GetAttrString(pModule, "sim"); // Python文件中的函数名
27+
if (!pFunc) {
28+
cout << "函数导入失败!" << endl;
29+
Py_Finalize();
30+
}
31+
32+
PyObject* result = PyObject_CallFunction(pFunc, "id", times, high); // 调用函数
33+
for (int i = 0; i < times * times; i++)
34+
{
35+
ori[i] = new double[4];
36+
for (int j = 0; j < 4; j++)
37+
{
38+
ori[i][j] = PyFloat_AsDouble(PyTuple_GetItem(PyList_GetItem(result, i), j));
39+
}
40+
}
41+
}
42+
Py_Finalize();
43+
}

CallPython.h

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
3+
void CallPython(int, double, double**&);

CppAndPython.sln

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
2-
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 17
4-
VisualStudioVersion = 17.1.32210.238
5-
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppAndPython", "CppAndPython\CppAndPython.vcxproj", "{9449F018-36F2-4527-A30B-5D3F9B03857B}"
7-
EndProject
8-
Global
9-
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10-
Debug|x64 = Debug|x64
11-
Debug|x86 = Debug|x86
12-
Release|x64 = Release|x64
13-
Release|x86 = Release|x86
14-
EndGlobalSection
15-
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16-
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Debug|x64.ActiveCfg = Debug|x64
17-
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Debug|x64.Build.0 = Debug|x64
18-
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Debug|x86.ActiveCfg = Debug|Win32
19-
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Debug|x86.Build.0 = Debug|Win32
20-
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Release|x64.ActiveCfg = Release|x64
21-
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Release|x64.Build.0 = Release|x64
22-
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Release|x86.ActiveCfg = Release|Win32
23-
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Release|x86.Build.0 = Release|Win32
24-
EndGlobalSection
25-
GlobalSection(SolutionProperties) = preSolution
26-
HideSolutionNode = FALSE
27-
EndGlobalSection
28-
GlobalSection(ExtensibilityGlobals) = postSolution
29-
SolutionGuid = {CB7D77D1-DD58-4516-A787-9695E103F5B5}
30-
EndGlobalSection
31-
EndGlobal
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.1.32210.238
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppAndPython", "CppAndPython\CppAndPython.vcxproj", "{9449F018-36F2-4527-A30B-5D3F9B03857B}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Debug|x86 = Debug|x86
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Debug|x64.ActiveCfg = Debug|x64
17+
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Debug|x64.Build.0 = Debug|x64
18+
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Debug|x86.ActiveCfg = Debug|Win32
19+
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Debug|x86.Build.0 = Debug|Win32
20+
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Release|x64.ActiveCfg = Release|x64
21+
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Release|x64.Build.0 = Release|x64
22+
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Release|x86.ActiveCfg = Release|Win32
23+
{9449F018-36F2-4527-A30B-5D3F9B03857B}.Release|x86.Build.0 = Release|Win32
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {CB7D77D1-DD58-4516-A787-9695E103F5B5}
30+
EndGlobalSection
31+
EndGlobal

CppAndPython.vcxproj

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>16.0</VCProjectVersion>
23+
<Keyword>Win32Proj</Keyword>
24+
<ProjectGuid>{9449f018-36f2-4527-a30b-5d3f9b03857b}</ProjectGuid>
25+
<RootNamespace>CppAndPython</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>Application</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v143</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>Application</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v143</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>Application</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v143</PlatformToolset>
46+
<CharacterSet>Unicode</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>Application</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v143</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74+
<LinkIncremental>true</LinkIncremental>
75+
</PropertyGroup>
76+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
77+
<LinkIncremental>false</LinkIncremental>
78+
</PropertyGroup>
79+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
80+
<LinkIncremental>true</LinkIncremental>
81+
<ExternalIncludePath>$(Python)\include;$(ExternalIncludePath)</ExternalIncludePath>
82+
<LibraryPath>$(Python)\libs;$(LibraryPath)</LibraryPath>
83+
</PropertyGroup>
84+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
85+
<LinkIncremental>false</LinkIncremental>
86+
</PropertyGroup>
87+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
88+
<ClCompile>
89+
<WarningLevel>Level3</WarningLevel>
90+
<SDLCheck>true</SDLCheck>
91+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
92+
<ConformanceMode>true</ConformanceMode>
93+
</ClCompile>
94+
<Link>
95+
<SubSystem>Console</SubSystem>
96+
<GenerateDebugInformation>true</GenerateDebugInformation>
97+
</Link>
98+
</ItemDefinitionGroup>
99+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
100+
<ClCompile>
101+
<WarningLevel>Level3</WarningLevel>
102+
<FunctionLevelLinking>true</FunctionLevelLinking>
103+
<IntrinsicFunctions>true</IntrinsicFunctions>
104+
<SDLCheck>true</SDLCheck>
105+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
106+
<ConformanceMode>true</ConformanceMode>
107+
</ClCompile>
108+
<Link>
109+
<SubSystem>Console</SubSystem>
110+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
111+
<OptimizeReferences>true</OptimizeReferences>
112+
<GenerateDebugInformation>true</GenerateDebugInformation>
113+
</Link>
114+
</ItemDefinitionGroup>
115+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
116+
<ClCompile>
117+
<WarningLevel>Level3</WarningLevel>
118+
<SDLCheck>true</SDLCheck>
119+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
120+
<ConformanceMode>true</ConformanceMode>
121+
</ClCompile>
122+
<Link>
123+
<SubSystem>Console</SubSystem>
124+
<GenerateDebugInformation>true</GenerateDebugInformation>
125+
<AdditionalDependencies>python3.lib;python3_d.lib;python310.lib;python310_d.lib;%(AdditionalDependencies)</AdditionalDependencies>
126+
</Link>
127+
</ItemDefinitionGroup>
128+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
129+
<ClCompile>
130+
<WarningLevel>Level3</WarningLevel>
131+
<FunctionLevelLinking>true</FunctionLevelLinking>
132+
<IntrinsicFunctions>true</IntrinsicFunctions>
133+
<SDLCheck>true</SDLCheck>
134+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
135+
<ConformanceMode>true</ConformanceMode>
136+
</ClCompile>
137+
<Link>
138+
<SubSystem>Console</SubSystem>
139+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
140+
<OptimizeReferences>true</OptimizeReferences>
141+
<GenerateDebugInformation>true</GenerateDebugInformation>
142+
</Link>
143+
</ItemDefinitionGroup>
144+
<ItemGroup>
145+
<ClCompile Include="CallPython.cpp" />
146+
<ClCompile Include="main.cpp" />
147+
<ClCompile Include="Processing.cpp" />
148+
<ClCompile Include="ResetXml.cpp" />
149+
<ClCompile Include="tinyxml2.cpp" />
150+
</ItemGroup>
151+
<ItemGroup>
152+
<ClInclude Include="CallPython.h" />
153+
<ClInclude Include="main.h" />
154+
<ClInclude Include="Processing.h" />
155+
<ClInclude Include="ResetXml.h" />
156+
<ClInclude Include="tinyxml2.h" />
157+
</ItemGroup>
158+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
159+
<ImportGroup Label="ExtensionTargets">
160+
</ImportGroup>
161+
</Project>

CppAndPython.vcxproj.filters

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="源文件">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="头文件">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="资源文件">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
<Filter Include="tinyxml2">
17+
<UniqueIdentifier>{d8fbb35d-482a-440d-8937-7b8c6f523b11}</UniqueIdentifier>
18+
</Filter>
19+
</ItemGroup>
20+
<ItemGroup>
21+
<ClCompile Include="ResetXml.cpp">
22+
<Filter>源文件</Filter>
23+
</ClCompile>
24+
<ClCompile Include="tinyxml2.cpp">
25+
<Filter>tinyxml2</Filter>
26+
</ClCompile>
27+
<ClCompile Include="CallPython.cpp">
28+
<Filter>源文件</Filter>
29+
</ClCompile>
30+
<ClCompile Include="main.cpp">
31+
<Filter>源文件</Filter>
32+
</ClCompile>
33+
<ClCompile Include="Processing.cpp">
34+
<Filter>源文件</Filter>
35+
</ClCompile>
36+
</ItemGroup>
37+
<ItemGroup>
38+
<ClInclude Include="tinyxml2.h">
39+
<Filter>tinyxml2</Filter>
40+
</ClInclude>
41+
<ClInclude Include="ResetXml.h">
42+
<Filter>头文件</Filter>
43+
</ClInclude>
44+
<ClInclude Include="CallPython.h">
45+
<Filter>头文件</Filter>
46+
</ClInclude>
47+
<ClInclude Include="main.h">
48+
<Filter>头文件</Filter>
49+
</ClInclude>
50+
<ClInclude Include="Processing.h">
51+
<Filter>头文件</Filter>
52+
</ClInclude>
53+
</ItemGroup>
54+
</Project>

CppAndPython.vcxproj.user

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
</Project>

Cylinder.urdf

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<robot name="Cylinder">
3+
<link name="base_link">
4+
<!--视觉?材质?-->
5+
<visual>
6+
<!--描述初始位置-->
7+
<!--看不懂是拿来干啥的。。。。-->
8+
<origin xyz=" 0 0 0" rpy="0 0 0" />
9+
<!--创建一个圆柱体 cylinder:圆柱 geometry:几何形状-->
10+
<geometry>
11+
<cylinder length="0.2" radius="0.1732"/>
12+
</geometry>
13+
<!--将材质命名为yellow(实际颜色与之无关) -->
14+
<material name="yellow">
15+
<!--设置材质颜色(应该是RGB)最后一个应该是透明度-->
16+
<color rgba="0 0.4 0.8 1"/>
17+
</material>
18+
</visual>
19+
<!--好像是碰撞箱?没有这个圆柱骰就一直自由落体-->
20+
<collision>
21+
<!--仍然描述初始位置-->
22+
<origin xyz=" 0 0 0" rpy="0 0 0" />
23+
<!--创建圆柱体-->
24+
<geometry>
25+
<cylinder length="0.2" radius="0.1732"/>
26+
</geometry>
27+
</collision>
28+
<!--好像是惯性?没有这个会报错,不过能自动生成(但是报错刷屏看着很不舒服)-->
29+
<inertial>
30+
<!--依然描述初始位置-->
31+
<origin xyz=" 0 0 0" rpy="0 0 0" />
32+
<!--质量,单位为kg-->
33+
<mass value="1"/>
34+
<!-- 惯 性 张 量 -->
35+
<!--我物理专业都看不懂这玩意儿是什么东西,泪目-->
36+
<inertia ixx="1" ixy="0" ixz="0" iyy="1" iyz="0" izz="1"/>
37+
</inertial>
38+
</link>
39+
</robot>

0 commit comments

Comments
 (0)